TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: V-Man on July 15, 2004, 10:09:14 AM

Title: List Question
Post by: V-Man on July 15, 2004, 10:09:14 AM
Is there a maximum number of characters that can be in a list?
Title: List Question
Post by: SMadsen on July 15, 2004, 10:16:59 AM
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)
Title: List Question
Post by: V-Man on July 15, 2004, 10:21:04 AM
Quote

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.
Title: List Question
Post by: Keith™ on July 15, 2004, 12:42:56 PM
never tried, but there is a 1024 character limit on certain strings
Title: List Question
Post by: Jeff_M on July 15, 2004, 01:33:09 PM
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
Title: List Question
Post by: SMadsen on July 15, 2004, 02:44:37 PM
Just did a test with this:
Code: [Select]
(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.
Title: List Question
Post by: Mark on July 15, 2004, 03:04:23 PM
this is what I get;
Code: [Select]

Command: (strlentest)
2048
4096
8192
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
; error: ; error:
Title: List Question
Post by: SMadsen on July 15, 2004, 04:22:36 PM
Probably depends on available heap space. But 134,217,728 is a pretty long string, too :)
Title: List Question
Post by: V-Man on July 15, 2004, 04:49:30 PM
Same here..

Code: [Select]

Command: (STRLENTEST)
2048
4096
8192
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
; error: ; error:
Title: List Question
Post by: Keith™ on July 15, 2004, 10:31:08 PM
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.
Title: List Question
Post by: SMadsen on July 16, 2004, 03:13:12 AM
Quote from: Keith
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?