Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoLISP OPEN function limitation

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
337 Views, 6 Replies

AutoLISP OPEN function limitation

I've come across what appears to be a length limitation for the filename on
the AutoLISP OPEN function (AutoCAD 2000 and 2000i).

If I provide a path/filename that exceeds 126 characters, the open function
fails.

Is this an oversite from the usual 255 character limit on other settings? Is
it going to be changed?

Thanx, Tony
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

Anthony:

I don't know if there is a limitation to the filename length, but passing
the filename as a variable may help.
by example:

(setq fPtah "C:/..../")
(setq fName "xxxFile.xxx")
(setq fullName (strcat fPath fName))
(setq fp (open fullName "r"))

-gnb
Message 3 of 7
Anonymous
in reply to: Anonymous

gaston@systempo.cl (Gaston Nunez) wrote in
<4A189B22EFC7CEEDAA9CA57AB2179BB4@in.WebX.maYIadrTaRb>:

>Anthony:
>
>I don't know if there is a limitation to the filename length, but passing
>the filename as a variable may help.
>by example:
>
>(setq fPtah "C:/..../")
>(setq fName "xxxFile.xxx")
>(setq fullName (strcat fPath fName))
>(setq fp (open fullName "r"))
>
>-gnb
>
>

Gaston,

I am using a variable for the filename similar to what you've shown.
I've even written a snippet of code for testing purposes that princ's the
filename value (setq by a getfiled call) and it's strlen prior to the
'open' request. When it fails, my open file variable equals nil.

When I run the test code it works fine until the strlen exceeds 126
characters. I use explorer between tests to lengthen the directory name
until the test routine fails.

With users creating directories with long names, it doesn't take long to
exceed this 126 character limit. I will probably have to issue a warning
about directory name length now!

Tony
Message 4 of 7
Anonymous
in reply to: Anonymous

Here is a possible work-around:

If you are reading a file, copy the file to a folder more accessible to the
"open" function, read it, and then delete it.

If you are writing a file, write it in a more accessible location and then
copy it to the correct location.

If you are adding to a file...well, you get the idea. If I'm not mistaken,
Visual LISP has functions that can copy and delete the files as necessary.

Anthony Dawe wrote...
>...
>With users creating directories with long names, it doesn't take long to
>exceed this 126 character limit. I will probably have to issue a warning
>about directory name length now!
>
>Tony
Message 5 of 7
Anonymous
in reply to: Anonymous

randy.richardson@york.com (Randy Richardson) wrote in
<685ACA675E262403247E4FF02EFBE752@in.WebX.maYIadrTaRb>:

>Here is a possible work-around:
>
>If you are reading a file, copy the file to a folder more accessible to
the
>"open" function, read it, and then delete it.
>
>If you are writing a file, write it in a more accessible location and then
>copy it to the correct location.
>
>If you are adding to a file...well, you get the idea. If I'm not
mistaken,
>Visual LISP has functions that can copy and delete the files as necessary.
>
>Anthony Dawe wrote...
>>...
>>With users creating directories with long names, it doesn't take long to
>>exceed this 126 character limit. I will probably have to issue a warning
>>about directory name length now!
>>
>>Tony
>

Randy,

Thanx for the ideas....

They worked fine until the file or directory contains spaces. The VL-FILE-
COPY function fails if the filenames contain spaces (which wasn't a problem
for the OPEN function).

Tony
Message 6 of 7
Anonymous
in reply to: Anonymous

Tony,

This works for me, even with spaces:

(if (not dos_copy)(arxload "doslib14"))
(dos_copy "file 1" "file 2")

Since you are using AutoCAD 2000/2000i, you will have to adjust the name of
the .arx file. If you don't already have DOSLib on your computer (in R14 at
least it was shipped with AutoCAD) it can be downloaded from www.mcneel.com

Good luck.

Anthony Dawe wrote...

>Randy,
>
>Thanx for the ideas....
>
>They worked fine until the file or directory contains spaces. The VL-FILE-
>COPY function fails if the filenames contain spaces (which wasn't a problem
>for the OPEN function).
>
>Tony
Message 7 of 7
Anonymous
in reply to: Anonymous

randy.richardson@york.com (Randy Richardson) wrote in
<595D8E354AD6D6B479AF58340B01A93C@in.WebX.maYIadrTaRb>:

>Tony,
>
>This works for me, even with spaces:
>
>(if (not dos_copy)(arxload "doslib14"))
>(dos_copy "file 1" "file 2")
>
>Since you are using AutoCAD 2000/2000i, you will have to adjust the name
of
>the .arx file. If you don't already have DOSLib on your computer (in R14
at
>least it was shipped with AutoCAD) it can be downloaded from
www.mcneel.com
>
>Good luck.
>
>Anthony Dawe wrote...
>
>>Randy,
>>
>>Thanx for the ideas....
>>
>>They worked fine until the file or directory contains spaces. The VL-
FILE-
>>COPY function fails if the filenames contain spaces (which wasn't a
problem
>>for the OPEN function).
>>
>>Tony
>
>

Randy,

I'll have to try the DOSlib program as you suggest. I had used it prior to
getting Visual LISP with it's new functions in R14 (I was a Vital LISP
user, so I jumped right into Visual LISP).

Thanx again, Tony

P.S. I wonder if Autodesk is going to address these inconsistancies in
Visual LISP's functions (open can handle spaces; vl-file-copy can't. vl-
file-copy can handle longer filenames; open can't). Hopefully they'll add
it to the list!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost