Author Topic: TIP: converting to a string  (Read 3093 times)

0 Members and 1 Guest are viewing this topic.

Columbia

  • Guest
TIP: converting to a string
« on: December 05, 2003, 12:42:55 PM »
Here's something I just ran across.  It's been around a while, but there are often tricks that are sometimes overlooked.

If you want to convert something (real or integer) to string and format is not a real big concern try using (vl-prin1-string) as in:
(setq x 1 y 1.5)
(vl-prin1-string x) returns "1"
(vl-prin1-string y) returns "1.5"

This could come in handy when dealing with dialog boxes.  I hope you all enjoy.

Adesu

  • Guest
Re: TIP: converting to a string
« Reply #1 on: February 17, 2005, 03:19:58 AM »
Quote from: Columbia
Here's something I just ran across.  It's been around a while, but there are often tricks that are sometimes overlooked.

If you want to convert something (real or integer) to string and format is not a real big concern try using (vl-prin1-string) as in:
(setq x 1 y 1.5)
(vl-prin1-string x) returns "1"
(vl-prin1-string y) returns "1.5"

This could come in handy when dealing with dialog boxes.  I hope you all enjoy.


You should like this

_$ (vl-prin1-string x)
; error: no function definition: VL-PRIN1-STRING

_$ (vl-prin1-to-string x)
"1"
_$

Columbia

  • Guest
TIP: converting to a string
« Reply #2 on: February 22, 2005, 01:28:16 PM »
You might want to make sure that COM interface for Visual LISP is loaded by issuing (vl-load-com).

If that doesn't work, call the ghostbusters. :D

daron

  • Guest
TIP: converting to a string
« Reply #3 on: February 22, 2005, 01:33:10 PM »
It'd also be nice to know what version of autocad Adesu is using??

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
TIP: converting to a string
« Reply #4 on: February 22, 2005, 01:40:44 PM »
The problem is not loading the COM interface or the Acad version.

VL-PRIN1-STRING does not exist as a built in function.

VL-PRIN1-TO-STRING does :)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Columbia

  • Guest
TIP: converting to a string
« Reply #5 on: February 22, 2005, 02:35:11 PM »
Yeah, well, so I can't type worth a hoot.  So what.  You don't have to make fun of me.... :crazy: