Computer Science Canada

if not get?

Author:  aldreneo [ Wed Jun 21, 2006 5:25 pm ]
Post subject:  if not get?

How do I do
code:

var oo:real
if not get oo then
    put "Error: ", Error.LastMsg
end if

So that if the user puts a letter insted of a number it doesnt die?

Author:  Clayton [ Wed Jun 21, 2006 6:20 pm ]
Post subject: 

i believe there is a function that determines whether input is of the right type, i think it is something like strintok or something to that effect:D

Author:  TheOneTrueGod [ Wed Jun 21, 2006 6:37 pm ]
Post subject: 

aye, look in the Turing Help (f10) for
strrealok
strintok
strreal
and
strint

Keep in mind you will need a second variable that is a string, and then you'll need to convert it. If you keep this in a separate procedure, It won't clutter up your code.

Author:  aldreneo [ Wed Jun 21, 2006 7:15 pm ]
Post subject: 

Ok, I got it

code:

var number:real
var letter:string
get letter
if strintok(letter)=false then put "error" else number:=strreal(letter)


Thanks


: