QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: luke on January 27, 2021, 06:53:44 am
-
QB64 1.5 will feature a new metacommand and a new pre-compiler value. The below example shows them both:
$IF VERSION < 1.5 THEN
$ERROR Requires QB64 version 1.5 or greater
$END IF
VERSION evaluates to the QB64 compiler version. $ERROR can be used in a $IF block to give a compilation error with a helpful message to the user if the programmer knows they will be using new features. You could also use $ERROR if you program is Windows-only or Linux-only, for instance. VERSION could also be used to implement a section of code two different ways if you're trying to work around differences in behaviour in QB64 versions.
See wiki for further details.
-
Perfect! I love this idea. You guys are great.
-
Is the build process broken?
Was going to test the $ERROR thing, but the dev-build download is still git e3b9c46 from Jan/27.
Shouldn't it be git f7cd2b2 or 65beb28 from Jan/28 already ??
-
Checking. Thanks for pointing it out.
-
Just see, it affects the Windows downloads only.
-
Quick question with all these new error commands:
Since we can generate actual error messages now ( _ERRMESSAGE$, or such, I think), is there some way to set custom messages to go with the codes?
For example, ERROR 5 might give us an error message of “ERROR 5: Illegal Function Call”, but a custom error of 128 would just say, “ERROR 128:”
Is there something like an _CUSTOMERROR$(errNum, errMes$), which an user can use to set those custom errors?
-
If you have a custom error code it’s likely because you have a custom error handler.
-
@SMcNeill I stand corrected, we already have _ASSERT: http://www.qb64.org/wiki/ASSERT
b$ = myFunc$(a)
_ASSERT value
> 0, "Value cannot be zero" _ASSERT value
<= 10, "Value cannot exceed 10"
IF value
> 1 THEN plural$
= "s" myFunc$
= STRING$(value
, "*") + STR$(value
) + " star" + plural$
+ " :-)"
It's an on-spot error handler which allows for a custom message.