$ERROR: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "The $ERROR metacommand triggers a compilation error. {{PageSyntax}} : $ERROR MESSAGE {{PageDescription}} * The 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. {{PageDescription}} * If there is a particular situation where you know your p...")
 
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
The [[$ERROR]] metacommand triggers a compilation error.
The '''$ERROR''' [[metacommand]] triggers a compilation error.




{{PageSyntax}}
{{PageSyntax}}
: [[$ERROR]] MESSAGE
: '''$ERROR''' {{Parameter|message}}
 
 
{{PageDescription}}
* The 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.




{{PageDescription}}
{{PageDescription}}
* This metacommand does not require a comment ''[[Apostrophe|']]'' 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 {{Parameter|message}} is shown to the user. This is useful in [[$IF]] blocks.
* 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]].
* 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.
* An '''$ERROR''' directive not inside an conditional [[$IF]] (or [[$ELSEIF]]) block is useless because the program will '''never''' compile in that case.




{{PageExamples}}
{{PageExamples}}
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|$IF}} VERSION < 2.1 OR WINDOWS = 0 THEN
{{Cm|$IF}} {{Text|VERSION|#55FF55}} < {{Text|2.1|#F580B1}} {{Cm|OR (boolean)|OR}} {{Text|WINDOWS|#55FF55}} = {{Text|0|#F580B1}} {{Cm|THEN}}
     {{Cl|$ERROR}} Requires Windows QB64 version 2.1 or above
     {{Cm|$ERROR}} Requires Windows QB64 version 2.1 or above
{{Cl|$END IF}}
{{Cm|$END IF}}  
{{CodeEnd}}
{{CodeEnd}}
''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).
;Output (IDE Status Area):Compilation check failed: REQUIRES WINDOWS QB64 VERSION 2.1 OR ABOVE on line 2 (assuming your version of QB64 doesn't meet those requirements).





Latest revision as of 20:11, 28 March 2023

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.
  • 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 conditional $IF (or $ELSEIF) block is useless because the program will never compile in that case.


Examples

$IF VERSION < 2.1 OR WINDOWS = 0 THEN
    $ERROR Requires Windows QB64 version 2.1 or above
$END IF 
Output (IDE Status Area)
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



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link