$ERROR: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
m (Removed protection from "$ERROR") |
No edit summary |
||
Line 3: | Line 3: | ||
{{PageSyntax}} | {{PageSyntax}} | ||
: [[$ERROR]] | : [[$ERROR]] {{Parameter|Message}} | ||
{{PageDescription}} | {{PageDescription}} | ||
* | * This Metacommand does '''not''' require a comment or REM before it. | ||
* | * {{Parameter|Message}} is any text. Quotation marks are not required. | ||
* When QB64 tries to compile an $ERROR metacommand a compilation error is triggered and | * When QB64 tries to compile an $ERROR metacommand a compilation error is triggered and {{Parameter|Message}} is shown to the user. This is useful in [[$IF]] blocks. | ||
Line 18: | Line 18: | ||
{{PageExamples}} | {{PageExamples}} | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|$IF}} VERSION < 2.1 OR WINDOWS = 0 THEN | {{Cl|$IF}} VERSION < 2.1 OR WINDOWS = 0 THEN | ||
{{Cl|$ERROR}} Requires Windows QB64 version 2.1 or above | {{Cl|$ERROR}} Requires Windows QB64 version 2.1 or above | ||
Line 32: | Line 32: | ||
{{PageNavigation}} | {{PageNavigation}} | ||
[[Category:Final]] |
Revision as of 15:34, 15 June 2022
The $ERROR metacommand triggers a compilation error.
Syntax
- $ERROR Message
Description
- This Metacommand does not require a comment or REM before it.
- Message is any text. Quotation marks are not required.
- When QB64 tries to compile an $ERROR metacommand a compilation error is triggered and Message is shown to the user. This is useful in $IF blocks.
Description
- If there is a particular situation where you know your program will not work properly, you can prevent the user compiling and give them a helpful error message instead by checking for the condition with $IF.
- An $ERROR directive not inside an $IF (or $ELSEIF) block is useless because the program will never compile.
Examples
$IF VERSION < 2.1 OR WINDOWS = 0 THEN $ERROR Requires Windows QB64 version 2.1 or above $END IF |
Output: Compilation check failed: REQUIRES WINDOWS QB64 VERSION 2.1 OR ABOVE on line 2 (assuming your version of QB64 doesn't meet those requirements).
See also