identifying integers or strings

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
banerian
Newbie
Posts: 2
Joined: Mon Apr 10, 2006 3:26 pm

identifying integers or strings

Post by banerian » Mon Apr 10, 2006 7:46 pm

Hello,

I'm parsing data. Some of the data are integers, some strings, but there's not a predictable format to it - I need a way to tell if a variable is holding integer or string data.

Rough example:

Separate>line, ,linedata
If>linedata_1 is-an-integer then
Let>var2=lindata_1*3.1.1459
Endif

This kind of thing. What's the syntax for this?

Thanks,
John

User avatar
JRL
Automation Wizard
Posts: 3503
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Apr 11, 2006 1:34 pm

Try something like this:

Let>line=ABCDEFG 12345 A2B3C4
Let>k=0
Separate>line, ,linedata
Repeat>k
add>k,1
Let>kk=0
Label>CheckEachChar
add>kk,1
Let>TextToCheck=linedata_%k%
Length>TextToCheck,len
Midstr>TextToCheck,%kk%,1,char
If>{(%char%=0)or(%char%=1)or(%char%=2)or(%char%=3)or(%char%=4)or(%char%=5)or(%char%=6)or(%char%=7)or(%char%=8)or(%char%=9)}
Goto>TextContainsNumber
EndIf
If>%kk%=%len%,NoNumbers,CheckEachChar
Label>TextContainsNumber
///Do stuff
Label>NoNumbers
Until>k=linedata_count

Hope this helps,
Dick

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts