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

Home » Public Forums » archive » Re: how to tell it is character or it is number?
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: how to tell it is character or it is number? [message #55213 is a reply to message #55211] Tue, 07 August 2007 10:41 Go to previous messageGo to previous message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Aug 7, 11:38 am, wlandsman <wlands...@gmail.com> wrote:
>> Is there a way I can tell whether it is numbers or it is characters?
>> 'fix' command can convert the numbers, it will give an error message
>> then continue to the execution.
>
> There are lots of programs around to do this, with two variants. The
> first tests, as you suggest, whether IDL can convert the string into a
> numeric value
>
> http://idlastro.gsfc.nasa.gov/ftp/pro/misc/strnumber.pro
>
> But IDL will consider the string '1qz_3' to be a valid number (=1) so
> if you want a more usual interpretation, you need a more detailed
> test of whether the ordering of digits, letters and decimal points
> make sense as in
>
> http://idlastro.gsfc.nasa.gov/ftp/pro/misc/valid_num.pro
>
> --Wayne

I would just try stregex. From what you've shown so far, all it would
take is this:

if stregex( string, '[^0-9]', /boolean ) then ; this not numeric
else ; this is numeric

that is assuming, of course, that the numeric data you will be
checking only contains the numbers 0-9. If you have negative signs,
or decimal points, or whitespace, then above regular expression will
have to be adjusted accordingly.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Basic Event Handling
Next Topic: question regarding 3d plotting

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

Current Time: Sun Oct 12 14:55:49 PDT 2025

Total time taken to generate the page: 1.20213 seconds