bad argument value: does not fit in word

Discussion in 'AutoCAD' started by wkiernan, Feb 12, 2004.

  1. wkiernan

    wkiernan Guest

    Here's an odd error message I got in 2000i. I have the LISP program that reads a big file (3 MB, 14000 lines), breaks each line up by the commas into a list of strings, then conses that list to a list of lists. Well, it takes a minute or so to read and decompose that big file, and users think something's gone wrong. So I was curious to see what would happen if I embedded that data file in the LISP program itself, whether it would load any faster. I made the data file into a second file, GETIMAGE2.LSP, that looks like this:

    (setq iflist
    (list
    (list "H:\COLOR AERIALS\01A-E\1E_286340_1400391.TIF" "3154124" "1024" "1024" "286340.0000000000" "1399368.000000000" "287364.0000000000" "1400392.000000000" "1.00000000000000" "0.00000000000000" "0.00000000000000" "-1.00000000000000" "286340.500000" "1400391.500000" )
    (list "H:\COLOR AERIALS\01A-E\1E_286340_1401415.TIF" "3154124" "1024" "1024" "286340.0000000000" "1400392.000000000" "287364.0000000000" "1401416.000000000" "1.00000000000000" "0.00000000000000" "0.00000000000000" "-1.00000000000000" "286340.500000" "1401415.500000" )
    ... [ 14000 lines like those above ]
    )
    )

    When I do (load "getimage2.lsp") it sits there for a minute ot two and then fails with the error message

    bad argument value: does not fit in word: 65536

    Not that I plan on writing a lot more 14000-line, 3MB setq statements, but just out of curiosity, what's happening?
     
    wkiernan, Feb 12, 2004
    #1
  2. wkiernan

    Tom Smith Guest

    You're doing something with memory that the language was never intended to
    handle. Apparently 64K is all that's allowed in a temporary variable, and
    the program upchucks when you go past it. A word is 16 bits (2 bytes). 2 to
    the 16th power is 65536. I'd guess 2 bytes is all the space you get for a
    variable.
     
    Tom Smith, Feb 12, 2004
    #2
  3. wkiernan

    ECCAD Guest

    Looks like you are running out of string space.
    Try adjusting memory - see ALLOC and EXPAND functions
    in Lisp.
    BTW, I wouldn't even (try) to fold the 'data' into a .lsp load.
    I would just read the file in smaller 'chunks', keep track of the
    number of lines read-in, close, open, read until linecounter = lastlinecount, then continue to end of file.
    Sort the data, look for what you want, if not found, get some more..

    Bob
     
    ECCAD, Feb 12, 2004
    #3
  4. wkiernan

    Jeff Mishler Guest

    Why not add a "spinner" or put a "." on the command line every 250, or
    so, lines read from the file?

    I wouldn't try to do what you are.......

    Jeff

    that reads a big file (3 MB, 14000 lines), breaks each line up by the
    commas into a list of strings, then conses that list to a list of lists.
    Well, it takes a minute or so to read and decompose that big file, and
    users think something's gone wrong. So I was curious to see what would
    happen if I embedded that data file in the LISP program itself, whether
    it would load any faster. I made the data file into a second file,
    GETIMAGE2.LSP, that looks like this:
    "1024" "1024" "286340.0000000000" "1399368.000000000"
    "287364.0000000000" "1400392.000000000" "1.00000000000000"
    "0.00000000000000" "0.00000000000000" "-1.00000000000000"
    "286340.500000" "1400391.500000" )
    "1024" "1024" "286340.0000000000" "1400392.000000000"
    "287364.0000000000" "1401416.000000000" "1.00000000000000"
    "0.00000000000000" "0.00000000000000" "-1.00000000000000"
    "286340.500000" "1401415.500000" )
    then fails with the error message
    but just out of curiosity, what's happening?
     
    Jeff Mishler, Feb 12, 2004
    #4
  5. wkiernan

    Tom Smith Guest

    Not that I plan on writing a lot more 14000-line, 3MB setq statements, but
    just out of curiosity, what's happening?

    Out of curiosity, what in the world are you doing with this? I'd have to
    wonder if it's not something that could be done better with a different
    application and/or programming language. Or maybe the data ought to be
    stored in some other manner that doesn't require dragging it into Acad this
    way.

    You might be able to hack this into working through expand and alloc, but
    IMHO it sounds like it's way into the category of "find a different way to
    do it."
     
    Tom Smith, Feb 12, 2004
    #5
  6. wkiernan

    Tom Smith Guest

    Why not add a "spinner"

    I gave up on spinners about R14 myself. The computers reached a speed where
    I can't make the thing print slowly or seldom enough to even be visible --
    and/or Acad handles printing to the command line in a different way, and
    just ignores everything that would result in nothing. In any case, I've
    written a function to print 250,000 revolutions of a spinner, and all I see
    is a pause, then the last character printed, nothing else. It used to be
    fairly easy to incorporate in a slow routine, but I can't figure it out now.

    For a commercial program, I might bother to figure it out, but for an
    in-house routine I just print "please wait..." and train them to be patient.
    Once the users understand it ain't broken, they're okay.
     
    Tom Smith, Feb 12, 2004
    #6
  7. wkiernan

    Jeff Mishler Guest

    Tom,
    Here is a little test I made and the spinner "appears" correctly on my
    machine. P42.4ghz, 1gb ram, geForce4 64mb. The spin routine I found in
    this newsgroup quite awhile ago.

    (defun spin ( / )
    (cond
    ((= SPN " |")(setq SPN " /"))
    ((= SPN " /")(setq SPN " -"))
    ((= SPN " -")(setq SPN " \\"))
    (T (setq SPN " |"))
    )
    (if SPN (princ (strcat "\r" SPN)))
    )

    (defun wait_test (/ count)
    (setq count 0)
    (prompt "\nPlease wait...\n")
    (while (< count 1000000)
    (if (= 0 (rem count 10000))
    (spin)
    )
    (setq count (1+ count))
    )
    )

    HTH,
    Jeff
     
    Jeff Mishler, Feb 12, 2004
    #7
  8. wkiernan

    Tom Smith Guest

    Thanks, Jeff, I'll give it a shot. At a glance it looks just like what I
    used to do.

    There's not many things I do that cause a disturbing delay, and in most of
    those cases I can leave a little on-screen "entertainment" so they know
    something's happening - like highlighting/dehighlighting entities as they're
    being processed, or whatever.
     
    Tom Smith, Feb 12, 2004
    #8
  9. I wonder obout the use of alloc in Lisp.
    In C or C++ it is clear. You must allocate and deallocate memory for
    arrays strings etc.
    But in Lisp this allocation and deallocation (gabarge collection) is
    done by Lisp (= nothing to worry about ?). Is there any good reason to
    alloc yourself, for example
    storing some 30000 vla-objects or other data in lists ?

    Regards
    Dieter
     
    Dieter Berger, Feb 13, 2004
    #9
  10. wkiernan

    Tom Smith Guest

    I wonder obout the use of alloc in Lisp.

    That's my opinion too. It's supposed to be taken care of . Some of the old
    functions like vmon are obsolete, and I was surprised that alloc and expand
    still exist. I've never used them, and haven't thought about them until this
    post.

    I'm still curious what the poster is doing with this. It's not apparent from
    his fragment what kind of data it is, or the purpose. I wonder if whatever
    he's doing couldn't be handled in an entirely different way.
     
    Tom Smith, Feb 13, 2004
    #10
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.