I have a small GUI application with a text-field and a button. The button triggers a function which tries to read a number from text-field. An exception is raised if the text-field is blank or has non-numeric text.
I am trying to catch error if text-field does not have a value or has text value rather than a valid number:
calc: does [
try [x: to integer! num_field/text]
catch [ print "Could not get number"]
print "Number read"
]
Following also does not work:
calc: does [
try [x: to integer! num_field/text]
throw 123
print "Number read"
]
catch 123 [ print "Could not get number"]
I am not sure how to use try, throw and catch here. I tried to check section 10 of http://static.red-lang.org/red-system-specs.html but could not really understand.
How can this be solved? Thanks for your help.