Troller Posted 9 hours ago Posted 9 hours ago I'm having trouble debugging AutoLISP code in ZWCad. In AutoCAD, I can use the VLIDE editor or set the LISPDEBUG variable to trace errors and see where they occur, but ZWCad doesn't seem to support LISPDEBUG (it says the variable doesn't exist). When I type "VLIDE" in the ZWCad command line, it just opens VS Code for editing the .lsp file, which doesn't help with runtime debugging. Are there any built-in tools or methods in ZWCad for debugging Lisp scripts? For example, how can I get line numbers for errors, trace function calls, or step through code? I've tried loading the file and running it, but the error messages in the command line don't specify the exact location. Any recommendations for external tools or workarounds would be appreciated. Thanks! Quote
SLW210 Posted 7 hours ago Posted 7 hours ago I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. You may need the ZWCAD plug-in for VS Code. https://marketplace.visualstudio.com/items?itemName=Zwsoft.ZwLisp What version of ZWCAD do you use? Quote
Steven P Posted 4 hours ago Posted 4 hours ago Not sure for ZWCad, but if you put checks into the code this can narrow down to where there error is. For example (princ "\nOK to here 1")... and 2, 3, 4 etc will show where the code runs to before an error (often errors are grammatically correct and just not doing what you want). Might help you out till you get another answer 1 Quote
BIGAL Posted 1 hour ago Posted 1 hour ago Like Steven P often use an Alert so it stops and can see where it got to. I tend to test code as I make it so I don't write all the code then test, If using defuns in main code test them by using Setq to set the value of the variables used in the defun and I use copy code and paste to command line to run a few lines at a time. The obvious problem I use Notepad++, is check for open and close bracket matching as I create code. I think it was ZWCAD that wrote VBA code when using macro record am I correct ? Quote
mhupp Posted 1 hour ago Posted 1 hour ago (edited) My 0.02¢ sprinkle some code in updates a variable through out the code. and recall it with error trapping This will show Error# 4 : bad argument type <(40)> ; expected <NUMBER> at [DXF/XED data] this error message would tell you to look after (setq x "4") for the error. (defun c:CIR (/ cen rad) (defun *error* (msg) (if (not (member msg '( "Function cancelled" "quit / exit abort"))) (princ (strcat "\nError# " x " : " msg)) ) (princ) ) (setq x "1") (setq cen (getpoint "\nSpecify center point: ")) (setq x "2") (if cen (progn (setq x "3") (setq rad (getdist cen "\nSpecify radius: ")) (setq x "4") (if rad (entmake (list '(0 . "CIRCLE") '(100 . "AcDbEntity") '(100 . "AcDbCircle") (cons 10 cen) (cons 40 ra))) ) (setq x "5") ) ) (setq x "6") (princ) ) -edit guess this is more steps then what Steven P posted. Edited 37 minutes ago by mhupp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.