print to a variable [message #5282] |
Mon, 20 November 1995 00:00 |
gfu
Messages: 10 Registered: October 1995
|
Junior Member |
|
|
Hi,
Is there a simple way to write outputs to a string variable that has
the same result as by using the 'print' statement ?
I'm asking something like 'sprintf' as to 'printf' in C.
Thanks.
Gary
|
|
|
Re: print to a variable [message #5284 is a reply to message #5282] |
Mon, 20 November 1995 00:00  |
rivers
Messages: 228 Registered: March 1991
|
Senior Member |
|
|
In article <48qip6$i99@post.gsfc.nasa.gov>, gfu@shark.gsfc.nasa.gov (Gary Fu) writes:
> Is there a simple way to write outputs to a string variable that has
> the same result as by using the 'print' statement ?
>
> I'm asking something like 'sprintf' as to 'printf' in C.
>
Use the string() function:
IDL> a = !pi
IDL> b = 'This is PI: ' + string(a)
IDL> print, b
This is PI: 3.14159
Note that the string function takes a "format" keyword, just like print:
IDL> print, string(!pi, format='(f10.2)')
3.14
____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
|
|
|