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

Home » Public Forums » archive » Reading formatted input with READS
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: Reading formatted input with READS [message #93597 is a reply to message #93596] Thu, 01 September 2016 01:50 Go to previous messageGo to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Thursday, September 1, 2016 at 5:27:19 AM UTC+2, Stefano Garcia wrote:
> Hello everybody,
>
> This is my first post so please let me know if I posted it in the wrong place.
>
> My problem is purely that I am not yet familiarized with the IDL formats. I would like to use READS to read what is in between the square brackets below:
>
> %M.z 20.37 [~] D 2011A&A...527A..78F
> %M.z 20.37 [0.12] D 2011A&A...527A..78F
>
> So, there is two cases, one when it is a STRING and the other, when it is a FLOAT.
>
> Is there a way to read that?
>
> I will appreciate any help.
>
> Thanks

Hi,
dunno how to use reads, but I do these sort of stuff with string functions. Not as elegant, but works. To check if the string between square brackets is a number or not, I use the isnumber() from Johns Hopkins University/Applied Physics Laboratory. You don't need the whole library. You can find it here: http://fermi.jhuapl.edu/s1r/idl/s1rlib/local_idl.html

IDL> str = '%M.z 20.37 [~] D 2011A&A...527A..78F'
IDL> posStart = strpos(str, '[')+1
IDL> posEnd = strpos(str, ']')
IDL> print, strmid(str, posStart, posEnd-posStart)
~
IDL> print, isnumber(strmid(str, posStart, posEnd-posStart), value) gt 0
0
IDL>
IDL> str = '%M.z 20.37 [0.12] D 2011A&A...527A..78F'
IDL> posStart = strpos(str, '[')+1
IDL> posEnd = strpos(str, ']')
IDL> print, strmid(str, posStart, posEnd-posStart)
0.12
IDL> print, isnumber(strmid(str, posStart, posEnd-posStart), value) gt 0

I hope it helps.
Cheers,
Helder

PS: this is the right place for these questions
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Band Math
Next Topic: contrast enhancement

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

Current Time: Wed Oct 08 13:54:14 PDT 2025

Total time taken to generate the page: 0.00432 seconds