(current-line) vs. $0
Posted: Sat Dec 06, 2003 10:15 pm
Using HPW's NeoBook interface to newLISP.DLL, I wrote this program to copy an input text file (Data1.txt) to an output text file (Data2.txt) eliminating duplicate entries along the way. Basically, (unique (contents of Data1.txt)) -> Data2.txt.
This is the NeoBook Interface which establishes the input and output files and then calls the NewLisp code:
And here is LispCode.Txt (the newLISP code is kept in a separate file and read by the hpwFileRead line above):
My question is this: On manual page 57, (current-line) is deprecated in favor of $0, but I'm not sure how to use $0. I originally wrote (in part):
but that didn't work at all, so I tried:
thinking that the value of $0 had to be captured quickly before it could was changed by another funciton. But that didn't work, either.
Instead of $0 I'm using (current-line) successfully but wondering what I should be using?
Thanks,
-- Sam
This is the NeoBook Interface which establishes the input and output files and then calls the NewLisp code:
Code: Select all
SetVar "[LispCode]" "(set 'inFile (open {[PubDir]Data1.txt} {read}))"
hpwNewLispCall "[PubDir]" "[LispCode]" "[LispResult]"
SetVar "[LispCode]" "(set 'outFile (open {[PubDir]Data2.txt} {write}))"
hpwNewLispCall "[PubDir]" "[LispCode]" "[LispResult]"
hpwFileRead "[PubDir]LispCode.txt" "ALL" "[LispCode]"
hpwNewLispCall "[PubDir]" "[LispCode]" "[LispResult]"
Code: Select all
(set 'uniqueLines '())
(while (read-line inFile)
(if (not (member (current-line) uniqueLines))
(set 'uniqueLines (append uniqueLines (list (current-line))))))
(close inFile)
(map (lambda (aLine) (write-line aLine outFile)) uniqueLines)
(close outFile)
Code: Select all
(while (read-line inFile)
(if (not (member $0 uniqueLines))
(set 'uniqueLines (append uniqueLines (list $0)))))
Code: Select all
(while (read-line inFile)
(set 'myLine $0)
(if (not (member myLine uniqueLines))
(set 'uniqueLines (append uniqueLines (list myLine)))))
Instead of $0 I'm using (current-line) successfully but wondering what I should be using?
Thanks,
-- Sam