Page 1 of 1

redo from start

Posted: Tue Feb 08, 2005 6:20 pm
by relic
Somewhere on this huge board I'm sure the answer lies, but I cannot find it. So, here goes....
When entering a response to a question that wants a numerical value. If the user accidently types a letter you would get `redo from start?'
So, my question is: How would you stop the error message from popping up, and simply make it loop back to the question without making it look messy?
thanks for any help.

Posted: Tue Feb 08, 2005 6:39 pm
by Nathan1993 no login
I won't give you the code :? (to lazy :twisted: ) but I will give you the steps.

#1>Input as STRING
#2>Check for letters, if there are, loop
#3>No letters, convert the string to #s. I dunno the function.

KNOW: MID$, INPUT$, IF, GOTO, DO, LOOP, GOSUB, and Something I don't.

OK... so the KNOW section was stupid. I don't care :wink:

Posted: Tue Feb 08, 2005 7:34 pm
by Z!re

Code: Select all

Do
Input "Enter any number to exit: ", value$
If LTrim$(Str$(Val(Value$) ) ) = value$ Then exit Do
Loop
value = Val(Value$)
"LTrim$(Str$(Val(Value$) ) ) = value$" is quick 'n dirty way to check if value$ is a valid number only, that is, no letters

Posted: Tue Feb 08, 2005 8:54 pm
by Mitth'raw'nuruodo
Quick question Z!re....ummm what's with converting it to an % then back to a $?


:shock: But to my suprise it works! :D

I used to always to the LOOP/ASCII thing....

Posted: Tue Feb 08, 2005 10:06 pm
by Rattrapmax6
You also need to check for commas.. I get a "Redo from start" every time I use a comma. This happens since a comma is used for to variables:

Code: Select all

INPUT "Q"; num1, num2
So if you use a comma and only have one variable, it messes up.. :wink: So it also needs a comma check to if that can be fabricated.. :)

Posted: Wed Feb 09, 2005 7:10 am
by Z!re

Code: Select all

Do
Line Input "Enter any number to exit: ", value$
If LTrim$(Str$(Val(Value$) ) ) = value$ Then exit Do
Loop
value = Val(Value$)
Line input can handle commas


And it convert to number, then to string to check if it's the same. consider:
Value$ = "23A"
VAL(Value$) = 0
LTRIM$(STR$(VAL(Value$))) = "0"
If "0" = "23A" Then Exit Do

thanks

Posted: Wed Feb 09, 2005 11:16 am
by relic
thanks guys. Worked like a charm!
:D

Posted: Wed Feb 09, 2005 3:27 pm
by Mitth'raw'nuruodo
Hmmm...I remember when I was getting these errors.. I forgot about that until this post because I never had to deal with that for like a year...

Posted: Wed Feb 09, 2005 5:02 pm
by Rattrapmax6
Yeah, I was playing with INPUT, MID$, LEN, and those others after Nathans bug (Not making a parser system, no way :shock: ,.) Not going to say what I'm trying to make with 'em tho,. :wink:

I noticed it when applying them in a CHAT style app, if I used a "," it messed up.. :( , LINE INPUT, that will help, but I'm off the CHAT thing for now.. :roll: hehe :wink: I'm on the secret one..

Posted: Wed Feb 09, 2005 5:10 pm
by Mitth'raw'nuruodo
?Que dicis?

Posted: Wed Feb 09, 2005 5:18 pm
by Rattrapmax6
Tranlate:
What for the sake of appearances?? :shock: What? :shock:

Posted: Wed Feb 09, 2005 6:18 pm
by Mitth'raw'nuruodo
Espanol....oh sorry Spanish....

It = What did you say?

Posted: Wed Feb 09, 2005 7:46 pm
by Rattrapmax6
I typed what you said in a latin dictionary..

It came out as : What for the sake of apearances? Ques dicis? :)

Posted: Wed Feb 09, 2005 9:05 pm
by Mitth'raw'nuruodo
He he...did I mention I know enough Spanish to communicate little in it?

Oh ya I said Que which is pronounced k.