I cant remember whether or not WHEN ERRor is part of SuperBASIC. Q-Liberator has its own variant, as does Turbo.
Personally I prefer my own VALID% toolkit function (naturally):
ok% = VALID%(expected_type%, <variable or expression>)
It uses the standard Qdos calls to try to fetch the variable/expression on the
stack as the type you specify (int, long, float), and returns its success or not
in ok%. The advantage of this method is that its interpretation will be 100%
consistent with the S*BASIC interpreter's idea of a variable's validity.
For example x% = '1e700' is a valid integer! Namely 1. However, x = '1e700' is
not a valid float! It may not be easy to cater for such anomalies in a home-grown
validy-checking program. At least not without WHEN ERRor. Much better to let
S*BASIC do the hard work!
PRINT VALID%(3, '1e700') will return ok
PRINT VALID%(2, '1e700') will return not ok (2 being the code for float)
VALID%, including it source code (so you could, for example, add it to your own
bespoke toolkit) can be found at Knoware.no
SuperBASIC function for type validation
Re: SuperBASIC function for type validation
Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
Re: SuperBASIC function for type validation
QL ROM (post JM)I cant remember whether or not WHEN ERRor is part of SuperBASIC
This SuperBASIC structure does not work very reliably on any QL versions other than Minerva v1.77 (or later), SMS or the THOR XVI: although Toolkit II improves the reliability...
https://superbasic-manual.readthedocs.i ... error.html
-
- RWAP Master
- Posts: 2893
- Joined: Sun Nov 28, 2010 4:51 pm
- Location: Stone, United Kingdom
- Contact:
Re: SuperBASIC function for type validation
Good to see people are using and quoting from my SuperBASIC / SBASIC Reference Manual 

Rich Mellor
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module - add a USB printer to your QL
Also Involved in:
Icephorm
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module - add a USB printer to your QL
Also Involved in:
Icephorm