Limit to list length?

Discussion in 'AutoCAD' started by BillZ, Apr 22, 2004.

  1. BillZ

    BillZ Guest

    R2005 Vlisp:

    I made a .lsp file that contains a list of RGB color numbers.

    When I run the list, it sets the var RGB_Lst to the value of that list but at the end of the program I get a:
    "Application ERROR: Bad argument type
    The var is set to the value okay and if I shorten the list somewhat then I don't get the error anymore.

    This is the only thing I have in the lisp and I have tried it without the quotes, the list and used a defun but still get the same error:

    (setq RGB_Lst
    (list
    '(0 0 0)
    '(255 0 0)
    '(255 255 0)
    '(0 255 0)
    '(0 255 255)
    '(0 0 255)
    '(255 0 255)
    '(255 255 255)
    '(128 128 128)
    '(192 192 192)
    '(255 0 0)
    '(255 127 127)
    '(204 0 0)
    '(204 102 102)
    '(153 0 0)
    '(153 76 76)
    '(127 0 0)
    '(127 63 63)
    '(76 0 0)
    '(76 38 38)
    '(255 63 0)
    '(255 159 127)
    '(204 51 0)
    '(204 127 102)
    '(153 38 0)
    '(153 95 76)
    '(127 31 0)
    '(127 79 63)
    '(76 19 0)
    '(76 47 38)
    '(255 127 0)
    '(255 191 127)
    '(204 102 0)
    '(204 153 102)
    '(153 76 0)
    '(153 114 76)
    '(127 63 0)
    '(127 95 63)
    '(76 38 0)
    '(76 57 38)
    '(255 191 0)
    '(255 223 127)
    '(204 153 0)
    '(204 178 102)
    '(153 114 0)
    '(153 133 76)
    '(127 95 0)
    '(127 111 63)
    '(76 57 0)
    '(76 66 38)
    '(255 255 0)
    '(255 255 127)
    '(204 204 0)
    '(204 204 102)
    '(153 153 0)
    '(153 153 76)
    '(127 127 0)
    '(127 127 63)
    '(76 76 0)
    '(76 76 38)
    '(191 255 0)
    '(223 255 127)
    '(153 204 0)
    '(178 204 102)
    '(114 153 0)
    '(133 153 76)
    '(95 127 0)
    '(111 127 63)
    '(57 76 0)
    '(66 76 38)
    '(127 255 0)
    '(191 255 127)
    '(102 204 0)
    '(153 204 102)
    '(76 153 0)
    '(114 153 76)
    '(63 127 0)
    '(95 127 63)
    '(38 76 0)
    '(57 76 38)
    '(63 255 0)
    '(159 255 127)
    '(51 204 0)
    '(127 204 102)
    '(38 153 0)
    '(95 153 76)
    '(31 127 0)
    '(79 127 63)
    '(19 76 0)
    '(47 76 38)
    '(0 255 0)
    '(127 255 127)
    '(0 204 0)
    '(102 204 102)
    '(0 153 0)
    '(76 153 76)
    '(0 127 0)
    '(63 127 63)
    '(0 76 0)
    '(38 76 38)
    '(0 255 63)
    '(127 255 159)
    '(0 204 51)
    '(102 204 127)
    '(0 153 38)
    '(76 153 95)
    '(0 127 31)
    '(63 127 79)
    '(0 76 19)
    '(38 76 47)
    '(0 255 127)
    '(127 255 191)
    '(0 204 102)
    '(102 204 153)
    '(0 153 76)
    '(76 153 114)
    '(0 127 63)
    '(63 127 95)
    '(0 76 38)
    '(38 76 57)
    '(0 255 191)
    '(127 255 223)
    '(0 204 153)
    '(102 204 178)
    '(0 153 114)
    '(76 153 133)
    '(0 127 95)
    '(63 127 111)
    '(0 76 57)
    '(38 76 66)
    '(0 255 255)
    '(127 255 255)
    '(0 204 204)
    '(102 204 204)
    '(0 153 153)
    '(76 153 153)
    '(0 127 127)
    '(63 127 127)
    '(0 76 76)
    '(38 76 76)
    '(0 191 255)
    '(127 223 255)
    '(0 153 204)
    '(102 178 204)
    '(0 114 153)
    '(76 133 153)
    '(0 95 127)
    '(63 111 127)
    '(0 57 76)
    '(38 66 76)
    '(0 127 255)
    '(127 191 255)
    '(0 102 204)
    '(102 153 204)
    '(0 76 153)
    '(76 114 153)
    '(0 63 127)
    '(63 95 127)
    '(0 38 76)
    '(38 57 76)
    '(0 63 255)
    '(127 159 255)
    '(0 51 204)
    '(102 127 204)
    '(0 38 153)
    '(76 95 153)
    '(0 31 127)
    '(63 79 127)
    '(0 19 76)
    '(38 47 76)
    '(0 0 255)
    '(127 127 255)
    '(0 0 204)
    '(102 102 204)
    '(0 0 153)
    '(76 76 153)
    '(0 0 127)
    '(63 63 127)
    '(0 0 76)
    '(38 38 76)
    '(63 0 255)
    '(159 127 255)
    '(51 0 204)
    '(127 102 204)
    '(38 0 153)
    '(95 76 153)
    '(31 0 127)
    '(79 63 127)
    '(19 0 76)
    '(47 38 76)
    '(127 0 255)
    '(191 127 255)
    '(102 0 204)
    '(153 102 204)
    '(76 0 153)
    '(114 76 153)
    '(63 0 127)
    '(95 63 127)
    '(38 0 76)
    '(57 38 76)
    '(191 0 255)
    '(223 127 255)
    '(153 0 204)
    '(178 102 204)
    '(114 0 153)
    '(133 76 153)
    '(95 0 127)
    '(111 63 127)
    '(57 0 76)
    '(66 38 76)
    '(255 0 255)
    '(255 127 255)
    '(204 0 204)
    '(204 102 204)
    '(153 0 153)
    '(153 76 153)
    '(127 0 127)
    '(127 63 127)
    '(76 0 76)
    '(76 38 76)
    '(255 0 191)
    '(255 127 223)
    '(204 0 153)
    '(204 102 178)
    '(153 0 114)
    '(153 76 133)
    '(127 0 95)
    '(127 63 111)
    '(76 0 57)
    '(76 38 66)
    '(255 0 127)
    '(255 127 191)
    '(204 0 102)
    '(204 102 153)
    '(153 0 76)
    '(153 76 114)
    '(127 0 63)
    '(127 63 95)
    '(76 0 38)
    '(76 38 57)
    '(255 0 63)
    '(255 127 159)
    '(204 0 51)
    '(204 102 127)
    '(153 0 38)
    '(153 76 95)
    '(127 0 31)
    '(127 63 79)
    '(76 0 19)
    '(76 38 47)
    '(51 51 51)
    '(91 91 91)
    '(132 132 132)
    '(173 173 173)
    '(214 214 214)
    '(255 255 255)
    )
    )
    )

    TIA

    Bill
     
    BillZ, Apr 22, 2004
    #1
  2. BillZ

    Jeff Mishler Guest

    Bill,
    I'm on 2k2 and other than and extra right paren it works just fine for me.
    As far as I know there is no limit to the length of a list, other than the
    physical memory you have available.

    FYI:
    _$ (length rgb_lst)
    256
    _$ (length (atoms-family 0))
    3347


    Jeff

    at the end of the program I get a:
    quotes, the list and used a defun but still get the same error:
     
    Jeff Mishler, Apr 22, 2004
    #2
  3. BillZ

    Paul Turvill Guest

    Try it without the extra ")" at the very end. You can also simplify it quite
    a bit by putting a single ' at the start (instead of the (list ...)
    function, and eliminating all of the remaining ones:

    (setq RGB_Lst)
    '(
    (0 0 0)
    (255 0 0)
    ...
    (214 214 214)
    (255 255 255)
    );; '
    );; setq

    ___
     
    Paul Turvill, Apr 22, 2004
    #3
  4. BillZ

    BillZ Guest

    The extra ")" was a mistake at post time.
    I tried it every way that you said plus a few more and I get the same error although it sets the list fine.

    Thanks anyway

    Bill
     
    BillZ, Apr 22, 2004
    #4
  5. BillZ

    BillZ Guest

    Okay thanks,
    Funny part is it sets the list fine but when I check the list at the command prompt it shows the error again at the end.

    Command: !rgb_lst
    ((0 0 0) (255 0 0) (255 255 0) (0 255 0) (0 255 255) (0 0 255) (255 0 255) (255
    255 255) (128 128 128) (192 192 192) (255 0 0) (255 127 127) (204 0 0) (204 102
    102) (153 0 0) (153 76 76) (127 0 0) (127 63 63) (76 0 0) (76 38 38) (255 63 0)
    (255 159 127) (204 51 0) (204 127 102) (153 38 0) (153 95 76) (127 31 0) (127
    79 63) (76 19 0) (76 47 38) (255 127 0) (255 191 127) (204 102 0) (204 153 102)
    (153 76 0) (153 114 76) (127 63 0) (127 95 63) (76 38 0) (76 57 38) (255 191 0)
    (255 223 127) (204 153 0) (204 178 102) (153 114 0) (153 133 76) (127 95 0)
    (127 111 63) (76 57 0) (76 66 38) (255 255 0) (255 255 127) (204 204 0) (204
    204 102) (153 153 0) (153 153 76) (127 127 0) (127 127 63) (76 76 0) (76 76 38)
    (191 255 0) (223 255 127) (153 204 0) (178 204 102) (114 153 0) (133 153 76)
    (95 127 0) (111 127 63) (57 76 0) (66 76 38) (127 255 0) (191 255 127) (102 204
    0) (153 204 102) (76 153 0) (114 153 76) (63 127 0) (95 127 63) (38 76 0) (57
    76 38) (63 255 0) (159 255 127) (51 204 0) (127 204 102) (38 153 0) (95 153 76)
    (31 127 0) (79 127 63) (19 76 0) (47 76 38) (0 255 0) (127 255 127) (0 204 0)
    (102 204 102) (0 153 0) (76 153 76) (0 127 0) (63 127 63) (0 76 0) (38 76 38)
    (0 255 63) (127 255 159) (0 204 51) (102 204 127) (0 153 38) (76 153 95) (0 127
    31) (63 127 79) (0 76 19) (38 76 47) (0 255 127) (127 255 191) (0 204 102) (102
    204 153) (0 153 76) (76 153 114) (0 127 63) (63 127 95) (0 76 38) (38 76 57) (0
    255 191) (127 255 223) (0 204 153) (102 204 178) (0 153 114) (76 153 133) (0
    127 95) (63 127 111) (0 76 57) (38 76 66) (0 255 255) (127 255 255) (0 204 204)
    (102 204 204) (0 153 153) (76 153 153) (0 127 127) (63 127 127) (0 76 76) (38
    76 76) (0 191 255) (127 223 255) (0 153 204) (102 178 204) (0 114 153) (76 133
    153) (0 95 127) (63 111 127) (0 57 76) (38 66 76) (0 127 255) (127 191 255) (0
    102 204) (102 153 204) (0 76 153) (76 114 153) (0 63 127) (63 95 127) (0 38 76)
    (38 57 76) (0 63 255) (127 159 255) (0 51 204) (102 127 204) (0 38 153) (76 95
    153) (0 31 127) (63 79 127) (0 19 76) (38 47 76) (0 0 255) (127 127 255) (0 0
    204) (102 102 204) (0 0 153) (76 76 153) (0 0 127) (63 63 127) (0 0 76) (38 38
    76) (63 0 255) (159 127 255) (51 0 204) (127 102 204) (38 0 153) (95 76 153)
    (31 0 127) (79 63 127) (19 0 76) (47 38 76) (127 0 255) (191 127 255) (102 0
    204) (153 102 204) (76 0 153) (114 76 153) (63 0 127) (95 63 127) (38 0 76) (57
    38 76) (191 0 255) (223 127 255) (153 0 204) (178 102 204) (114 0 153) (133 76
    153) (95 0 127) (111 63 127) (57 0 76) (66 38 76) (255 0 255) (255 127 255)
    (204 0 204) (204 102 204) (153 0 153) (153 76 153) (127 0 127) (127 63 127) (76
    0 76) (76 38 76) (255 0 191) (255 127 223) (204 0 153) (204 102 178) (153 0
    114) (153 76 133) (127 0 95) (127 63 111) (76 0 57) (76 38 66) (255 0 127) (255
    127 191) (204 0 102) (204 102 153) (153 0 76) (153 76 114) (127 0 63) (127 63
    95) (76 0 38) (76 38 57) (255 0 63) (255 127 159) (204 0 51) (204 102 127) (153
    0 38) (153 76 95) (127 0 31) (127 63 79) (76 0 19) (76 38 47) (51 51 51) (91 91
    91) (132 132 132) (173 173 173) (214 214 214) (255 255 255))
    Application ERROR: Bad argument type

    Weird huh.

    Bill
     
    BillZ, Apr 22, 2004
    #5
  6. BillZ

    Devin Guest

    "BillZ",

    I tried the list and got the same error, take out all the extra (') things
    and it worked fine. Maybe a limit in the use of (') ?

    I wish I had more time to investigate but I have to go,

    Devin
     
    Devin, Apr 22, 2004
    #6
  7. BillZ

    Jeff Mishler Guest

    OK, I remember seeing this before. See the thread, in this newsgroup :),
    started by Marc'Antonio Alessi on Feb 13, 2003 with the heading "Bad
    argument type in simple list: why?"

    Jeff


    command prompt it shows the error again at the end.
     
    Jeff Mishler, Apr 22, 2004
    #7
  8. BillZ

    BillZ Guest

    Thanks Devin,
    But I originally tried it with just the one quote at the beginning.

    '((0 0 0)(255 255 0)

    I tried it again and it still does it.

    Bill
     
    BillZ, Apr 22, 2004
    #8
  9. BillZ

    BillZ Guest

    Okay,

    I added a (princ) at the end so I don't see it anymore.

    I guess if I don't see it, It doesn't bother me. :)

    I'll look at that post..

    Bill
     
    BillZ, Apr 22, 2004
    #9
  10. BillZ

    Doug Broad Guest

    Bill,
    This is apparently part of a larger code. What makes you think
    that this particular expression is causing the error?

    Regards,
    Doug
     
    Doug Broad, Apr 22, 2004
    #10
  11. BillZ

    Doug Broad Guest

    I see what you are seeing. It happens at the command
    prompt but not in vlide. Also it won't happen if the program
    doesn't return that value to the command line as you have
    discovered with princ.
     
    Doug Broad, Apr 23, 2004
    #11
  12. BillZ

    BillZ Guest

    So it isn't just me. (play twilight zone music here)

    I feel like a beta tester with this new release. :)

    Bil


    <Reply From: Doug Broad
    <Date: Apr/23/04 - 07:03 (CDT) NEW!

    < Re: Limit to list length?
    <I see what you are seeing. It happens at the command
    <prompt but not in vlide. Also it won't happen if the program
    <doesn't return that value to the command line as you have
    <discovered with princ.
     
    BillZ, Apr 23, 2004
    #12
  13. BillZ

    Doug Broad Guest

    The same error occurs with 2004. Also tested it with
    2002 and it occurs there as well. I think you're safe
    as long as you don't allow the return value to feedback
    to the command line. I don't expect it to ever be fixed.

    Regards,
    Doug
     
    Doug Broad, Apr 23, 2004
    #13
  14. I dont have any good answer, today also.

    Cheers.

    --
    ________________________________________________

    Marc'Antonio Alessi
    http://xoomer.virgilio.it/alessi
    (strcat "NOT a " (substr (ver) 8 4) " guru.")

    O.S. = XP Pro 2002 Ita - Sp.1
    AutoCAD = 2004 Ita - Sp.1a
    ________________________________________________

    Magic numbers?

    ....
    Command: (list '(218 127 252))
    ((218 127 252))

    Command: (list '(219 127 252))
    ((219 127 252))
    --------------------------------------------
    Command: (list '(220 127 252))
    ((220 127 252))
    Application ERROR: Bad argument type

    Command: (list '(221 127 252))
    ((221 127 252))
    Application ERROR: Bad argument type

    Command: (list '(222 127 252))
    ((222 127 252))
    Application ERROR: Bad argument type

    Command: (list '(223 127 252))
    ((223 127 252))
    Application ERROR: Bad argument type

    Command: (list '(224 127 252))
    ((224 127 252))
    Application ERROR: Bad argument type

    Command: (list '(225 127 252))
    ((225 127 252))
    Application ERROR: Bad argument type

    Command: (list '(226 127 252))
    ((226 127 252))
    Application ERROR: Bad argument type

    Command: (list '(227 127 252))
    ((227 127 252))
    Application ERROR: Bad argument type

    Command: (list '(228 127 252))
    ((228 127 252))
    Application ERROR: Bad argument type

    Command: (list '(229 127 252))
    ((229 127 252))
    Application ERROR: Bad argument type

    Command: (list '(230 127 252))
    ((230 127 252))
    Application ERROR: Bad argument type

    Command: (list '(231 127 252))
    ((231 127 252))
    Application ERROR: Bad argument type

    Command: (list '(232 127 252))
    ((232 127 252))
    Application ERROR: Bad argument type

    Command: (list '(233 127 252))
    ((233 127 252))
    Application ERROR: Bad argument type

    Command: (list '(234 127 252))
    ((234 127 252))
    Application ERROR: Bad argument type

    Command: (list '(235 127 252))
    ((235 127 252))
    Application ERROR: Bad argument type

    Command: (list '(236 127 252))
    ((236 127 252))
    Application ERROR: Bad argument type

    Command: (list '(237 127 252))
    ((237 127 252))
    Application ERROR: Bad argument type

    Command: (list '(238 127 252))
    ((238 127 252))
    Application ERROR: Bad argument type

    Command: (list '(239 127 252))
    ((239 127 252))
    Application ERROR: Bad argument type
    --------------------------------------------
    Command: (list '(240 127 252))
    ((240 127 252))
    Command: (list '(241 127 252))
    ((241 127 252))
    ....
     
    Marc'Antonio Alessi, Apr 23, 2004
    #14
  15. BillZ

    BTO Guest

    Hi,

    i don't think it's a limit problem , cause i get :

    (setq RGB_Lst (list '(10 0 0))) no error

    (setq RGB_Lst (list '(200 0 0))) no error

    (setq RGB_Lst (list '(210 0 0))) no error

    (setq RGB_Lst (list '(219 0 0))) no error

    (setq RGB_Lst (list '(220 0 0))) error

    (setq RGB_Lst (list '(223 255 127))) error



    Bruno Toniutti
     
    BTO, Apr 23, 2004
    #15
  16. BillZ

    BillZ Guest

    << I don't expect it to ever be fixed.Okay,
    thanks!


    Bill
     
    BillZ, Apr 23, 2004
    #16
  17. BillZ

    Devin Guest

    BillZ,

    Hey there, I tested some more of your code and found that there's a problem
    setting the first member of a list within a list to certain numbers, try
    instead...

    '(
    ("RGB" 220 0 0)
    ("RGB" 255 255 255)
    etc...
    )

    and try...

    '((220 0 0))

    it returns an error.

    now try...

    '((220 0))

    it works fine...

    I beleive it has to do with association list programming in autocad. The
    DXF code 220 can only accept one member after the dxf code of 220. I think
    dxf error checking is probably built into the list creator functions in
    autocad, it's checking the list member behind 220 because it's a list of a
    list and it interprets it as an association list. It's just my assumption,
    but it appears to be the best explanation.

    HTH,

    Devin
     
    Devin, Apr 23, 2004
    #17
  18. I believe you may be correct. I seem to recall reading
    somewhere that the work around <cough> was to use reals
    instead of integers for the key.
     
    michael puckett, Apr 23, 2004
    #18
  19. BillZ

    Devin Guest

    michael puckett,
    Yes that would redirect any dxf code checking as the first member wouldn't
    evaluate to a dxf code. I use alot of lists in my own codes and such, I've
    created my own association lists and functions to work with them, I later on
    found that text keys at the beginning was a good solid approach and it
    provided a key descriptor for what was to follow. ie:

    (("RGB" 220 0 0)("RGB" 221 20 30) ...)

    Although, of course, using the same descriptor in the same level of a list
    is not going to lend itself to (assoc <first member> <list>) type functions
    and would have to be accessed via (nth # list).

    Using reals for the first item would save on space in memory though, but
    each value may have to be converted back to integer which may slow down the
    code a little (probably nanoseconds per pass, huh :)

    Thanks Michael.
     
    Devin, Apr 23, 2004
    #19
  20. Just an FyI, nothing says you can't use symbols instead
    of strings (which eliminates any case problems, uses
    less memory but still provides a descriptor) ...

    (setq mylist
    '(
    (keyreallylongtomakeapoint1 . 42)
    (keyreallylongtomakeapoint2 . 27)
    )
    )

    (cdr (assoc 'KeYrEaLlYlOnGtOmAkEaPoInT1 mylist))

    Of course, I'd probably avoid any reserved symbols.

    ChEeRs :)
     
    michael puckett, Apr 23, 2004
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.