AutoLISP open function returns 'nil'

Hi there:
I used to create single routines un LISP for programming.
When i use open in BricsCad, always returns 'nil'
An example could be the next:
(setq myfile (open "file.txt" "r"))

Of course, i've been checked the file exists and the path is correct. Even using the parameters "w" or "a" instead of "r" the result always is 'nil'
I compare my code with AutoCAD and i can see that works (in AutoCAD)

Has this happened always in BricsCad?
Thanks in advance

Comments

  • What does this return:
    (findfile "file.txt")

  • As Roy said - it is most likely, that the file "file.txt" is not found by the (open) function ...
    (findfile "file.txt") can be used to verify ...

    You mentioned "file exists and the path is correct" - which path ?
    In generally, using code like
    (setq ffile (findfile "file.txt"))
    (if (not ffile) (exit))
    (setq fptr (open ffile "r/w"))

    is the safest approach.

    Also, please check your support path settings ... probably, some folders are missing ?
    many greetings !

  • Are you sure that "file.txt" is in a folder on the file search path? You can access the path with SRCHPATH at the command line or from the menu using Settings > Settings > Program options > Files > Support file search path.

This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. Click one of the buttons on the top bar to get involved!