Computer Science Canada Need help with Changing variables |
Author: | supersaiyan1 [ Thu Nov 30, 2006 8:24 pm ] | ||
Post subject: | Need help with Changing variables | ||
k my program when i enter letter instead of number, it crashes is there a way to make it stop crashing if yes can u plz explain me Code tags added by your friendly neighborhood spiderm... err... mod. |
Author: | uberwalla [ Thu Nov 30, 2006 8:50 pm ] |
Post subject: | |
ok i cant really think of it right now but im pretty sure its possible, ima go watch t.v and ill try to think about it a bit. and by the way when u put ur code in ur post plz make use of the code tags and indenting ur code in turing so that it is easier to read. |
Author: | [Gandalf] [ Thu Nov 30, 2006 9:07 pm ] |
Post subject: | |
Welcome to compsci.ca! The solution to your problem lies in error proofing, which was covered in Cervantes' String Manipulation Tutorial. In essence, you will read in the integer as a string, and then convert that string back to an integer if it doesn't contain any non-numerical characters. Read through it, and you should be able to accomplish what you seek. And yes, next time make sure to put your code inside [ code ] [ /code ] tags (without the spaces). |
Author: | sweetiechic [ Sat Dec 02, 2006 12:49 am ] | ||
Post subject: | |||
k well this is the way I learned how to bulletproof my work:
and then when u want to get a score use 'getscore' instead of 'get' |
Author: | Clayton [ Sat Dec 02, 2006 2:04 am ] |
Post subject: | |
that is in essene correct, perhaps you should put that into a function, generally, whenever you can use a function over a procedure, do it. |
Author: | sweetiechic [ Sat Dec 02, 2006 8:43 pm ] |
Post subject: | |
ohh ok, I thought you couldn't output anything in a function though..? and there's a put statement in the procedure |
Author: | Silent Avenger [ Sat Dec 02, 2006 9:37 pm ] |
Post subject: | |
Functions do have outputs, otherwise they wouldn't be of much use. |
Author: | [Gandalf] [ Sun Dec 03, 2006 12:42 am ] | ||||
Post subject: | |||||
Silent Avenger wrote: Functions do have outputs, otherwise they wouldn't be of much use.
This statement is no doubt confusing. While it is possible to output something in a function, the main point of a function is to return a value. So instead of having:
You would have:
|