Jump to content

Finding Parenthesis for if & progn Statements


Recommended Posts

Posted (edited)

OK, so everyone knows that using the IDE with AutoLISP you can enter a closing paren and the cursor will quickly flash at the location of the opening paren which the one just typed is paired to. Now imagine that the distance between the pair of parens is much longer than the vertical height of the monitor. The cursor still flashes at the beginning paren but then reappears where you're typing and I can't tell where it flashed. :unsure:

 

I have found that by carefully positioning both hands on the keyboard and at just the exact moment I press the PrintScreen key. Then by pasting from the clipboard into Paint I can often times see the cursor where the opening paren is and if it's the correct one. But this method is sometimes hit or miss. Is there a method to have the screen pause long enough for me to actually see where the opening paren is located?

 

UPDATE: OK - I found this on the forum. Has some good stuff, but are there any other methods.

 

(_vl-balance-parenthesis 1 2000) => This look like the ticket here!

Edited by Bill Tillman
Posted

This may be helpfull chkbrk.lsp wrote it years ago look in out put file

 

(defun c:chkbrk (/ opf bkt chekdfile rdctl wkfile currentln wln ltr ncln)
(setvar "cmdecho" 0)
(prompt "\nlook at end of line")
;(setq chekdfile (getstring "enter name of file :"))
(SETQ chekdfile (getfiled "Enter file name:" " " "LSP" 4))

(setq opf (open chekdfile "r"))
(setq bkt 0)
(setq blkl 0)
(setq rdctl 1)
(setq wkfile (open "c:\temp\wow.lsp" "w"))

(setq currentln "a")
(while (/= blkl 6)
(setq currentln (read-line opf))
(if (= currentln nil)(setq currentln ""))
(if (= currentln "")(setq blkl (+ 1 blkl))(setq blkl 1))
(setq wln currentln)                                                        
(while (/= wln "")
       (setq ltr (substr wln 1 1))
       (setq wln (substr wln 2))
       (cond ((= (ascii ltr) 34) (if (= rdctl 0)(setq rdctl 1)(setq rdctl 0)))
               ((and (= ltr "(")(= rdctl 1))(setq bkt (+ bkt 1)))
               ((and (= ltr ")")(= rdctl 1))(setq bkt (- bkt 1)))
               ((and (= ltr ";")(= rdctl 1))(setq wln ""))
               ;(t (prompt ltr))
       )
)
(setq ncln (strcat currentln ";" (itoa bkt)
(princ (itoa bkt))
(if (= rdctl 0) "string open" "")))
(if (/= currentln "")(write-line ncln wkfile))
)
(close wkfile)
(close opf)
(prompt (strcat "open brakets= " (itoa bkt) "."))
)

(setq ang1 nil
     pt1 nil
     pt2 nil
     pt3 nil
     pt4 nil
     pt5 nil)

(princ)

Posted

You may position the cursor on a parenthesis and press + or + (square brackets) and the cursor will jump to the pair one. If it doesn't jump, the that parenthesis isn't properly balanced.

Posted

Thanks guys...that's all great information. I am using the (_vl-balance-parenthesis 1 2000) command at the console and it makes life so much easier now. The code I'm working on this morning is close to 4,000 lines long and it makes LISP (Lost in Stupid Parenthesis) a little easier to find my way around in.

Posted

In the Visual LISP IDE, double-clicking outside a parenthesis will highlight all expressions enclosed by the parenthesis.

Posted

Lee, I like that idea much better. The _vl statement above I was using has a definite drawback. It slows down typing in code. I thought it was simply when you're checking for parenthesis pairs, but it enforces the longer delay at all time and that makes typing much slower.

Posted

Bill a question 4000 lines is the code broken into defuns if not then it probably should be makes debugging so much easier, I would never write a continuous single start and end lisp program of this size. I have thousands of lines of code and over the years have built up libraries so that you can make calls to external defuns autoloaded so much easier to control and have all been long time debugged. I am not a programmer but a professional would also break the code down into smaller routines joined together. Anyway thats my view others may disagree. Had a quick look my architectural add on 96 lisps

Posted

BIGAL, no the 4,000 liners are broken into many (defuns), the one I'm working on right now has 31 (defuns). Over the year now I've been developing for these folks I now have 9 programs, the smallest being about 2,300 lines and the larger ones being over 4,000 lines. And I write and format my code to include more on a single line than what the IDE would default format it to. It I did that it would probably turn into more like 5,000 or 6,000 lines.

 

Several months ago I started breaking some of the (defuns) out into their own files and load them if and only if they are needed. This saves mucho time when making changes or fixing bugs because I can make the change in one place instead of having to edit up to 9 different programs.

 

The assemblies manufactured here have so many different features that the users can select. It makes IF this, IF that, IF this and NOT that...etc... a real challenge.

 

I also just completed a web interface for them last month which allows the salespeople as well as many of their customers to produce drawings in seconds. The drawings produced by this system now far outnumber what the designers could ever do on a given day. Yesterday, for example, the system produced more drawings than all 8 of their designers could do in three 10 hour days. And the best part is no one is being laid off. It just means the tedious units are flying out the door and only the really complex products go to the designers.

Posted

Bill sounds like your well on top. Our main emphasis was on having stds hence the outside defuns these handle the, for a particular object you shall have correct layers and colours. Then each individual shall we call it part had a lisp. Some lisp parts had 1 -2 sub options and did grow to 6-7 as we used a menu or keyboard command the lisp was basicly a cond that called a defun in the lisp so add a defun add a simple cond the menu ^c^c^p(setq part "part56")(load "endwaller")

 

Its sound like though you objects are pretty extensive post some pictures of the steps.

Posted

BIGAL, my situation was to create an entirely automated process. Absolutely no user input whatsoever from start to finish. I'd love to post some details but I'm sworn to secrecy with an NDA contract. It is cranking out drawings by the score. We're at over 100 for the week and we still have two more days to go.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...