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
identifying integers or strings
Moderators: Dorian (MJT support), JRL
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
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