Author Topic: lisp debugging  (Read 8124 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
lisp debugging
« on: February 12, 2004, 01:25:03 PM »
hey guys i have a multiple offset lisp that is causing some trouble and i was wondering if someone could tell me what the conflict is. here's the error message i get sometimes when trying to isolate a layer after using it

Command: layiso
bad function: "\nOffset distance <1/2>: "

here's the multiple offset code

Code: [Select]

;Command Name: moff
;Description: Doing the multiple offset using the different offset distance
(defun
   C:MOFF ()
  (setvar "cmdecho" 0)
  (setvar "luprec" 2)
  (initget 7)
  (setq DIST (getdist "\nOffset distance: "))
  (setq OBJ (entsel "\nSelect an object: "))
  (redraw (car OBJ) 3)
  (setq SIDE (getpoint "\nSide to offset?"))
  (command "offset" DIST OBJ SIDE "")
  (redraw)
  (initget "Cancel")
  (setq
    ANS
     (getkword "\nPress 'enter' to continue or hit 'C' to finish: ")
  ) ;_ end of setq
  (while (= ANS NIL)
    (setq OBJL (entlast))
    (redraw OBJL 3)
    (setq ODIST (getvar "offsetdist"))
    (setq prompt (strcat "\nOffset distance <" (rtos ODIST) ">: "))
    (initget 6)
    (setq DIST (getdist prompt))
    (if (= DIST NIL)
      (setq DIST ODIST)
    ) ;_ end of if
    (setq SIDE (getpoint "\nSide to offset?"))
    (command "offset" DIST OBJL SIDE "")
    (redraw)
    (initget "Cancel")
    (setq
      ANS
       (getkword
         "\nPress 'enter' to continue or hit 'C' to finish: "
       ) ;_ end of getkword
    ) ;_ end of setq
  ) ;_ end of while
  (princ "*Cancel*")
  (setvar "cmdecho" 1)
  (princ)
) ;_ end of defun
(princ)

daron

  • Guest
lisp debugging
« Reply #1 on: February 12, 2004, 01:33:39 PM »
layiso? Isn't that the function name for layer isolate in express tools. Seems like a conflict in functions to me. That program looks oddly familiar. Where'd you pick it up at?

ELOQUINTET

  • Guest
lisp debugging
« Reply #2 on: February 12, 2004, 01:49:37 PM »
yeah it's the layer iso from express tools. it also seem to remember it conflicting with my referrence line lisp. yes it looks familiar for good reason i requested it recently from here. any thoughts of why i get the message?

daron

  • Guest
lisp debugging
« Reply #3 on: February 12, 2004, 02:33:16 PM »
Have you tried testing each line in the vlide? To do so, double-click on the outside of a parenthesis, so the entire line is highlighted, then hit the little microscope button on the toolbars. When you get to the error, double-click the function name i.e. getdist and pick the help button. Read up on it and see if you can work it out.

ELOQUINTET

  • Guest
lisp debugging
« Reply #4 on: February 12, 2004, 03:00:09 PM »
ok i'll give it a shot later and let ya know

ELOQUINTET

  • Guest
lisp debugging
« Reply #5 on: February 12, 2004, 03:47:53 PM »
daron i doubleclicked a line but don't see the magnifying glass. could it be something else in mine. what is it called watch, trace? i tried several things and a dialog box pops up which looks like what you mean but how do i see if somethings wrong???

daron

  • Guest
lisp debugging
« Reply #6 on: February 12, 2004, 04:05:21 PM »
Have you ever read this? The first image is the vlide toolbar set up as it is on mine. On the bottom row under the word car and one tool to the right is a picture of a microscope, not magnifiing glass. When you've highlighted the line of code, from paren to paren, hit that button. Follow any instructions from your command line and eventually you should get a popup. That popup can tell you volumes. BTW, nil in the popup is not a bad thing. It's just what the functions return was. Lastly, the button is called inspect. I believe my tutorial does explain that.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
lisp debugging
« Reply #7 on: February 12, 2004, 05:15:10 PM »
Daron,
Are you trying to get dan to use the debugging tools in VLIDE?
Or just looking for the answer to the riddle?
 answer = eman elbairav dab a si tpmorp

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Serge J. Gianolla

  • Guest
lisp debugging
« Reply #8 on: February 13, 2004, 12:07:57 AM »
Cute Cab, euh CAB. Clever! I personally wait for a bottle of Cab-Sauv, and we'll drink to that when it happens. :lol:

OK eloquintet, while still sober, let us remark that less mishaps occur when using a system. My favourite is Hungarian notation where a variable name is preceded by a coded character:
    Some of the prefixes:
    s for Strings
    a for Angles
    i for Integers
    r for Reals
    l for Lists...[/list:u] e.g. (setq sAns instead of Ans
    Makes life easier when debugging or coming back to edit some code 2 months later.

daron

  • Guest
lisp debugging
« Reply #9 on: February 13, 2004, 09:13:01 AM »
Who wrote that code for you then, Dan? I find it hard to believe we let something get off the shelf that doesn't at least collect variable states, so they can be reset when the code finishes execution.

ELOQUINTET

  • Guest
lisp debugging
« Reply #10 on: February 13, 2004, 09:59:41 AM »
i don't recall daron. i am thinking about just deleting it from my menu because i don't care for the way the command operates anyway. don't really have time right now to get into it actually busy busy busy

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
lisp debugging
« Reply #11 on: February 13, 2004, 10:42:14 AM »
Dan, the fix is easy once you find it.

When the routine crashes and you are dumped into VLIDE
(or in this case the alert box tells you what the problem is.
In my system that is) If the alert box asks you to
Enter a Break Loop, answer yes.
In VLIDE, you see the parentheses with the red dot in it
click that and it will take you to the line with the problem.

The problem is an improper variable name which is conflicting
with a function name. Function names are in blue text and variable
names are in black text. Setq is setting a VARIABLE to some value.
Are you with me to this point?

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
lisp debugging
« Reply #12 on: February 13, 2004, 11:54:33 AM »
ah i see where i got it from it was cadalyst/get the code so daron is correct. cab when i run the command none of that happens it works fine. when i do other lisps i have i just get the message i posted at the command line. i tried to open the file and test but i'm no expert. i understand the colors but as far as fixing it not clear. my apologies???

daron

  • Guest
lisp debugging
« Reply #13 on: February 13, 2004, 12:10:53 PM »
Dan, here's a freebie. Change the name of the variable here:
Code: [Select]
(setq prompt (strcat "\nOffset distance <" (rtos ODIST) ">: "))
    (initget 6)
    (setq DIST (getdist prompt))

from prompt to something like aprompt or offdist. Make sure you change it in both places. Here's why you don't use prompt as a variable.
Quote
prompt Function
 



Displays a string on your screen's prompt area

(prompt msg)

On dual-screen AutoCAD configurations, prompt displays msg on both screens and is, therefore, preferable to princ.

Arguments

msg

A string.

Return Values

nil

Examples

Command: (prompt "New value: ")

New value: nil
_____________________________________________________________
See Also

The Displaying Messages topic in the AutoLISP Developer's Guide.


ELOQUINTET

  • Guest
lisp debugging
« Reply #14 on: February 13, 2004, 12:57:33 PM »
thanks daron for the freebie, what would i do without you? i've incorporated it as offdist and haven't encountered the message yet so i suppose that is it. i'll keep you posted. i appreciate you filling in the blanks for me buddy  :D