TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on July 15, 2004, 10:09:14 AM
-
Is there a maximum number of characters that can be in a list?
-
Of characters? Do you mean maximum number of items in a list or maximum number of characters in a string?
To either: no maximum ('cept for memory limitations)
-
Of characters? Do you mean maximum number of items in a list or maximum number of characters in a string?
Yes, Sorry I mean items.
-
never tried, but there is a 1024 character limit on certain strings
-
FWIW, here is the string length of an Mtext object in one of my drawings. I have no problem setting/retrieving a variable assigned to the string.
Command: (strlen (vla-get-textstring (vlax-ename->vla-object (car (entsel)))))
Select object: 7987
Jeff
-
Just did a test with this:
(defun strLenTest (/ astr)
(defun makeFirstString (/ str a)
(setq a 65 str "")
(repeat 1024
(setq str (strcat str (chr a))
a (cond ((<= a 122) (1+ a))(65)))
)
str
)
(setq astr (makeFirstString))
(while (not (vl-catch-all-error-p astr))
(setq astr (vl-catch-all-apply 'strcat (list astr astr)))
(princ (strlen astr))(terpri)
)
)
It got to make a string with 268,435,456 characters and then ran into an access violation when trying to concatenate two times 268,435,456 characters.
-
this is what I get;
Command: (strlentest)
2048
4096
8192
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
; error: ; error:
-
Probably depends on available heap space. But 134,217,728 is a pretty long string, too :)
-
Same here..
Command: (STRLENTEST)
2048
4096
8192
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
; error: ; error:
-
Perhaps I should have made myself a little clearer ... try to put a string in a lisp file that is greater than 1024 characters...you can strcat them together till you run out of heap space, but the string itself must be below that length.... I had that problem in some programs I had written and had to put the items in dofferent variables first, then strcat them together in the program.
-
Perhaps I should have made myself a little clearer ...
Oh, the test was not to prove you wrong or anything .. it was simply pure curiosity.
I know there are limitations on string input and strings in entity data and such. Personally, I've not experienced a limitation on strings in lisp files - probably because I never stuffed a 1024+ character string anywhere. Are you referring to limitations for I/O functions?