comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » a simple question about strings
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
a simple question about strings [message #27012] Mon, 08 October 2001 15:06 Go to next message
Sean Raffuse is currently offline  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 #48077 is a reply to message #27012] Mon, 20 March 2006 12:03 Go to previous message
mmeron is currently offline  mmeron
Messages: 44
Registered: October 2003
Member
In article <1142879866.627909@pwww.drenet.dnd.ca>, "Fritz" <f.leduc@hotmail.com> writes:
> 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 ?
>
a = strcompress(strjoin(string(indgen(5))),/remove)

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
Re: A simple question about strings [message #48081 is a reply to message #27012] Mon, 20 March 2006 10:56 Go to previous message
btt is currently offline  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 Go to previous message
liamgumley is currently offline  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/
Re: A simple question about strings [message #48083 is a reply to message #27012] Mon, 20 March 2006 10:43 Go to previous message
Fritz is currently offline  Fritz
Messages: 7
Registered: February 2006
Junior Member
Hello,

Little correction:

The command
> A = string(indgen(5))
produces an array of five elements:
[0 1 2 3 4]
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to debug seg fault.
Next Topic: how to exchange variable between modal dialog and the main window?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:07:23 PDT 2025

Total time taken to generate the page: 0.00682 seconds