Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 if not get?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
aldreneo




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Wed Jun 21, 2006 6:20 pm   Post subject: (No 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
TheOneTrueGod




PostPosted: Wed Jun 21, 2006 6:37 pm   Post subject: (No 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.
aldreneo




PostPosted: Wed Jun 21, 2006 7:15 pm   Post subject: (No 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: