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

Home » Public Forums » archive » Re: Why doesn't this work?
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: Why doesn't this work? [message #7789] Tue, 14 January 1997 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Tim Abbott wrote:
>
> Can anyone tell me why this doesn't work?
>
> I need to extract the four numbers from the string "[123:456,246:135]"
>
> Here is the code segment I'm trying to use:
> IDL> str = "[123:456,246:135]"
> IDL> reads,str,x1,x2,x3,x4,format='(4(1X,I0))'
> % Unable to apply format code I to input: "]".
> % Execution halted at: $MAIN$
> IDL> print,x1,x2,x3
> 123.000 246.000 0.00000
> IDL> print,x1,x2,x3,x4
> % PRINT: Variable is undefined: X4.
> % Execution halted at: $MAIN$
>

Tim -

I've mailed you a copy of my routine GET_TOKEN.PRO that
allows you to read byte, int, long, float, double and string
values from a string, as tokens. The routine maintains a string
pointer for subsequent calls.

You can parse the above string using:

IDL> str = "[123:456,246:135]"
IDL> pos=0
IDL> s1 = get_token( str, pos, sep='[:,]', /increment)
IDL> s2 = get_token( str, pos, sep='[:,]', /increment)
IDL> s3 = get_token( str, pos, sep='[:,]', /increment)
IDL> s4 = get_token( str, pos, sep='[:,]', /increment)
IDL> help, s1,s2,s3,s4
S1 STRING = '123'
S2 STRING = '456'
S3 STRING = '246'
S4 STRING = '135'

If anyone else is interested, send me an email and I'll send
you a copy.

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
[ UCSD Mail Code 0949 ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: polar stereographic contour plot.
Next Topic: Q: Selection of specific plot regions

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

Current Time: Wed Oct 08 15:05:55 PDT 2025

Total time taken to generate the page: 0.00456 seconds