setq null variable

setq null variable

Anonymous
Not applicable
900 Views
2 Replies
Message 1 of 3

setq null variable

Anonymous
Not applicable

hi, I am trying to write a command, during that command it asks for height to text, if i hit enter i want the variable to be .2 height but i cant make it, where is the error? thanks

(defun C:cht()
(setq pt1 (getpoint "\nSpecify first corner of text: "))
(setq pt2 (getpoint "\nSpecify second corner of text: "))
(setq height (getreal "\nspecify height of text:"))
(if (null height)
(setq height (= .2))
)
(command "-mtext" pt1 "j" "mc" "h" height pt2)
)

0 Likes
901 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant

Just:

 

(setq height 0.2)

 

And it requires the 0 before the decimal point:

 

Command: (SETQ WHAT .2)
; error: misplaced dot on input

 

even though it doesn't require a 0 after the decimal point:


Command: (SETQ WHO 3.)
3.0

Kent Cooper, AIA
Message 3 of 3

john.uhden
Mentor
Mentor

Along with what @Kent1Cooper sagely pointed out, you have a major problem with this line...

(setq height (= .2))

Change that to...

(setq height 0.2)

 

Of course it would be polite of you to let the user know that there is a default value...

(setq height (getreal "\nspecify height of text <0.2>: "))

I personally much prefer being able to hit just Enter rather than typing in values.

 

BTW, the use of colors in this response is only to highlight suggested changes.  AutoLisp cares nothing about the color of the code.

John F. Uhden

0 Likes