QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

Re: When does 'redo from start' occur?

March 17 2012 at 2:47 PM
ChronoKitsune  (Login rpgfan3233)


Response to When does 'redo from start' occur?

 

There are two situations in which I know it occurs for certain:
- Using INPUT with a string containing a comma
- Trying to INPUT a string when a numeric variable is used

The last case is one that QB64 eliminates by limiting the characters you can type when trying to store a numeric value.

The first case, however, is a bit more difficult. INPUT was designed to allow you to enter several items at once. For example, you could enter a name and age:
INPUT "Enter your name and age, separated by a comma: ", name$, age%

The problem arises when you do something like this:
INPUT "Enter your name (Last, First): ", name$

Ideally you would use the comma in the string to separate the names later. This limits the number of reads you would need to do. In QBasic, this was definitely an issue due to limited system resources, and string operations may have taken less time. However, if you try to enter the name in the last case:

Kitsune,Chrono

You would end up getting a "Redo from start" message because there are two items there, not one.

Ultimately, there is a rule: use LINE INPUT for strings and INPUT for numbers. And back in QBasic, you should have used LINE INPUT for numbers and parsed the string yourself actually. After all, how can you store 3.45 in an integer variable?

 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement