Elektrik Posted September 3, 2023 Posted September 3, 2023 Hi, I am trying to learn lisp coding for the first time, and I am trying to write a lisp code to find the area of a room selected. Let's say room area is 1000, then what I want is the code to show Room Area= 1000 at the end. Thanks in advance. (defun c:oa () (setq startPointL (getpoint "\nEnter the starting point of the room length: ")) (setq endPointL (getpoint "\nEnter the end point of the room length: ")) (setq rlenght (distance startPointL endPointL)) (setq startPointW (getpoint "\nnter the starting point of the room width: ")) (setq endPointW (getpoint "\nEnter the end point of the room width: ")) (setq rwidth (distance startPointW endPointW)) (setq area (* rlength rwidth)) (alert (strcat "\nRoom Area= " (rtos area))) princ() ) Quote
Lee Mac Posted September 3, 2023 Posted September 3, 2023 Typo rlenght on line 4 princ() should be (princ) 1 Quote
BIGAL Posted September 3, 2023 Posted September 3, 2023 (edited) Look into using Bpoly. It will make a pline inside your room shape, then you can get the property "area" of the pline created. Some help bpoly I will let you work that out as your learning (setq obj (vlax-ename->vla-object (entlast))) (setq area (vla-get-area obj)) Edited September 3, 2023 by BIGAL 1 Quote
j2lstaples Posted September 6, 2023 Posted September 6, 2023 On 9/3/2023 at 6:52 AM, Elektrik said: Hi, I am trying to learn lisp coding for the first time, and I am trying to write a lisp code to find the area of a room selected. Let's say room area is 1000, then what I want is the code to show Room Area= 1000 at the end. Thanks in advance. (defun c:oa () (setq startPointL (getpoint "\nEnter the starting point of the room length: ")) (setq endPointL (getpoint "\nEnter the end point of the room length: ")) (setq rlenght (distance startPointL endPointL)) (setq startPointW (getpoint "\nnter the starting point of the room width: ")) (setq endPointW (getpoint "\nEnter the end point of the room width: ")) (setq rwidth (distance startPointW endPointW)) (setq area (* rlength rwidth)) (alert (strcat "\nRoom Area= " (rtos area))) princ() ) misspelled rlength on the first setq. 1 Quote
ronjonp Posted September 7, 2023 Posted September 7, 2023 @Elektrik Also don't forget to localize all those variables. (defun c:oa (/ area endpointl endpointw rlenght rlength rwidth startpointl startpointw);<- LOCALIZED VARIABLES ( SETQ .. (setq startpointl (getpoint "\nEnter the starting point of the room length: ")) (setq endpointl (getpoint "\nEnter the end point of the room length: ")) (setq rlength (distance startpointl endpointl)) (setq startpointw (getpoint "\nnter the starting point of the room width: ")) (setq endpointw (getpoint "\nEnter the end point of the room width: ")) (setq rwidth (distance startpointw endpointw)) (setq area (* rlength rwidth)) (alert (strcat "\nRoom Area= " (rtos area))) (princ) ) 1 Quote
j2lstaples Posted September 7, 2023 Posted September 7, 2023 1 hour ago, ronjonp said: @Elektrik Also don't forget to localize all those variables. (defun c:oa (/ area endpointl endpointw rlenght rlength rwidth startpointl startpointw);<- LOCALIZED VARIABLES ( SETQ .. (setq startpointl (getpoint "\nEnter the starting point of the room length: ")) (setq endpointl (getpoint "\nEnter the end point of the room length: ")) (setq rlength (distance startpointl endpointl)) (setq startpointw (getpoint "\nnter the starting point of the room width: ")) (setq endpointw (getpoint "\nEnter the end point of the room width: ")) (setq rwidth (distance startpointw endpointw)) (setq area (* rlength rwidth)) (alert (strcat "\nRoom Area= " (rtos area))) (princ) ) I don't really localize my variables anymore and I don't know why. Do the variables leak into a parent function if it's called? I haven't seen this happen. Common variables like ent, obj, entlist, etc. can be used repetitively across multiple functions and I can't even be bothered to localize the variables. I don't nest functions inside of functions. See, whenever I write new function definitions, I don't know how many internal/local variables I would need to use, and I don't expect to know what names they would be. By what you said, you have to localize the variables, I would need to read through my function that could be a few hundred lines long and find out which 'variables' were used. For me personally, this is stupid. As long as I'm not touching global variables, I'm good with not localizing the variables unless I nest my functions, which I don't. I don't really know which style is best. Some of my function definitions literally uses more than 20 local/internal variables, writing them all out in the defun line is so stupid to me. Quote
ronjonp Posted September 7, 2023 Posted September 7, 2023 (edited) 34 minutes ago, j2lstaples said: .... For me personally, this is stupid. As long as I'm not touching global variables, I'm good with not localizing the variables unless I nest my functions, which I don't. I don't really know which style is best. Some of my function definitions literally uses more than 20 local/internal variables, writing them all out in the defun line is so stupid to me. You should probably do a bit more reading before declaring that a standard practice is "stupid". Do you know how to localize variables in the VLIDE? It's quite easy. Edited September 7, 2023 by ronjonp Quote
j2lstaples Posted September 7, 2023 Posted September 7, 2023 14 minutes ago, ronjonp said: You should probably do a bit more reading before declaring that a standard practice is "stupid". Do you know how to localize variables in the VLIDE? It's quite easy. I think my thinking of calling it 'stupid' is a personal thing really. Also, I 'hate' VLIDE so that could be a contributing factor. Quote
j2lstaples Posted September 7, 2023 Posted September 7, 2023 I guess I need to start localizing variables. Shouldn't it understand that any variables inside a function is only valid for that function unless specified. Only the output should matter. Quote
mhupp Posted September 7, 2023 Posted September 7, 2023 (edited) 2 hours ago, j2lstaples said: I guess I need to start localizing variables. Shouldn't it understand that any variables inside a function is only valid for that function unless specified. Only the output should matter. lisp doesn't "understands" anything its only processing data and will do what its programed to do. What makes a good coder is the ability to know what you need to input to get the right output and in the right order. Then from there its to make it as efficient as possible and user friendly. I found making code for others to use is harder then just programming just for yourself. -edit another take with getdist (defun c:oa (/ L W A str) (setq A (* (setq L (getdist "\nSelect Room Length: ")) (setq W (getdist "\nSelect Room width: ")))) (prompt (setq str (strcat "\n" (rtos L 2 3) " x " (rtos W 2 3) " = " (rtos A 2 3)))) (alert str) (princ) ) Edited September 8, 2023 by mhupp Quote
BIGAL Posted September 8, 2023 Posted September 8, 2023 (edited) Using VLIDE, check lisp, it shows all the non localized variables just copy them and paste into your code. Blade in Bricscad shows variables also but have to add them to code one at a time, unless someone knows how. Edited September 8, 2023 by BIGAL Quote
Steven P Posted September 8, 2023 Posted September 8, 2023 12 hours ago, j2lstaples said: I don't really localize my variables anymore and I don't know why. Do the variables leak into a parent function if it's called? I haven't seen this happen. Common variables like ent, obj, entlist, etc. can be used repetitively across multiple functions and I can't even be bothered to localize the variables. I don't nest functions inside of functions. See, whenever I write new function definitions, I don't know how many internal/local variables I would need to use, and I don't expect to know what names they would be. By what you said, you have to localize the variables, I would need to read through my function that could be a few hundred lines long and find out which 'variables' were used. For me personally, this is stupid. As long as I'm not touching global variables, I'm good with not localizing the variables unless I nest my functions, which I don't. I don't really know which style is best. Some of my function definitions literally uses more than 20 local/internal variables, writing them all out in the defun line is so stupid to me. Looks like you need a code to look through your code so you can code the local variables into the function description. You have to accept that local and global variables exist, and then when you do it becomes easier, but there needs to be a way to define which is which. For example I'll use a global variable such as "file Location" - and that saves me having lots of LISPs each calculating the file save path when needed, calculate it one, save the variable globally, call the variable as needed instead of "get file location" routine every time - a little more efficient. Global is for that drawing of course, and not every drawing in this sense. Similarly some things such as setting text sizes - set it once, save as a global variable then each text it uses that. Very useful to use Then if you accept global variables as a handy thing to have, you need to consider local variables. Imagine something like this: (if (setq ent (entsel) ) If variable ent has a value then continue. Normally ent starts the LISP as 'nil' and unless you select something this will do not a lot, However if you have used ent previously then it could see that value and carry on, perhaps altering something you didn't just select. As mhupp I much prefer to make my own up and not share them, you don't need to be as precise with stuff like this and little things that creep in you know what it is and can live with it or fix there and then. This might or might not work, it is one of those functions that I wrote for myself "srchlsp" which -should- return a list of all the LISP routines in a file and list the variables in each, then just copy and paste local variables as you want. It might refer to other LISPs not copied here - so let me know where it goes wrong and what errors it sends. This is unchecked by others so what you find will only improve what I have ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Returns lists of setq variables in a LISP ;; Appears to fail if string contains "/" ;; Do a batch type, rename results text page and open them all as checking ;;Command: SrchLsp ;;Limitations: ;;If defun is all on 1 line, the LISP is ignored (vl-load-com) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:srchlsp ( / MyFile) ; ready for batch (setq MyFile (getfiled "Select LISP File to Query" (getmyfolder) "lsp" 16)) (srchlsp MyFile ) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun lstprts ( MyList StartDel EndDel startpos / result acount acounter NewLst pos) ;; Make list from lines (setq NewLst (list)) (setq acounter 0) (setq acount startpos) (while (< acount (length MyList)) (if (= (nth acount MyList) StartDel) (setq acounter (+ acounter 1)) ) (if (= (nth acount MyList) EndDel) (setq acounter (+ acounter -1)) ) (setq acount (+ acount 1)) (if (= acounter 0) (progn (setq pos acount) (setq acount (length MyList)) ) (progn (setq NewLst (append NewLst (list (nth acount MyList)))) ) ) ) ; end while (setq result (list pos (append (list StartDel) NewLst))) result ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun splitlst ( MyList StartDel EndDel / result acount lst aresult x y z) ;; split into main functions (setq result (list)) (setq acount 0) (while (< acount (length MyList)) ; split up main functions (setq lst (lstprts MyList StartDel EndDel acount)) (setq result (append result (list (nth 1 lst)))) (setq acount (nth 0 lst)) ) ; end while (setq MyList (list)) (foreach x result (setq aresult (splitsublist x StartDel EndDel)) (foreach y aresult (setq z (vl-string-left-trim "0123456789 " y)) (setq MyList (append MyList (list z))) ) ) ; end foreach MyList ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun splitsublist ( MyList StartDel EndDel / StartCounter SplitList SplitListLength defcounterlist maxdefcount totaldefuns defuncount acount) ; split sub functions (setq StartCounter 0) (setq SplitList (list)) (setq SplitListLength 0) (setq defcounterlist (list 0)) (setq maxdefcount 0) (setq totaldefuns (- (length MyList) (length (vl-remove StartDel MyList)))) (if ( = totaldefuns 1) (progn (setq MyList (LM:Unique MyList)) ; unique values only (setq SplitList (list (strcat "0 " (LM:lst->str MyList " ") ))) ) (progn (setq defuncount -1) (setq acount 0) (while (< acount totaldefuns) ; create blank list, SplitList (setq SplitList (append SplitList (list (rtos acount) ))) (setq acount (+ acount 1)) ) (foreach x MyList (if (= x StartDel) (progn (setq maxdefcount (+ maxdefcount 1)) (setq defcounterlist (append defcounterlist (list maxdefcount))) ) ; end progn ) ; go up 1 (setq defuncount (- (last defcounterlist) 1) ) (setq SplitList (subst (strcat (nth defuncount SplitList) " " x) (nth defuncount SplitList) SplitList)) (if (= x EndDel)(setq defcounterlist (reverse (cdr (reverse defcounterlist)))) ) ; go down 1 defuncounter ; (if (= x StartDel)(setq defuncount (+ defuncount 1))) ; go up 1 defuncounter ; (setq SplitList (subst (strcat (nth defuncount SplitList) " " x) (nth defuncount SplitList) SplitList)) ; (if (= x EndDel)(setq defuncount (- defuncount 1))) ; go down 1 defuncounter ) ; end foreach (setq asplitlist (list)) (foreach x SplitList (setq SplitList (subst (LM:lst->str (LM:Unique (LM:str->lst x " ")) " ") x SplitList)) ; unique values ) ) ; end prgn ) ; end if SplitList ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun LM:str->lst ( str del / pos ) (if (setq pos (vl-string-search del str)) (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del)) (list str) ) ) (defun LM:lst->str ( lst del / ) (if (cdr lst) (strcat (car lst) del (LM:lst->str (cdr lst) del)) (car lst) ) ) (defun LM:Unique ( l / ) (if l (cons (car l) (LM:Unique (vl-remove (car l) (cdr l))))) ) (defun LM:StringSubst ( new old str / inc len ) (setq len (strlen new) inc 0 ) (while (setq inc (vl-string-search old str inc)) (setq str (vl-string-subst new old str inc) inc (+ inc len) ) ) str ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun removequotes ( line / splittext acount) (setq splittext (LM:str->lst line (chr 34))) ; ignore " (setq acount 0) (setq line "") (while ( < acount (length splittext)) (setq line (strcat line (nth acount splittext))) (setq acount (+ acount 2)) (if (= acount (length splittext))(setq line (strcat line (last splittext)))) ; a bad fix ) ; end while line ) ; end defun ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun countbracketO ( line / splittext) (setq line (removequotes line)) (setq splittext (LM:str->lst line (chr 40))) (- (length splittext) 1) ) ; end defun (defun countbracketC ( line / splittext) (setq line (removequotes line)) (setq splittext (LM:str->lst line (chr 41))) (- (length splittext) 1) ) ; end defun ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun MakeClipBoardText ( MyText / htmlfile ) (vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'setData "Text" Mytext) (vlax-release-object htmlfile) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun WriteListToFile ( AList / fn Lispfile LFDES x MyString) (setq fn "srchlsp.txt") (if (strcat (getvar "TEMPPREFIX") fn)(vl-file-delete (strcat (getvar "TEMPPREFIX") fn))) (setq Lispfile (strcat (getvar "TEMPPREFIX") fn)) (setq LFDES (open Lispfile "w")) (foreach x AList (setq MyString (vl-string-trim "EndDefun" x)) (write-line MyString LFDES) ) (setq LFDES (close LFDES)) (if (findfile Lispfile) (startapp "notepad" Lispfile)) (if (not (findfile Lispfile)) (princ "\nError writing file")) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;returns the next word(s) in a text string after the search term(s) (defun NextWord ( s p / l result lcount pcount MyString x y) (defun xyz123 ( p l lcount / MyString pcount x ) (setq MyString nil) (setq pcount 0) (while (< pcount (length p)) (if (setq x (vl-string-search (strcase (nth pcount p)) (strcase (nth lcount l)))) ; if in text strng, (progn (setq MyString (strcat (nth pcount p) " " (nth (+ lcount 1) l))) (setq pcount (+ pcount 1)) ) (progn (setq pcount (+ pcount 1)) ) ; end progn ) ; end if ) ; end while MyString ) ; end defun ;; (setq s (strcase s)) (setq l (LM:str->lst s " ") ) ; make line into list (setq result (list)) (setq y 0) (setq pcount 0) (while (< pcount (length p) ) ; check line for search terms ;; (setq x (vl-string-search (strcase (nth pcount p)) s)) (setq x (vl-string-search (strcase (nth pcount p)) (strcase s))) (if (= x nil)()(setq y (+ y 1))) (setq pcount (+ pcount 1)) ) ; end while (if (> y 0) ; do for applicable lines (progn (setq lcount 0) (while (< (+ lcount 1) (length l)) (setq MyString (xyz123 p l lcount)) (if (= MyString nil) () (setq result (append result (LM:str->lst MyString " ") )) ) (setq lcount (+ lcount 1)) ) ; end while ) ; end if ) ; end progn result ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun srchlsp ( file / *error* searchlist EndDelim Nesteddefuns TxtLst f CTO CTC CT Line FoundText MyCount TempList LstTxt x) (defun *error* ( msg / MyError ) (setq MyError 1) (if (and file (eq 'FILE (type file))) (close file)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (defun stringsub ( MyString newterm oldterm / ) (setq strsrch (vl-string-search oldterm MyString)) (while (/= strsrch nil) (setq MyString (vl-string-subst newterm oldterm MyString) ) (setq strsrch (vl-string-search oldterm MyString)) ) MyString ) (setq alerttext "This will produce a temporary text file showing:") (setq alerttext (strcat alerttext "\nFunction names variables used in that function.")) (setq alerttext (strcat alerttext "\n\nResults Explained")) (setq alerttext (strcat alerttext "\n'(' Blank line indicates a 1 line function (unnamed in this listing)")) (setq alerttext (strcat alerttext "\nVariables will only be found if coded \"(strcat xyz....\"")) (setq alerttext (strcat alerttext "\nThe whole lot failes if brackets are out of order or other similar things")) (alert alerttext) (setq searchlist (list (strcat "(defun")(strcat "(setq")(strcat "(foreach") )) (setq enddelim "EndDefun") (setq nesteddefuns (list)) (setq TxtLst (list) ) (setq ctO 0)(setq ctC 0)(setq ct 0) ;; reset bracket counters (setq linelist (list)) (princ "Searching for: ")(princ searchlist)(princ "\n") (if (setq f (open file "r")) (progn (while (setq line (read-line f)) (setq line (stringsub line "" (strcat (chr 92)(chr 92)))) ; remove \\ (setq line (stringsub line "" (strcat (chr 92)(chr 34)))) ; remove \" (setq line (removequotes line)) ;; remove quotes '"' (setq line (nth 0 (LM:str->lst line ";"))) ;; Remove Comments ';' (if (or (= line nil) (= line "") ) ;; ignore commented out lines, blank lines () (progn (setq ctO (countbracketO line)) ;; count opening brackets (setq ctC (countbracketC line)) ;; count closing brackets (setq ct (+ ct (- ctO ctC))) ;; sum brackets (if (= (wcmatch (strcase line) (strcase (strcat "*" (nth 0 searchlist) "*"))) nil) ;;assuming only 1 defun per line () (if (= ctO ctC) (setq nesteddefuns (append (list ct) nesteddefuns)) ; single line function (if (= ctC 0) (progn (while (/= ctO (+ ctC 1)) (setq lineb (read-line f)) (setq lineb (LM:StringSubst "" (strcat (chr 92)(chr 34)) lineb)) (setq lineb (removequotes lineb)) ;; remove quotes '"' (setq lineb (nth 0 (LM:str->lst lineb ";"))) ;; Remove Comments ';' (if (or (= lineb nil) (= lineb "") ) ;; ignore commented out lines, blank lines () (progn (setq line (strcat line lineb)) (setq ctO (countbracketO line)) ;; count opening brackets (setq ctC (countbracketC line)) ;; count closing brackets (setq ct (+ ct (- ctO ctC))) ;; sum brackets ) ; end progn ) ; end if ) ; end while (setq nesteddefuns (append (list (- ct 1)) nesteddefuns)) ; multiline function ) ; end progn (progn (setq nesteddefuns (append (list (- ct 1)) nesteddefuns)) ; multiline function ) ; end progn ) ; end if ) ; end if ) ; end if (if (= ct (car nesteddefuns)) ;; if ct value is the same as the list (progn (setq linelist (append linelist (list enddelim))) (setq nesteddefuns (cdr nesteddefuns)) ) ; end progn ) ; end if ;;;add in search expressions (if (and (foreach x seachlist (= (wcmatch (strcase line) (strcase (strcat "*" x "*"))) nil) ) ) () (setq linelist (append linelist (NextWord line searchlist))) ;;; (setq linelist (append linelist (NextWord (vl-string-trim " " line) searchlist))) ) ; end if ) ; end progn ) ; end if 'non blank lines' ) ; end while (close f) ) ; end progn ) ; end if (setq lsttxt (splitlst linelist (nth 0 searchlist) enddelim)) ;Display in command line (foreach x lsttxt (princ "\n") (princ (type x)) (princ x) ) (WriteListToFile lsttxt) ;; (MakeClipBoardText (LM:lst->str lsttxt " ")) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1 Quote
j2lstaples Posted September 8, 2023 Posted September 8, 2023 is there a way for VSCode to check my variables as well? I don't see any version of the VLIDE edit. Quote
exceed Posted September 8, 2023 Posted September 8, 2023 1 hour ago, j2lstaples said: is there a way for VSCode to check my variables as well? I don't see any version of the VLIDE edit. - VSCODE -> VLIDE COMMAND : LISPSYS > 0 Quote
BIGAL Posted September 9, 2023 Posted September 9, 2023 Vlide is a Autocad command not a VS command, but Exced may have given you an answer to get around it. 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.