Error Handling

BlitzPlus Forums/BlitzPlus Beginners Area/Error Handling

Armor Nick(Posted 2007) [#1]
Greetings everyone,

Currently, I am remaking a Delphi tutorial with BlitzPlus and it's going quite well. But I've hit a seemingly dead-end; I need to know how to handle a type conversion error.

You see, I am making a Celcius<->Fahrenheit converter, and there is a textbox where you have to put the degrees you want to convert. Now, what will happen when the user puts in a string? It should give an error.

How would I do this?


Andy_A(Posted 2007) [#2]
If a string is entered it's the same as entering a zero because Blitz automatically converts strings into integers.

Entered string: Converted to:
"11".................11 (integer)
"E 11th St"...........0 (integer)
"WTF???"..............0 (integer)

You may, or may not have noticed that Blitz+ does not have a VAL() function to convert string values to integers.

The non-obvious way to validate is to accept every input as a string and parse for digits (i.e. chr$(48)-chr$(57).

Kind of lame, but oh well... :/