Author Topic: Newbie to world of (Lost in Stupid Parentheses) errr..(List)  (Read 100320 times)

0 Members and 2 Guests are viewing this topic.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #15 on: November 04, 2003, 11:10:19 AM »
Code: [Select]
(defun nl (/ answer oldblip oldortho)
(initget 0 "Three Double Single seCondary E600 F208")
(setq answer (getkword "\nSelect Phase:Three/Double/Single/seCondary/E600/F208 <> "))
  oldblip (getvar "blipmode)  
  oldortho (getvar "osmode)
  (setvar "osmode" 0)
  (setvar "blipmode" 0)

(cond ((= answer "seCondary") ; Secondary
    (setvar "plinewid" 0.5); set polyline width to 0.5
  (setvar "clayer" "622"); set layer to 622
  (princ answer)
      )


I don't know where i'm goin with this.. but give some time to get this into my head..

Does this look a little better??
I took out the setting of variables within the condition and put it before the condition takes place...


7Edit: I added the code tags to your post.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #16 on: November 04, 2003, 11:18:18 AM »
O.k another quick question...

Because i don't understand the syntax too well and still tryin to understand what i read i'm confused to why the routine is not setting the next variables

I figured out how to use the debugging options and place a couple breakpoints...

(cond ((= answer "seCondary") ; Secondary
          (setvar "plinewid" 0.5); set polyline width to 0.5
        (setvar "clayer" "622"); set layer to 622
        (princ answer)
      )

after it finds the first line and reads it it goes to the next but doesn't set "plinewid" to 0.5 and "clayer" to 622...
am i missing somethin in the code?

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #17 on: November 04, 2003, 11:18:24 AM »
Alright just some formatting issues with that code bit.
I have commented the code where you made some formatting mistakes.
Code: [Select]
(defun nl (/ answer oldblip oldortho)
(initget 0 "Three Double Single seCondary E600 F208")
(setq answer (getkword "\nSelect Phase:Three/Double/Single/seCondary/E600/F208 <> "))
(setq oldblip (getvar "blipmode") ;;<- You forgot the "setq" and the closing dbl quotes.
      oldortho (getvar "osmode")) ;;<- You forgot the closing dbl quotes and to
                                  ;;   close the "setq" statment.
  (setvar "osmode" 0)
  (setvar "blipmode" 0)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #18 on: November 04, 2003, 11:20:31 AM »
How much programing experience do you have. (In any language?)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #19 on: November 04, 2003, 11:20:55 AM »
Andre,
If it is your intention to leave OSMODE and BLIPMODE set to 0 then yes, you might as well do it in one place instead of repeating it in each condition.
However, if the user regrets to having issued the command and exits the routine, then it will have changed the users environment unexpectedly, which is not so polite.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #20 on: November 04, 2003, 11:29:53 AM »
When you talk about programming experience let's just say that i was always that turned my head to the idea of ever learning anything about it..

But after working with a consultant for a few months and saw what he did with the autocad system where i work i was blown away and now has me itchin to learn this...

So no experience at all, except for the books i've picked up the last few months.. " Autocadet's guide to Visual Lisp", "Autolisp in Plain English" and
"Autolisp Treasure Chest"

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #21 on: November 04, 2003, 11:48:42 AM »
How far have you gotten in those books? Im asking you because i wanted to know if you truly want to learn or do you just want a couple bits of code?  (and thats cool too; we have a few people like that here. They just want the code and are upfront about it. Thats fine by me.)  If you want to learn, ill toss you a few links to get you started. (And if you want code, ill toss you a few links to get started too :)~ )  But i think we could make this program your "intro" and teach you the right way, right-away. But i suggest starting over so you can understand each and every line in your code.  Up for it?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #22 on: November 04, 2003, 11:53:08 AM »
Well then, if I were you I'd go to www.dsxcad.com and download the VisuaLisp developer's bible so you can get to it later.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #23 on: November 04, 2003, 11:55:11 AM »
Se7en,

Let's start this buggy up because my whole intent is to learn...
I'm lookin for bits of code to put somethin together... I wanna learn
how to write and what things i should keep in mind when i write code.

"Autolisp in Plain English":- I've read that about 5 times now.. I know what you're thinkin... but it's an old copy dating back to version 9 of autocad.. and i know a lot of things have changed since then..

The other 2 I've read a few chapters and section but havin some trouble understandin...

I've found a few websites and have done a lot of readin..
Afralisp is one i enjoy.. I've downloaded the manual for Autolisp and have been goin through that, the only problem i have with that manual is that it jumps too much...

So i'm up to learnin to answer your question...

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #24 on: November 04, 2003, 12:04:58 PM »
w00t! Good, glad to have you abord the lisp train! Alright lets get started.

If your looking for a nice intro the lisp world; our SMadsen has a very nice intro, and is very much so, worth reading. I would at least check it out. Its  on SMadesen's page under the "Primer" section. You can get to it by visiting here: http://www.smadsen.com/ and clicking on the "primer" link on the left.

The next thig i would do is to develop "pseudo code" and tell us  what you want for a program. (remeber we are starting over and giving you a fresh new program.)  

Example Psuedo Code:  (this is actualy one of mine for an idea i was working on.)
Quote
;;; Pseudo code for the circle leader program                         ;
;;;-------------------------------------------------------------------;
;;; - Select an entity.                                               ;
;;; - Test if block.                                                  ;
;;;    - If it is, dive in.                                           ;
;;; - Get second point.                                               ;
;;; - Calculate polar point of circle/arc                             ;
;;; - Get third point (the tail)                                      ;
;;;   ~ I would calc this, but I dont want to assume the              ;
;;;     direction of the tail/text.                                   ;
;;; - Prompt the user for text strings.                               ;
;;;   ~ I could use a simple dialog box for this.                     ;
;;;   ~ I could just start the dtext command after prgn complete.     ;;
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #25 on: November 04, 2003, 12:06:44 PM »
To illustrate some points from the previous comments, consider the code below.

As for COND and why it doesn't proceed further than the condition, please look up COND in the help reference or in one of your books. Sometimes it helps to read up on a function in an isolated way just to get a clear picture of its specific behavior.

Code: [Select]
(defun c:nl (/ answer oldblip oldlayer oldplinewidth oldortho)

  ;;sm: Removing the "1" in INITGET allows GETKWORD to return nil, which
  ;;sm: means that the user simply hit enter or space (an empty input)
  (initget "Three Double Single seCondary E600 F208")
  ;;sm: ^Therefore, we have to test if GETKWORD was given an input
  ;;sm: This can be done by wrapping it all into one CONDition:
  (cond ((setq
           answer (getkword "\nSelect Phase: Three/Double/Single/seCondary/E600/F208 <> ")
         )
         ;;sm: OK, user gave an input that we can use.
         ;;sm: Now proceed. Set the environment and check the input.
         ;;sm: If the user hit enter, the code will not have gone
         ;;sm: this far and it will not be able to set his/her
         ;;sm: system variables (it is still inpolite to change
         ;;sm: them but that's another story :)
         (setvar "osmode" 0)
         (setvar "blipmode" 0)

         (cond ((= answer "seCondary") ; Secondary
                (setvar "plinewid" 0.5) ; set polyline width to 0.5
                (setvar "clayer" "622") ; set layer to 622
                (princ answer)
               )
               ;;sm: Using Daron's suggestion of collecting all identical settings:
               ;;sm: (if you have plans of adding other statements to the conditions
               ;;sm: then please keep your existing structure!)
               ((or (= answer "Three") ; Three Phase
                    (= answer "Double") ; Double Phase
                    (= answer "Single") ; Single Phase
                )
                (setvar "plinewid" 0) ; set polyline width to 0
                (setvar "clayer" "612") ; set layer to 612
                (princ answer)
               )
               ;;sm: Again, using Daron's suggestion:
               ((or (= answer "E600") ; 600/347V
                    (= answer "F208") ; 120/208V
                )
                (setvar "plinewid" 0) ; set polyline width to 0
                (setvar "clayer" "622") ; set layer to 622
                (princ answer)
               )
         )
        )
  )
  (princ)
)

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #26 on: November 04, 2003, 12:18:37 PM »
Thanks for all the comments...
I really do appreciate all the help..

se7en,

I will check out the site and do some readin and i will develop
some pseudo code and i will re-post when i am done..
I will try and get back and post it as soon as i get it done.

Thanks again,

Andre

P.S- Lookin forward to clearing the smoke and starting fresh..

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #27 on: November 04, 2003, 02:33:37 PM »
Under direction of se7en i'm starting over..
I've done some reading and have re-compiled my
routine with some better pseudo code for your understanding


Pseudo Code

-Prompt User: "Select Phase: Three,Double,Single,Secondary,600/347V, 120/208V
-use a keyword for each selection
          - Three = T
          - Double = D
          - Single = S
          - Secondary = C
          - 600/347 = E
          - 120/208V = F

;if user inputs T (Three) then
;Linetype = Three Phase
;Layer = 612
;Color = Bylayer


;if user inputs D (Double ) then
;Linetype = Double Phase
;Layer = 612
;Color = Bylayer

;if user inputs S (Single) then
;Linetype = Single Phase
;Layer = 612
;Color = Bylayer

;if user inputs E (600/347V) then
;Linetype = Hidden
;Linetype Scale = 0.5
;Layer = 622
;Color = Bylayer

;if user inputs F (120/208V) then
;Linetype = Overhead Secondary
;;Layer = 622
;Color = Bylayer

;if user inputs C (Secondary) then
;Linetype = Bylayer
;Layer = 622
;Color = Bylayer
;Plinewidth = 0.5

;after variables are set, the pline command is
launched with all the settings that are required.

;once the user is done drawing a line the routine will reset all variables
to original settings so the routine can start from a fresh start again.

;if user inputs nil (enter) then
; routines exits.


se7en,
I await your response.

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #28 on: November 04, 2003, 03:34:17 PM »
First I would like you to explaine in your own words what a variable is. Then i would like you to explain what a function is. And how the two tie together.

Nothing fancy, just the basics.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #29 on: November 04, 2003, 06:46:08 PM »
In my own words

A variable is where data can be stored ( Numbers, Strings, lists, other variables)

A function is a set of commands you give to the routine to tell it what to do.

A function calls on variables so it can pass through the routine.