Posted: Sat Dec 16, 2006 8:55 pm Post subject: Make sure someone enters a string
How do I make sure someone enters a string instead of an int or real?
Sponsor Sponsor
Ultrahex
Posted: Sat Dec 16, 2006 9:03 pm Post subject: (No subject)
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
Posted: Sat Dec 16, 2006 10:44 pm Post subject: (No subject)
you would have to errortrap the user input. you would have to of course put declare variables first.
ericfourfour
Posted: Sat Dec 16, 2006 10:45 pm Post subject: (No subject)
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.
code:
var number : string
get number
put number, " is "..
if not strrealok (number) then
put "not" ..
end if
put " a number."
mish
Posted: Sat Dec 16, 2006 10:47 pm Post subject: (No subject)
LOLL whats a strrealok? o_O that looks an awful lot like an errortrap to me >.<
StealthArcher
Posted: Sat Dec 16, 2006 10:53 pm Post subject: (No subject)
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
Posted: Sat Dec 16, 2006 11:49 pm Post subject: (No subject)
mish wrote:
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.