
-----------------------------------
xSonu
Wed Jan 20, 2010 10:01 pm

What is strintok
-----------------------------------
I`m a bit confused. I know strintok is a error trap but what does it really mean.

Yea yea, i know you people are probably saying go check the reference manual or its on the site.

But the definitions on the site and manual, i dont get them

i mean converting string to integer :?: 

its not getting to me, could someone explain it in a more simpler way.

-----------------------------------
Zren
Wed Jan 20, 2010 10:27 pm

RE:What is strintok
-----------------------------------

var str:="99"
var x:int
if strintok(str) then
    x := strint(str)


If string can convert to an integer then,
X is the integer value of Str.

Basically it checks the string if it's compatible as an Integer, and returns true or false. If it's false, then you skip the conversion and immenent failure.

-----------------------------------
TerranceN
Wed Jan 20, 2010 10:31 pm

Re: What is strintok
-----------------------------------
strint changes a string to an integer, but if the string has something other than letters, your program will crash. This is where strintok becomes useful.

stringok checks if you can convert a string to an integer, so:

strintok("5") % returns true

but

strintok("wsecuy") % returns false

so if you use this in an if statement with strint, you can prevent the error, and even say what to do if there would have been an error

var num : int := 0
var str : string := "5"

if strintok(str) then
    num := strint(str)
else
    % handle error
end if

put num

Hope that helps
