PDA

View Full Version : Text string from routine displays twice... WHY?


Donchuno
2007-10-12, 01:33 AM
I've made a pull down menu to make it easy to change text heights using the dimscale variable. Easy enough.
Using this little bit of lisp (this example is for 1 unit high test):
^C^C^P(setvar "textsize" (* 1.0000 (getvar "dimscale")))

It works fine and it returns just the value of the text height.

Then I thought I'll have it return "The new text height is: (text height)"
I thought this bit of lisp would work:
^C^C^P(setvar "textsize" (* 1.0000 (getvar "dimscale")))(setq strtyp "New Text Height is " )(setq strsz (rtos (getvar"textsize")))(princ (strcat strtyp strsz))

It works but gives this odd return on the command line:
New Text Height is 4'-0""New Text Height is 4'-0\""

The first part of that is all I want to see. What am I doing wrong?? I know this is a very simple routine (or it should be...) But I'm an old fart who hasn't touch lisp in years. PLEASE HELP ME!
Aloha!
Blake

aaronic_abacus
2007-10-12, 01:44 AM
Add (princ) to the end.

dgorsman
2007-10-12, 04:43 PM
Most lisp functions return a value; the return of the last function called in a sequence is output to the command line. By adding a (princ) as the last function called, the sequence will return a zero-length string to the command line.

You might want to move the code to a lisp file with a proper command-line function definition, so the command can be updated without messing around with menus. It will also make controlling the command line output easier.

Donchuno
2007-10-12, 05:00 PM
Add (princ) to the end.

That did it! Thanks much guys! I suspected it was something simple I was missing.
(I have to get back into reading up on lisp!)