String vs. Numeric Input

Input for a string variable occurs in an input symbol, the same one used for inputting numeric values.  When a value is input from the user in an input symbol, the value is stored in the specified variable.  Raptor automatically determines the data type:  If the user types in a properly formed number (leading and trailing spaces are ignored), Raptor will treat the value, and therefore the variable, as a number.  If the user types anything else (including a number with multiple decimal points, spaces between digits, etc.), Raptor will treat the value, and therefore the variable, as a string.  Note that, if the input variable has been used before, an error will occur if the user doesn't enter a value consistent with the previous type for the variable.

 

Below are some examples of legal inputs for both Numeric and String variables.

 

Numeric Input

String Input

3e5   (3 x 105)

3  5

123

12.3.2

-55

              (nothing - if nothing is input, an empty string results

58.7

"123"    (quotes will be part of the string)

 

Note:  If the programmer is asking for a particular type of input (either numeric or string), the user is free to enter something else.  This will normally cause a fatal error at some point of program execution.  Avoiding these fatal errors is beyond the scope of basic Raptor programming.