Author Topic: Small lisp help please  (Read 1536 times)

0 Members and 1 Guest are viewing this topic.

Pad

  • Bull Frog
  • Posts: 342
Small lisp help please
« on: July 13, 2009, 12:13:20 PM »
Hi

Sorry I am probably being a bit thick, but could you please have a look at this lisp and tell me whats wrong.

it is supposed to ask for user input and then depending on choice launch another lisp routine.


Code: [Select]
(defun c:asfinal2 (a)
(setq a (getstring "\nTo burst blocks type 'B' OR to set attributes to invisible type 'I'? B/I : "))
(if
    (or
      (= a "B")
(= a "b")
    );or
((LOAD"ASFINAL) (C:asfinal))
((LOAD"ASFINAL1) (C:asfinal1))
);if
    (princ)
);defun
(princ)
ir runs with error 'Command: ASFINAL2
too few arguments'

Thanks
Pad

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Small lisp help please
« Reply #1 on: July 13, 2009, 12:24:18 PM »
Hi,

Quote
(defun c:asfinal2 (a)

This way, a is declared as an arugument requiered by the  function.

Write: (defun c:asfinal2 (/ a) ...) so that a is declared as a local variable.

Have a look at the initget and getkword functions too (more powerfull than getstring for this unsing).
Speaking English as a French Frog

Pad

  • Bull Frog
  • Posts: 342
Re: Small lisp help please
« Reply #2 on: July 13, 2009, 12:27:14 PM »
ah of course

thanks

i will look into the initget and getkword functions after I get this method working, thanks for the tip!

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Small lisp help please
« Reply #3 on: July 13, 2009, 12:29:56 PM »
you are missing quotes and have an argument specified when you really are trying to localize the variable "a" ...

try this though:

Code: [Select]
(defun c:asfinal2 ( / a)
    (initget "Burst Invisible" 8)
    (setq a (getkword "\nTo burst blocks type 'B' OR to set attributes to invisible type 'I'  [Burst/<Invisible>]: "))
    (cond
        ((= a nil)((LOAD"ASFINAL1") (C:asfinal1)))
        ((= a "Burst")((LOAD"ASFINAL") (C:asfinal)))
        ((= a "Invisible")((LOAD"ASFINAL1") (C:asfinal1)))
    );cond
    (princ)
);defun
(princ)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Pad

  • Bull Frog
  • Posts: 342
Re: Small lisp help please
« Reply #4 on: July 13, 2009, 12:45:06 PM »
oh wow
that getkword function is great.
Thanks for your help.