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

Username:   Password: 
 RegisterRegister   
 "Goof Proof"
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
14fenix




PostPosted: Tue Dec 09, 2003 1:30 pm   Post subject: "Goof Proof"

I have been trying to make my program not crash when you accidentally input a string instead of a number ie:

code:

var num: int
put "enter a number"
get num


If the user types in a letter accidentally, you get the iunvalid integer input message. I want the program to loop back to the "enter a number part". Is there anyway I can do so?? I have been messing around with boolean and intstr and strintok and those types of things but I cant get it to work.
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Tue Dec 09, 2003 2:57 pm   Post subject: (No subject)

i do think there is an expection system like in java but this should work:

code:

var tempNum : string
var num : int

get tempNum

if strintok (tempNum) then
    num := strint (tempNum)
else
    put "bad input"
end if


strintok test to see if it is posabe to cover a string to an int
strint coverts a sting to an int

so you input it as an int, test to see if is good and if it is covert.

you could trun this in to a while loop to keep on asking for input till vailed one is put in.

P.S. it is idiot proof not goof, lol. see my sig for a good qoute about that Twisted Evil
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
DanShadow




PostPosted: Sat Dec 13, 2003 6:54 pm   Post subject: (No subject)

Wow...I wish I had that answer a month ago, I was having a fair amount of problems, tx.
Dan




PostPosted: Tue Dec 16, 2003 12:32 pm   Post subject: (No subject)

oh yes the power of strint and intstr is grate, it can even cover dec to bibonary, hex or any other bace. who needs whatdocolor when you have a good old intstr Twisted Evil
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Andy




PostPosted: Tue Dec 16, 2003 8:08 pm   Post subject: (No subject)

wtf? i can do that problem with whatdotcolor anyday... i think...
Mazer




PostPosted: Tue Dec 16, 2003 8:55 pm   Post subject: (No subject)

hmm... i'd like to see that one...
AsianSensation




PostPosted: Tue Dec 16, 2003 9:27 pm   Post subject: (No subject)

Sure you could, but it's going to take some planning. Just color coordinate each bases to some color. Make sure the color coded are in some kind of mathematical sequence, and then voila, just use whatdotcolor to get the base, convert it, and then display it in the new color, now look at your color chart, and there you go, now you can figure out what number is what.
Mazer




PostPosted: Tue Dec 16, 2003 9:32 pm   Post subject: (No subject)

AsianSensation wrote:
Just color coordinate each bases to some color. Make sure the color coded are in some kind of mathematical sequence, and then voila, just use whatdotcolor to get the base, convert it, and then display it in the new color, now look at your color chart, and there you go, now you can figure out what number is what.

i was actually considering using a system like that to store the account information for Evasive Maneuvers. using pixels and certain colours to code information (even text). i don't know why i didn't, it woulda been really cool.
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Tue Dec 16, 2003 10:25 pm   Post subject: (No subject)

cool, that seems like an innovative way of encoding things. And no one would be able to guess it, they all be trying to find out how you encrypted the thing as if you did some stuff with prime numbers or whatnot. Well, there's an idea now for EM 2, if you are ever making one that is.
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  [ 9 Posts ]
Jump to:   


Style:  
Search: