Page 1 of 1

colon in text file causes hiccups

Posted: Mon Feb 16, 2009 3:25 pm
by JohnE
What am I doing wrong here? I saved this very short program as 'test.lsp':

(set 'infile (open (main-args 2) "r"))
(print (read-line infile) "\n")
(close infile)

It is in a directory with this very short file called 'test.txt':
a_label:

If I run this on the Windows console command line:
newlisp test.lsp test.txt

I get:
a_label:

ERR: symbol expected : "a_label:"

and am back in the command console.

If I change test.txt to:
a_label

It opens the file, prints 'a_label', and leaves me in newlisp, where I should be.

What is that colon doing?

John
(Oops, edited, because in the original posting I left out the 'a_label:' which atually gets printed)

colon in text file causes hiccups

Posted: Mon Feb 16, 2009 4:22 pm
by JohnE
Me again already.

If test.lsp is reduced to:

(set 'infile (open (main-args 2) "r"))
(close infile)

Then I still get the result:

ERR: symbol expected : "a_label:"

And back into the command line.

Seems like newLISP is reading the contents of the file without being asked. :(

I know it must be me, it always is. I've missed something.

Regards, John

Posted: Mon Feb 16, 2009 4:34 pm
by Lutz
this is what happens after executing on the command-line

newlisp test.lsp test.txt


newLISP loads test.lsp and executes it, which loads test.txt. Because test.lsp does not exit, newLISP tries to load text.txt as a program and tries to evaluate the string "a_label:". Because the ":" is syntax in newLISP awaiting a symbol after it.


Put and (exit) statement at the end of test.lsp and everything will be fine ;-)

Colon hic

Posted: Mon Feb 16, 2009 5:29 pm
by JohnE
Thanks Lutz, much obliged. I knew it was me (so I got that bit right).
A lesson soundly learned.

Regards, John