a simple question about strings [message #27012] |
Mon, 08 October 2001 15:06  |
Sean Raffuse
Messages: 46 Registered: July 2001
|
Member |
|
|
Hello.
I'm trying to format some data into one long line of various types of data.
My simple problem is that I am out of room to write the code on one line.
Normally, you can use the '$' to continue your code on the next line.
However, this does not work inside strings. Is there an analogous character
or magic combination of characters that does the same thing? If not, how
can I format my ridiculously long and complex output?
Thanks in advance.
-Sean Raffuse
|
|
|
|
Re: A simple question about strings [message #48081 is a reply to message #27012] |
Mon, 20 March 2006 10:56  |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Fritz wrote:
> Hello,
>
> The command
>
>> A = string(indgen(5))
>
> produces an array of five elements:
> [0 1 2 3 4 5]
>
> The command
>
>> B = '01234'
>
> produces an array of one element:
> 01234
>
> How to transform A so it becomes the same as B ?
>
Pick your poison...
IDL> print, strjoin(strtrim(indgen(5),2))
01234
IDL> print, indgen(5), format = '(5I1)'
01234
IDL> print, strcompress(strjoin(indgen(5)),/remove_all)
01234
IDL> print, string(indgen(5), format = '(5I1)')
01234
I'm sure there are other means, too.
|
|
|
Re: A simple question about strings [message #48082 is a reply to message #27012] |
Mon, 20 March 2006 10:53  |
liamgumley
Messages: 74 Registered: June 2005
|
Member |
|
|
Fritz wrote:
> Hello,
>
> The command
>> A = string(indgen(5))
> produces an array of five elements:
> [0 1 2 3 4 5]
>
> The command
>> B = '01234'
> produces an array of one element:
> 01234
>
> How to transform A so it becomes the same as B ?
Use STRJOIN, e.g.
IDL> a = strcompress(indgen(5), /remove_all)
IDL> help, a
A STRING = Array[5]
IDL> print, a
0 1 2 3 4
IDL> b = strjoin(a)
IDL> help, b
B STRING = '01234'
IDL> print, b
01234
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|
|