See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: What is the real maximum string length?

  1. #1
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Question What is the real maximum string length?

    What is the real maximum string length?

    Some documentation says 100 characters, some says 256, and I just "strcat" -ed a 450 character string.

    Anybody have the true scoop on string length limitations and repricussions in AutoLISP/CAD's environment?

    Thanks

    Doug

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    Are you talking about a TEXT object, MTEXT object, or a lisp symbol?
    C:> ED WORKING....


    LinkedIn

  3. #3
    Member
    Join Date
    2010-08
    Posts
    21
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    Sorry, as a LISP symbol specifically, but a clear description of the actual limitations would be nice to know. in all it's places.

  4. #4
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    Which documentation gives the maximum string lengths you mentioned? I've seen a number of non-LISP references indicate 80 characters (ISOGEN), 256 (Win2000 registry REG_SZ entry), and a few others for various applications but nothing specificaly for LISP. I've run LISP string values in the 1000+/- character region before problems start to crop up, but I can't tell if thats from the string value itself or where the value is being sent to.

  5. #5
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    ;This autolisp program i wrote to test string length.
    ;I let it run up to 700,000 charaters then canceled it.
    ;if someone wants to crash autocad and let it run longer, let me know what the results were.

    Code:
    (DEFUN C:SLT ()
     (PROMPT "\n *STRING LIST TEST* ")
     (SETQ HS "X")
     (SETQ CT 1)
     (SETQ LP 1)
     (WHILE LP
      (SETQ HS (STRCAT HS "X"))
      (SETQ CT (+ CT 1))
      (PROMPT "\n CHARACTER # ")
      (PRINC CT)
     );END LP
    );END SLT
    Attached Files Attached Files

  6. #6
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    Quote Originally Posted by aaronic_abacus View Post
    ;This autolisp program i wrote to test string length.
    ;I let it run up to 700,000 charaters then canceled it.
    ;if someone wants to crash autocad and let it run longer, let me know what the results were.

    Code:
    (DEFUN C:SLT ()
     (PROMPT "\n *STRING LIST TEST* ")
     (SETQ HS "X")
     (SETQ CT 1)
     (SETQ LP 1)
     (WHILE LP
      (SETQ HS (STRCAT HS "X"))
      (SETQ CT (+ CT 1))
      (PROMPT "\n CHARACTER # ")
      (PRINC CT)
     );END LP
    );END SLT
    Are you assuming that you would get some kind of error to stop the loop? I don't see anything to change the value of LP. What if additional attempts to use (strcat) simply have no effect on the contents of HS? Looks like an endless loop.

    Since a lisp symbol is a named pointed to some value, it depends on the data type of the value stored in the symbol. Here is the desc of an ActiveX String data type.
    There are two kinds of strings: variable-length and fixed-length strings.

    • A variable-length string can contain up to approximately 2 billion (2^31) characters.
    • A fixed-length string can contain 1 to approximately 64K (2^16) characters.
    Last edited by Ed Jobe; 2011-10-04 at 10:05 PM.
    C:> ED WORKING....


    LinkedIn

  7. #7
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    ;ok ed, i edited the program to be based on STRLEN and ran it to 700,000 again and it still works.
    ; who wants to crash autocad with it?

    Code:
    (DEFUN C:SLT ()
     (PROMPT "\n *STRING LIST TEST* ")
     (SETQ HS "X")
     (SETQ LP 1)
     (WHILE LP
      (SETQ HS (STRCAT HS "X"))
      (SETQ CT (STRLEN HS))
      (PROMPT "\n CHARACTER # ")
      (PRINC CT)
     );END LP
    );END SLT
    Attached Files Attached Files

  8. #8
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    Here's a much "quicker" test:
    Code:
    (defun c:TestStrLen (/ s)
      (setq s "X")
      (while t
        (setq s (strcat s s))
        (princ "\n")
        (princ (strlen s))
      )
    )
    Doubling the string's length each time, and deliberately going through an infinite loop. Running it on my Vanilla 2011 on WinXP 32bit ACad crashes after displaying a strlen of 268435456.

    So I'm guessing it's governed by the 32bit integer maximum of 4294967295, or very close to that. Perhaps someone could test the same on 64bit (don't have one available just now).

    As for the rest of the OP's questions. Acad has several "limits" on string lengths. Here's a few:

    1. Layer, block & style names: if ExtNames=0 then these may only be 31 characters long. Otherwise 255 and may also include some extra characters which are not allowed otherwise.
    2. Linetype definitions have some weird stuff as well: http://www.upfrontezine.com/tailor/tailor15.htm
    3. Text (DText) objects have a maximum character length of 255. This comes from the limitation in DXF of only allowing 255 characters per DXF item and and TEXT only having one DXF-code-1 item. Note the limit includes special characters, e.g. the %%c for the diameter character counts as 3 characters (not one).
    4. MText has effectively no limit, though it seems around 32000 http://forums.augi.com/showthread.php?t=37010. This is because MText (in addition to the DXF-code-1) may contain an "unlimited" number of code-3's. Thus it breaks the length into chunks of 250 each. http://docs.autodesk.com/ACD/2011/EN...2e719-79f8.htm

  9. #9
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    Actually just realized I'm not counting the numbers correctly. That 268435456 is actually 256 MB. At first I though it's something to do with RAM size, as my PC only has 3GB. But that 256 sounds a lot more like a hard-wired limit to me.

  10. #10
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: What is the real maximum string length?

    Quote Originally Posted by aaronic_abacus View Post
    ;ok ed, i edited the program to be based on STRLEN and ran it to 700,000 again and it still works.
    ; who wants to crash autocad with it?
    Aaron, I think you missed my point. I didn't say anything about STRLEN. That line is just part of reporting to the user. The strcat function does the real work of the loop, by adding X's on each iteration. Inerb sped up the loop by doubling the characters added each loop. You could have added 100 or 1000 X's. 700k iterations isn't close to the limit.

    What I was referring to is that you've got LP set to 1 and then use (While LP). Nothing in your code changes the value of LP, so you've got an infinite loop. Crashing acad is not a very elegant way to get out of a loop...unless that was your goal as was the case with Inerb's example. Hence, my question was if you were expecting an error to get you out of the loop.
    C:> ED WORKING....


    LinkedIn

Page 1 of 2 12 LastLast

Similar Threads

  1. 2014: maximum alignment length?
    By cadtag in forum AutoCAD Civil 3D - Alignments
    Replies: 6
    Last Post: 2014-08-30, 08:35 PM
  2. Data from file(string) to real
    By Deyan Dechev in forum AutoLISP
    Replies: 9
    Last Post: 2014-05-08, 01:09 PM
  3. Maximum Filename Length with ArcGIS
    By Opie in forum Geospatial - General
    Replies: 4
    Last Post: 2013-02-26, 11:12 PM
  4. Maximum Triangle Length - NOT
    By Spokes in forum AutoCAD Civil 3D - Surfaces
    Replies: 1
    Last Post: 2010-03-17, 03:50 PM
  5. Convert string to real - precision
    By abdulhuck in forum AutoLISP
    Replies: 9
    Last Post: 2007-11-06, 11:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •