multiple dcl file loading

Discussion in 'AutoCAD' started by dflynn0001, May 12, 2004.

  1. dflynn0001

    dflynn0001 Guest

    I have three lisp files that load at startup that refer to "dcl" files. Only the last one loaded works correctly. When I start one of the previously loaded files the "dcl" file starts, and appears to work correctly, but when I hit "OK" or "Cancel" it gives me the following error -" ; error: bad argument type: stringp nil" - if I reload the lisp file that I want to use, it works correctly but the other file now doesn't work. Is there something I need to add to my lisp files or my dcl files or is there a toggle to set inside AutoCAD or something else that I need to do to make this work.
     
    dflynn0001, May 12, 2004
    #1
  2. dflynn0001

    Devin Guest

    Sounds like you may have some crossed function names or something else
    conflicting, perhaps you should run vlide and put an error trap on the find
    out where the error is coming from, if you need help doing that, let us
    know.

    Devin
     
    Devin, May 12, 2004
    #2
  3. dflynn0001

    BillZ Guest

    Yes, I would test run each function individually to see which is giving the trouble. There may be a problem with a null value at the start of the dialog or maybe the sequence is wrong.

    Bill
     
    BillZ, May 13, 2004
    #3
  4. Are you using unique ID's for the dcl_id?
    (setq ot_dcl (load_dialog "otext")
    (setq ls_dcl (load_dialog "lstext")
    (setq ks_dcl (load_dialog "kstext")

    (if (not (new_dialog "USERR3" ot_dcl)) (oexit))
    (start_dialog)

    Only the last one loaded works correctly. When I start one of the
    previously loaded files the "dcl" file starts, and appears to work
    correctly, but when I hit "OK" or "Cancel" it gives me the following
    error -" ; error: bad argument type: stringp nil" - if I reload the lisp
    file that I want to use, it works correctly but the other file now doesn't
    work. Is there something I need to add to my lisp files or my dcl files or
    is there a toggle to set inside AutoCAD or something else that I need to do
    to make this work.
     
    Allen Johnson, May 13, 2004
    #4
  5. dflynn0001

    Devin Guest

    In dded.lsp, the following seems unprotected...

    (if (= (tblsearch "layer" tname) nil)
    (command "-layer" "m" tname "") ;if layer name doesn't exist make layer
    to draw text
    (command "-layer" "t" tname "s" tname "")
    ;if it does exist thaw it and make it current
    )
    (if (= (tblsearch "layer" gname) nil)
    (command "-layer" "m" gname "") ;if layer name doesn't exist make layer
    to draw grid current
    (command "-layer" "t" gname "s" gname "")
    ;if it does exist thaw it and make it current
    )

    Since tname and gname are only set if accept is pressed.
     
    Devin, May 13, 2004
    #5
  6. dflynn0001

    Devin Guest

    Yea, I checked thru and first off, if a user presses cancel then it still
    runs as if the get_info function was ran even though it wasn't. The
    variables from get_info are used and assumed to have values even though
    they've not been set thus causing errors like string nil or real nil.
    You'll need to account for this and then if you're still having trouble send
    it back in.

    HTH,

    Devin
     
    Devin, May 13, 2004
    #6
  7. dflynn0001

    Devin Guest

    Don,

    See my response further down in the thread.
     
    Devin, May 13, 2004
    #7
  8. dflynn0001

    dflynn0001 Guest

    I added the line -
    (action_tile "cancel" "(exit)") - but it still gave me the same error if I selected "CANCEL".
     
    dflynn0001, May 13, 2004
    #8
  9. dflynn0001

    Devin Guest

    The problem isn't that you don't have a cancel button it's rather that code
    is running that's not supposed to if the user presses cancel. You've got to
    remember that you're dealing with top-down programing (meaning that the line
    of code below the current line is executed after the current unless you
    cause a program exit to occur).

    The problem I see is that if the user opens the dialog and does nothing but
    cancel it then it ends the dialog and runs the code directly below the
    line...

    (setq what_next (start_dialog));this line reperesents the chronological
    start AND end of the dialog. this is where the dialog is started and also
    where it ends in the running sequence.

    The problem code is what runs a little later after the end of the dialog...

    (if (and
    tname
    (= (tblsearch "layer" tname) nil)
    )
    (command "-layer" "m" tname "") ;if layer name doesn't exist make layer
    to draw text
    (command "-layer" "t" tname "s" tname "")
    ;if it does exist thaw it and make it current
    )
    (if (and
    gname
    (= (tblsearch "layer" gname) nil)
    )
    (command "-layer" "m" gname "") ;if layer name doesn't exist make layer
    to draw grid current
    (command "-layer" "t" gname "s" gname "")
    ;if it does exist thaw it and make it current
    )

    The above snippet from the problem code shows that you are trying to use
    variables that aren't initialized as if they were. If the user opens the
    dialog and does nothing and then cancels or exits without pressing accept
    then tname and gname are nil. There's your string error (because you
    supplied the layer command with a null string). If you use this kind of
    investigating throughout the rest of your code you should be able to fix it
    all.

    HTH,

    Devin
     
    Devin, May 14, 2004
    #9
  10. dflynn0001

    CAB2k Guest

    You can try something like this:

    Code:
    (defun c:ae (/ pt le ent)
    (if (setq pt (getpoint "\nPick Point in Void To Find Area... "))
    (progn
    (setq le (entlast))
    (command "-boundary" pt "")
    (if (/= le (setq ent (entlast))) ; boundary was created
    (progn
    (command "_area" "o" ent)
    (prompt (strcat "\nArea found is " (rtos (getvar "area") 2 2)))
    (entdel ent) ; remove the boundary
    )
    ) ; endif
    )
    (alert "\nFailed to create a Boundry.")
    )
    (princ)
    )
     
    CAB2k, May 23, 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.