Steven
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
(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)))))
DWORD __stdcall EnumeratePIE(long VID, long *data, long &count)Quote
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.
(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))
Don't know what you mean by this. Can you elaborate?Quote
I'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).Quote
However, by creating a newLISP interface to itQuote
The easiest way to do COM is to use Microsoft Scripting Control (like ws4ahk uses).Quote
; 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)
)
"11","abc","some value"
"12","aaa","another value"
"13","bbb","next value"