LISP function works in BricsCad - Not AutoCad

 Greetings,

I am not sure why this LISP function works in BricsCad and not AutoCad.
I am using Bricscad Pro, Version 13.2.4 (x64) revision 29780
I have tried this same LISP function in AutoCAD 2012 and 2015 with the same results:
; error: bad argument type: streamp nil

With BricsCad, the text file is generated as expected with the Title and Drawing Number.
Searching the Internet and similar problems around , "; error: bad argument type: streamp nil", It seems that others would think that the error comes somewhere between the two lines:

(setq fileout (open filelast "a"))
and
(Close fileout)

Just wondering if any of you who are using BricsCad and AutoCad with DOSLIB can check it out and see if you can come up with anything.

Thanks


Comments

  • Does the folder exist? Do you have rights to create a file in that folder?
    To help with debugging add a 'print' here:
    [code](print (setq fileout (open filelast "a")))[/code]
    I suspect that fileout is nil.
  • Dear Doug,

    at least I can confirm, that there is a strange bug in AutoCAD, I noticed in Acad 2008 ... 2016 :
    sometimes, for simply unknown reason, AutoCAD/AutoLISP fails to open files ...
    I encountered this with my Lisp Benchmarks, benching (open) function ...

    AutoLISP is rather old, and Autodesk loves to replace OS functions with their own (try installing AutoCAD from DVD - always failed for me, until copied to HDD);
    good chances, that there are such old own functions still alive in AutoLISP.

    potential candidates :
    - filename too long
    - path too long
    - to many files are / were opened

    I never found a solution to bypass that strange bug :-(
    many greetings !
  • Roy,

    You are correct.

    From BricsCAd

    !Fileout = #

    From AutoCAD

    !Fileout  = nil

    Torsten,

    "AutoLISP is rather old", yes it is and so am I. Don't know if I am up to learning VLisp. This Lisp function is just a modified version of one that I used from R13 through 2004. It used to work fine as it is. Since coming back to this business, I have had AutoCAD LT, and BricsCad. The boss is not up to buying new full versions of AutoCAD, so I test LISP functions in BricsCad, then find out if they work or not in AutoCAD when other people here who have Acad full versions try them out.

    Thanks for the replies,

    Doug

     

    Does the folder exist? Do you have rights to create a file in that folder?
    To help with debugging add a 'print' here:
    (print (setq fileout (open filelast "a")))    

    I suspect that fileout is nil.
  • I think that one thing was modified as HTML code or something. I will put quotes around the BricsCad response to see if it looks closer to normal. At any rate. Fileout is a thing in BricsCad and Nil in AutoCAD.

    !fileout: "#"

  • Here is a graphic that explains it better

    imageBricsAutoCad.png
  • Dear Doug,

    yes, the question is - why it that file handle NIL in AutoCAD ? :-)
    In worst case it is that bug as I noticed ... but that happened after opening + closing a file hundreds of times ...
    in normal usage (few open + close) there should be no problem, of course.

    So I can only guess :
    - search pathes ? is the filename given with full specification ?
    - run AutoCAD with admin rights ("run as admin" in desktop icon)

    I hope you can identify what causes AutoCAD/AutoLISP to fail here ...
    many greetings !
  • Torsten,

    One guy was sick today so I logged onto his computer, to check things out. I am a local administrator on the CAD computers only. The LISP file worked with AutoCAD Electrical 12, when I was logged on as me (the administrator). Not sure yet but it may be a "Windows Permission" thing.

    Doug

  • Doug, that was my first hunch as well (see post #2).
  • Dear Doug,

    yes, very likely this indicates a permisson problem (as Roy pointed to as well) ...
    so it seems, the Lisp code needs to be reviewed, especially where the Lisp code wants to open the file ...
    Usually, thanks MS, the standard program folders are usually not enabled for writing, for standard user rights ...

    Installing applications to non-default folder then allows this :-)
    So far for MS' security strategy - installing into other than suggested folder "breaks" the security :-)
    Or, in other words, allows you to work properly :-)

    Especially, if no path is specified with LISP's (open) statement, then the actual "OS current folder" will be used - than can widely vary;
    normally, it is specified in desktop shortcut ...

    many greetings !
  • Roy and Torsten,

    Thank you both for your responses. They were both helpful in figuring out AutoCad here On the BricsCad site.

    Thanks,

    Doug

This discussion has been closed.