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

Home » Public Forums » archive » Splitting An Array Of Strings Without Using Loops
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Splitting An Array Of Strings Without Using Loops [message #35960 is a reply to message #35881] Sat, 26 July 2003 04:10 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Darrick White wrote:

> This is probably simple, but I'm having a time trying to figure it
> out. I want to be able to split an array of strings without using
> loops.
>
> Example:
> dataPoints is an array of strings with N elements
> The format of each element within dataPoints is "x:y1:y2:y3:yn". More
> than likely, the data will be in the format of x:y".
>
> This array will become data points (the first element is always
> considered the x coordinate): (x,y) = 1,23. In case of multiple
> points (2:21:34:54), the data will look like: (2,21), (2,34), (2,54).
>
> I need a way to take:
> dataPoints[0] = 1:23
> dataPoints[1] = 2:32
> dataPoints[2] = 3:30
> dataPoints[3] = 4:45
>
>
> and create
> points[2,4]
> 1 23
> 2 32
> 3 30
> 4 45
>
> -Darrick


Dear Darrick,

here is a second solution using reads.

pro test
data=['1:23','2:32','3:30','4:45']

s={x:bytarr(1),s:bytarr(1),y:bytarr(2)}
s=replicate(s,4)

reads,byte(data),s

print,string(s.x)
print,string(s.y)
end

IDL> 1 2 3 4
IDL> 23 32 30 45


--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: where is my plot....
Next Topic: Reading RINEX files into IDL

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

Current Time: Sat Oct 11 12:31:26 PDT 2025

Total time taken to generate the page: 0.79983 seconds