Author Topic: Using the PRINC function  (Read 4915 times)

0 Members and 1 Guest are viewing this topic.

iliekater

  • Guest
Using the PRINC function
« on: January 08, 2007, 02:47:44 PM »
For years I was happy wit the use of the cprinc function . Thus , if I wanted to print a text in the next line in the command lie , I used something like this :
( princ "\nBla bla bla" )

Or even set first the text in a variable and then called it as many times I wanted :
( setq MyText "\nBla bla bla" )
( princ MyText  )

However , lately in some routines I run into a strange problem : though I use the same tactics as above , I get the text printed twice :
( princ "\nBla bla bla" )
returns :
"\nBla bla bla" "\nBla bla bla"

It's even stranger the fact that the
\n
caracters are printed as well !
I admit I am a little rusty in Lisp , so the reason why this is happening may be quite simple and funny , but even if you laugh at me , please , tell me what to do in order to solve this problem .

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Using the PRINC function
« Reply #1 on: January 08, 2007, 02:52:20 PM »
It could be that your last line of code is (princ MyText).  If so, then the routine will print your your line as you want it to, but then it will also return it.

Quote
Command: (defun c:Test (/ MyText)
(_> (setq MyText "\n Bla bla bla.....")
(_> (princ MyText)
(_> )
C:TEST

Command: test

 Bla bla bla....."\n Bla bla bla....."
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Using the PRINC function
« Reply #2 on: January 08, 2007, 02:58:03 PM »
When you use PRINC function, you must, place at the end a (PRINC) call.

iliekater

  • Guest
Re: Using the PRINC function
« Reply #3 on: January 08, 2007, 04:17:52 PM »
Thanks a lot . You were both right .