Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - SHX

#1
newLISP and the O.S. /
December 24, 2007, 07:46:35 AM
I too have plans aon using this important module.



Steven
#2
newLISP in the real world /
November 15, 2007, 12:47:23 PM
:-)

just learning. thanks for your help and direction.
#3
newLISP in the real world /
November 15, 2007, 07:44:17 AM
Thanks Rickyboy for your help. It really opened my eyes to how to code in Newlisp



I unserstood from you the value of define and used it in definning a condition that I am checking for.







Here is how I did it at the end. I did not wanted to exit the loop but rather just skip blank lines.


(define (the-line-is-empty) (null? (current-line) ) )

;;;-----------------------------------
;;; Now, let the rubber meet the road.

(let ((inFile (open in-filename "read"))
      (outFile (open out-filename "write")))
  (while (read-line inFile)
    (unless (the-line-is-empty) ;... if blank skip
    (letn ((the-line (parse (current-line) {,} 0))
           (thepgmcode (int (eval-string (the-line 0))))
           (repl-num (if (find thepgmcode not-available-set)
                         (allocate-from is-available-set)
                          thepgmcode)))
      (write-line
      (join
      (set-nth 0 the-line (string repl-num )) {,})
      outFile)))))
#4
newLISP and the O.S. /
November 15, 2007, 07:39:18 AM
Thanks Lutz,



I didn't realize that there was stuff in the documentation.
#5
newLISP and the O.S. / Help with DLL Call
November 14, 2007, 01:14:41 PM
I am trying to call a DLL with the following requirements
QuoteDWORD __stdcall EnumeratePIE(long VID, long *data, long &count)



Call EnumeratePIE() once, before doing anything else, to determine a list of available devices. For our uses, always pass our VID of 0x05F3 for the first parameter, so that only PI Engineering devices will be included in the list.



The count parameter MUST be long, not int, even though Borland defines these as having the same meaning. The value returned in this parameter is the number of devices, not the number of data values.



The long *data parameter should be an array of at least 100 long values. Since there are four values for each device, PIEHID will return information on up to 25 HID devices. Since this parameter is a pointer, one could also pass a pointer to an array of structures, each containing four named long values. The advantage of doing this would be that you then don't have to remember the index offset for each variable type. The four long values for each device are, in sequence: USB Product ID, HID Usage, HID Usage Page, and Handle. The "handle" is a number identifying the device to additional PIEHID calls that follow. Zero is a valid value, so don't confuse zero to mean "no device." This number has no meaning to the operating system; it is purely for internal use. Usage and Usage Page define whether the device is a mouse, keyboard, etc, according to the HID standard.


The part that I have no idea is how to do an array of integer values.



I would appreciate any help in how to communicate with this dll.



Steven
#6
newLISP in the real world /
November 14, 2007, 04:56:55 AM
Rickyboy

Could you have coded it like this?
(catch
      (letn ((the-line (parse (current-line) {,} 0))
             (thepgmcode (int (eval-string (the-line 0))))
             (cond ((null? thepgmcode) (throw 'escape)) )
             (repl-num
                             ((find thepgmcode not-available-set)
                              (allocate-from is-available-set))
                             thepgmcode)))
        (write-line (join (set-nth 0 the-line (string repl-num )) {,})
                    outFile))

Where  (cond ((null? thepgmcode) (throw 'escape))  comes earlier.



It would seem to make more sense.



Steven
#7
newLISP in the real world /
November 13, 2007, 07:31:34 PM
Thanks rickyboy.
#8
newLISP and the O.S. /
November 13, 2007, 02:01:05 PM
Thanks, now I see.



It would be great if someone would develop such a wrapper.
#9
newLISP in the real world /
November 13, 2007, 01:19:05 PM
Thanks Lutz,



rickyboy
QuoteDon't know what you mean by this. Can you elaborate?


What I mean is do I have to worry about the fact that if I am processing a blank line and I do the parse and find that there is no number in the position where I expected the number to be or if there was a mistake and there weas charachters instead of a number that it wouldn't cause a problem.


QuoteI'd wrap the rest of the processing (the "punchline"), starting from the opening of the principal files, into a let statement (see the code below).


I understand and really appreciate the tip.





Steven
#10
newLISP and the O.S. /
November 13, 2007, 01:09:11 PM
QuoteHowever, by creating a newLISP interface to it

m35,



Excuse my ignorance but does that mean that the interface to the Microsoft Scripting Control can be written in Newlisp script by interfacing with the dll or does it mean some sort of external interface in c or something.



Steven
#11
newLISP and the O.S. /
November 13, 2007, 10:08:45 AM
m35
QuoteThe easiest way to do COM is to use Microsoft Scripting Control (like ws4ahk uses).


I would like to understand what you are saying.



Are you saying that currenlty there is a facility within Newlisp to use Microsoft Scripting Control and then you can access com objects via a scripting language?



Steven
#12
newLISP in the real world /
November 13, 2007, 09:49:55 AM
rickyboy, thanks for getting back to me.



You wrote
(define code-domain (sequence 1 100))
I wrote
(setq the-number-list  (sequence 1 100) )

Why is "define" more appropriate than "setq"



Steven
#13
newLISP in the real world /
November 12, 2007, 05:40:36 AM
Thanks all for your help. I was a little sidelined so am finally getting back to this.



Here is how I did it.
; this will clean out the numbers that should not be used when loading a table

;---- List of Unavailable Numbers
(setq not-available-list
(map int
(parse ( read-file "test4.txt" ) {rn} 0)
)
)
(println "not available " not-available-list)


;---- List of All Numbers in a range
(setq the-number-list
(sequence 1 100)
)
(setq is-available-list
(difference the-number-list not-available-list)
)
(println "is available "is-available-list )


; open the file and read the number
(set 'outFile (open "tempexpo.txt" "write"))
(set 'inFile (open "tempexp.txt" "read"))

(while (read-line inFile)
  (setq the-line   ; create a list from a line in the file
  (parse (current-line) {,} 0)
  )
  (setq thepgmcode (int (eval-string (the-line 0)))) ; get the first member of the list which is the pgm code
  (setq repl-num ; set repl-num to the pgm code or an avail number
  (if (find thepgmcode not-available-list)
  (pop is-available-list )
  thepgmcode )
  )
  (write-line (join (set-nth 0 the-line (string repl-num )) {,} ) outFile)
 )


Any comments. I am new at this and appreciate the feedback.



Also, what would be the best way for me to code a check that there is a number in the position I am expecting and if not to skip that record?



Thanks



Steven
#14
newLISP in the real world / Some help needed coding
November 01, 2007, 06:02:41 PM
Hi



Here is what I am trying to do.



I have a file that looks like the following
"11","abc","some value"
"12","aaa","another value"
"13","bbb","next value"


What I have to do is

1- read each line

2- check the number in quotes against a list of numbers that should not be used

3- If it does exist in that list, replace it with a number from a list of available numbers

4- rewrite the updated line





I am able to do step 1 and 2 and I get an available number from an available number list.



But how would I rewite the line and replace the number in quotes.



Thanks for your help



Steven
#15
Can someone give me an example of how to code a function that creates  multiple sub directories



For instance if I pass "c:firstdirseconddirthirddir" to the function and only "c:" exists, that the code will create "c:firstdir" and then "c:firstdirseconddir" and finally "c:firstdirseconddirthirddir"





Steven