Going through a string as an array - what did i do?
TrikinCurt
Posts: 158
For (i=1;i<=LENGTH_STRING(data.text);i++) { If (debug) SEND_STRING 0,"'PARSING! step:',ITOA(i),' is ',data.text[i],'.'" strStatus = data.text[i] intStatus = ATOI(strStatus) strZone = ITOA(i)
Okay, my debug line prints what I expect, as data.text is simply a long string of numbers (coming back from a security system). So data.text = '222200004444' etc...
It prints the debug as step:1 is 4. That seems fine and dandy.
Why can't I convert that to an int with ATOI? I tried ATOI(data.text) and the code above, same error no matter what I do, not a compile error but a runtime error on the ATOI routine.
I know it is late, but am I doing something really wrong?
Curt
0
Comments
ATOI(data.text)
To this
ATOI(?data.text?)
ATOI() requires a string and Netlinx (right or wrong) does not interpret one character as a string. The double quotes forces it into a string and satisfies ATOI(). I?ve been told to always use double quotes with ATOI() to avoid any possible ambiguity.
All better, thanks again,
Curt