Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function to validate string for numeric with decimal point
#31
meh, it isn't as efficient as mine.

Besides, error codes are for wimps who don't use 16x800x600 bit resolution where PRINT statements crash the program Smile
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#32
AGAMEMNUS,

You still haven't fixed your latest posted version.

What do you mean that error codes are for wimps? This may be true if you program is just for fun and never going to be put into production. Put yourself in a user's shoes. He inputs a piece of data and it's rejected with no corresponding error message. How is he supposed to figure out why?

You have to start thinking in terms of "production quality" programs. Let me tell you that more than 50% of the code and effort for applications that interface with users are devoted to security, entitlement, validation, error messages, and error logging.
*****
Reply
#33
I fixed my last version....

What I mean by "Error codes are for wimps" is that if a program were to be using this internally, (not "INPUT userinput$) it would be quite useless to point out the error it made -- better code it so that it doesn't make an error. Smile

For users, an error code is still not justified. A better approach would be to NOT LET the user make an error by making a custom INPUT that only accepts the right stuff. Smile
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#34
Quote:....A better approach would be to NOT LET the user make an error by making a custom INPUT that only accepts the right stuff. Smile

What do you have in mind by a "custom INPUT" that only accepts thre right stuff? Give me an example.
*****
Reply
#35
well, I won't code it here since it's a pain, but the general idea is:
Code:
DO
IF instr$(chr$(13)+chr$(8)+"1234567890."), i$) <> 0 then..
end if
LOOP
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#36
AGAMEMNUS:
Looks like you're doing a kind of character checking. Which brings us back to the subject of having to send the user an error message if he types an invalid charcater. That's what the original routine was all about.
*****
Reply
#37
nay, the user can't enter an incorrect character.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#38
AGA,
How do you inhibit the user from entering invalid data? I don't get it.
*****
Reply
#39
when the user presses any number except "0 1 2 3 4 5 6 7 8 9 . backspace" in the input field, just ignore that in your input function. After the user presses ".", ignore "." afterwards, as well. If nothing is entered after ".", then remove the ".".
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#40
AGAMEMNUS:

That's a wonderful idea you have, but how do you control what keys the user can hit? You cant by using any of the INPUT or INKEY$ commnds that I know? Please tell me how?
*****
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)