pateksan Posted March 14, 2018 Share Posted March 14, 2018 Hello My first post here, so I will start with a brief introduction. I'm an engineering surveyor working in BricsCAD 18 (it's not listed as an option in this forum's registration form), most of my work is editing/tidying drawings exported from other software. I also do a fair bit of data manipulation in spreadsheets, and LISP is the next thing I want to get into. Unfortunately I have very limited time for troubleshooting. I wrote my first script today and guess what - too few / too many arguments. Can anyone cast their eye please? (defun c:leveltext1103 (datum levpoint ydatum ypoint levdistance) (setq datum (getpoint "\nDatum line:")) (setq point (getpoint "\nSurvey point:")) (setq ydatum (cadr (datum))) (setq ypoint (cadr (levpoint))) (setq levdistance (rtos (* 2 (- point datum) 2 2)) );setq (command "text" levpoint "0.15" "0" levdistance "") );defun The code is intended to produce a piece of text based on a scaled measurement of the y distance between two points on paperspace. Naturally this is just a dimension but I will later need to apply offsets etc to the calculation. I tried a few changes already and still get the error. I hope this is enough information for someone to resolve. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 14, 2018 Share Posted March 14, 2018 (defun c:leveltext1103 ( [b][color="red"]/[/color][/b] datum levpoint ydatum ypoint levdistance) Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted March 14, 2018 Share Posted March 14, 2018 Actually there are more than 5 issues with the code. (defun c:leveltext1103 ( / datum levpoint ydatum ypoint levdistance) (setq datum (getpoint "\nDatum line:")) (setq levpoint (getpoint "\nSurvey point:")) (setq ydatum (cadr datum)) (setq ypoint (cadr levpoint)) (setq levdistance (rtos (* 2 (- ypoint ydatum)) 2 2) ) ;setq (command "_.text" "_non" levpoint "0.15" "0" levdistance) (princ) ) ;defun Quote Link to comment Share on other sites More sharing options...
pateksan Posted March 14, 2018 Author Share Posted March 14, 2018 Thank you both for your rapid responses, that's great. (defun c:leveltext1103 ( [b][color="red"]/[/color][/b] datum levpoint ydatum ypoint levdistance) I was going by this: It's a good idea to leave all variables as global whilst you are writing yourprogram so that you can check their values during debugging. taken from the bottom of http://www.afralisp.net/autolisp/tutorials/the-define-function.php Is the advice on afralisp a bit oversimplified or am I missing something? Actually there are more than 5 issues with the code. (defun c:leveltext1103 ( / datum levpoint ydatum ypoint levdistance) (setq datum (getpoint "\nDatum line:")) (setq [color="red"]lev[/color]point (getpoint "\nSurvey point:")) (setq ydatum (cadr datum)) (setq ypoint (cadr levpoint)) (setq levdistance (rtos (* 2 (- [color="red"]y[/color]point [color="red"]y[/color]datum)) 2 2) ) ;setq (command "[color="red"]_.text[/color]" "[color="red"]_non[/color]" levpoint "0.15" "0" levdistance) ([color="red"]princ[/color]) ) ;defun I've put red colour on any of your edits which I noticed. Coding is not forgiving, is it... Your code works! Did you make any more edits which I am missing? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 14, 2018 Share Posted March 14, 2018 Re testing globally ;(defun c:leveltext1103 ( / datum levpoint ydatum ypoint levdistance) (defun c:leveltext1103 ( ) Sometimes though doing with global you will need to type say (setq datum nil) on command line to clear a variable. Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 14, 2018 Share Posted March 14, 2018 Thank you both for your rapid responses, that's great. I was going by this: It's a good idea to leave all variables as global whilst you are writing yourprogram so that you can check their values during debugging. taken from the bottom of http://www.afralisp.net/autolisp/tutorials/the-define-function.php Is the advice on afralisp a bit oversimplified or am I missing something? Global variables.. well I hope you understand: (defun c:something ( ) This means you didn't used global variables either, Main issue with your code is that you excluded '/' so your function became this structure: (defun example ( ex1 ex2 ex3 ) where to call it you must provide arguments to it, like: (example "string" 1 (list "this" "is" "a list")) so if it was: (defun example ( / ex1 ex2 ex3 ) the call would be just: (example) because now 'ex ex2 and ex3' are variables that the example functions uses inside. Yeah afralisp's examples are oversimplified and thats great for someone new to learn easily LISP. I'd suggest checking Lee Mac's tutorials, Localising Variables is related to your problem. Tho each tutorial requires very careful reading and re-reading it n-times, but you won't regret it. Quote Link to comment Share on other sites More sharing options...
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.