Number Array Difficulties - Pr
Hi Guys,I have just been creating a LISP to produce a number array, but can't get it to work.
I would appreciate it if someone could point out the mistake in my program
(defun c:numarray (/ snum enum incr txpt cnt ldir lspc) (while (and (setq snum (getreal "\nSpecify Starting Number: ")) (setq enum (getreal "\nSpecify Ending Number: ")) (setq incr (getreal "\nSpecify Increment Size [> 0.01]: ")) (setq txpt (getpoint "\nSelect First Text Base Point: ")) ) ; end and (setq cnt snum) (initget 1 "Up" "Down" "Left" "Right") (setq ldir (getkword "\nSpecify List Direction (Up/Down/Left/Right): ")) (setq lspc (getreal (strcat "Specify List Spacing [>" (rtos (* 2.5 (getvar "DIMSCALE")) 2 2) "]: " ) ; end strcat ) ; end getreal ) ; end setq (while ( Right off the bat I noticed that your initget has too many arguments
should be
(initget 1 "Up Down Left Right") Excellent, thanks for that lpseifert - I knew it would be something as simple as that... Hi Guys,
Once again, thanks for your help with my LISP program
Now that I have finished it, I thought I might upload it so that if it is of any use to anyone to help speed up their work, they are free to use it or modify it to better suit their needs.
So here it is:
(defun c:numarray (/ pref ptxt snum enum incr txpt cnt ldir lspc) (initget "Yes No") (setq pref (getkword "\nPrefix Text? : ")) (if (= pref "Yes") (setq ptxt (getstring t "\nSpecify Prefix: ")) ) ; end if (while (and (setq snum (getreal "\nSpecify Starting Number: ")) (setq enum (getreal "\nSpecify Ending Number: ")) (setq incr (getreal "\nSpecify Increment Size [> 0.01]: ")) (setq txpt (getpoint "\nSelect First Text Base Point: ")) ) ; end and (setq cnt snum) (initget 1 "Up Down Left Right") (setq ldir (getkword "\nSpecify List Direction (Up/Down/Left/Right): ")) (setq lspc (getreal (strcat "\nSpecify List Spacing [> " (rtos (getvar "TEXTSIZE") 2 2) "]: " ) ; end strcat ) ; end getreal ) ; end setq (cond ((/= pref "Yes") (while ( Lee Mac you're learning fast.
Food for thought.
(defun c:numarray (/ pref ptxt snum enum incr txpt cnt ldir lspc) (initget "Yes No") (setq pref (getkword "\nPrefix Text? : ")) (if (= pref "Yes") (setq ptxt (getstring t "\nSpecify Prefix: ")) (setq ptxt "") ) ; end if (while (and (setq snum (getdist "\nSpecify Starting Number: ")) (setq enum (getdist "\nSpecify Ending Number: ")) (setq incr (getdist "\nSpecify Increment Size [> 0.01]: ")) (setq txtpt (getpoint "\nSelect First Text Base Point: ")) ) ; end and (setq cnt snum) (initget 1 "Up Down Left Right") (setq ldir (getkword "\nSpecify List Direction (Up/Down/Left/Right): ")) (setq lspc (getdist (strcat "\nSpecify List Spacing [> " (rtos (getvar "TEXTSIZE") 2 2) "]: " ) ; end strcat ) ; end getdist ) ; end setq (if (member ldir '("Right" "Left")) (setq ang 0.) (setq ang (/ pi 2.)) ) (if (member ldir '("Down" "Left")) (setq lspc (- lspc)) ) (while ( Thanks Charles,
That make the LISP a lot more concise, whilst still achieveing the same result.
I couldn't figure out how to incorporate the prefix within the entmake function and still enable the user to decide not to use a prefix, without duplicating the entmakewith use of a cond function - but just setting the prefix to "" in the alternative result of the if function accomplishes it nicely.
Thanks
页:
[1]