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

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #270 on: November 19, 2003, 09:50:40 AM »
Hey SMadsen, isn't terpri an obsolete function. I mean it still works, but does anybody really use it? Is it useful in Andre's routine?

Andre', that looks good, but remember, things that are the same in all conditions can be altered outside the condition statement. Also, you might consider creating a function to be called within the cond so you don't have to type the same variables over and over again. Example:
Code: [Select]
(defun chvars (clay lintype)
(setvar 'clayer clay)
(setvar 'celtype lintype)
(princ)
)

Write that outside the condition and/or outside the main function and call it like:
Code: [Select]
(cond ((= ans "T")
         (chvars "612" "Three" etc.)
        )
)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #271 on: November 19, 2003, 09:51:00 AM »
amgirard2003,
Just so that you know about this option :--

Note the [ ... ] in the prompt here.
If you now long press the right mouse button during the prompt .. then you will see the dialog box ..

and .. the < > are usually only used to enclose a default value.
 
and .. terpri was remove ' cause the "\n ... " makes it superfluous

Code: [Select]

(defun c:nl ( / ans)
  (prompt "Run with Phil's routine only")
  (initget 0 "T D S C E F")
  (setq ans
         (getkword
           "\nSelect Line: [(T)hree/(D)ouble/(S)ingle/se(C)ondary/(E)600/(F)208]: "
         )
  )
  (cond ((= ans "T")
         (setvar "clayer" "612")
         (setvar "celtype" "Three")
        )
  )
  (princ)
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #272 on: November 19, 2003, 10:05:07 AM »
(terpri)
I was referencing one of the books i have... it's quite old so i didn't know
it was old and wasn't in use anymore...
I'll remeber to use "\n"..

Daron,

I want to take one step at a time... I want to write it out so i can work with it and then improve the writting of the code afterwards..

SMadsen

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #273 on: November 19, 2003, 10:05:50 AM »
Ok, I thought wrong. Seeing your code, the string makes sense.

Time to learn some standard GUI techniques when asking for keywords. Notice how AutoCAD always offers keywords as entire words with one or a few uppercase letters in them? It's possible to choose a keyword by typing the uppercase letter(s) only, part of the keyword or the entire word.

In your code, it's only possible to make a valid choice by typing the uppercase letter. Not that it's wrong but it doesn't comply to the standards.
Of course, there is a problem with choosing "E600" and "F208" but take a look at the code below for a possible solution.

Also, notice that AutoCAD almost always put choices into square brackets and separate them with slashes? This has a distinct purpose. Try running the modified code below and, while executing GETKWORD, try to right-click:

Code: [Select]
(defun c:nl ()
  (prompt "Run with Phil's routine only")
  (terpri)
  (initget 0 "Three Double Single seCondary E E600 F F208")
  (setq ans
         (getkword "\nSelect Line [Three/Double/Single/seCondary/E600/F208] <>: ")
  )
  (cond ((= ans "T")
         (setvar "clayer" "612")
         (setvar "celtype" "Three")
        )
  )
)

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #274 on: November 19, 2003, 10:12:03 AM »
when i right click it it just says : nil

SMadsen

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #275 on: November 19, 2003, 10:14:52 AM »
Wow, 3 posts came in while typing - talk about falling asleep! Nah, had a phone call and didn't refresh

Daron, I think TERPRI is still used for print-to-screen purposes. I use it when outputting other data than strings where (princ "\n")'s hurts the eye

SMadsen

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #276 on: November 19, 2003, 10:17:26 AM »
Quote from: amgirard2003
when i right click it it just says : nil

Ok, try this sequence at the command line and right click where it says so (watch out for word wrap):

Command: (initget 0 "Three Double Single seCondary E E600 F F208")
nil
Command: (getkword "\nSelect Line [Three/Double/Single/seCondary/E600/F208] <>: ")
Select Line [Three/Double/Single/seCondary/E600/F208] <>: [right-click here!]

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #277 on: November 19, 2003, 10:22:43 AM »
I still get nil..
I think it might be because i might have changed the function of my mouse
What does right click on your mouse do?

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #278 on: November 19, 2003, 10:25:09 AM »
It brings up a popup that says:
Enter
Cancel
Three
Double
Single
seCondary
E600
F208
Pan
Zoom

SMadsen

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #279 on: November 19, 2003, 10:27:22 AM »
Thanks Daron :)

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #280 on: November 19, 2003, 10:31:29 AM »
nope not working over here..
It must be an Autocad 2004 improvement..

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #281 on: November 19, 2003, 10:38:26 AM »
Not that either. It has been implemented since 2000. After hitting enter after inputing (getkword ...) the command line should read:
Select Line [Three/Double...<>:. Are you right clicking at this point? Check this, under options->User Preferences, select Right-click Customization. Is command Mode set to "Shortcut Menu: enabled when command options are present"? If not, that is your problem.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #282 on: November 19, 2003, 10:58:12 AM »
I changed that setting and still nothing is working..
no shortcut menu...

daron

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #283 on: November 19, 2003, 11:00:11 AM »
What about the Default Mode in the same dialog? Is it set to Shourtcut Menu? In fact, put everything to Shortcut Menu.

amgirard2003

  • Guest
Newbie to world of (Lost in Stupid Parentheses) errr..(List)
« Reply #284 on: November 19, 2003, 11:06:42 AM »
nope not that either..
didn't work..
 :evil: