
-----------------------------------
chelsee
Sat Dec 16, 2006 8:55 pm

Make sure someone enters a string
-----------------------------------
How do I make sure someone enters a string instead of an int or real?

-----------------------------------
Ultrahex
Sat Dec 16, 2006 9:03 pm


-----------------------------------
easiest way is read everything in as a String and check and then convert for using strintok ( s : string ) : boolean and check whether it is then convert and set as your integer variable.

-----------------------------------
mish
Sat Dec 16, 2006 10:44 pm


-----------------------------------
you would have to errortrap the user input. you would have to of course put declare variables first.

-----------------------------------
ericfourfour
Sat Dec 16, 2006 10:45 pm


-----------------------------------
You should actually use strrealok. This method will return true if a string can be converted to a real number. It will return false if it cannot.
var number : string
get number
put number, " is "..
if not strrealok (number) then
    put "not" ..
end if
put " a number."

-----------------------------------
mish
Sat Dec 16, 2006 10:47 pm


-----------------------------------
LOLL whats a strrealok? o_O  that looks an awful lot like an errortrap to me >.<

-----------------------------------
StealthArcher
Sat Dec 16, 2006 10:53 pm


-----------------------------------
Specifically these statements say "String OK", or in the case you refer to"String-Real OK" meaning that the given input can work with the stated conditions.

-----------------------------------
ericfourfour
Sat Dec 16, 2006 11:49 pm


-----------------------------------
LOLL whats a strrealok? o_O  that looks an awful lot like an errortrap to me >.<
F10. I think there is also a tutorial on it. And did you not read my post? I said exactly what it does.
