mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-07 08:20:18 +00:00
54 lines
1.7 KiB
Text
54 lines
1.7 KiB
Text
|
{{QBDLDATE:05-20-2022}}
|
||
|
{{QBDLTIME:23:06:28}}
|
||
|
This metacommand enables debug tests with the [[_ASSERT]] statement.
|
||
|
|
||
|
|
||
|
{{PageSyntax}}
|
||
|
:[[$ASSERTS]][:CONSOLE]
|
||
|
|
||
|
|
||
|
{{PageDescription}}
|
||
|
* The metacommand does not require a comment or [[REM]] before it. There is no space after the colon.
|
||
|
* If this metacommand is used in a program and any of the set [[_ASSERT]] checkpoints will fail, then the program will stop with an '''{{Text|_ASSERT failed|#fc5454}}''' error.
|
||
|
* Detailed error messages passed to the [[_ASSERT]] statement will be displayed in the console window, but only if [[$ASSERTS|$ASSERTS:CONSOLE]] is used.
|
||
|
|
||
|
;Note: This metacommand is the main switch to enable debug tests during development. Later just remove this metacommand to compile the program without debugging code, all the [[_ASSERT]] statements may remain in the code for later debugging sessions, they are simply ignored without this metacommand.
|
||
|
|
||
|
|
||
|
{{PageAvailability}}
|
||
|
* '''QB64 1.4 and up''' (QB64 Team)
|
||
|
* '''QBPE 0.5 and up''' (QB64 Phoenix Edition)
|
||
|
|
||
|
|
||
|
{{PageExamples}}
|
||
|
;Example:Adding test checks for parameter inputs in a function.
|
||
|
{{CodeStart}}
|
||
|
{{Cl|$ASSERTS}}:CONSOLE
|
||
|
|
||
|
{{Cl|DO}}
|
||
|
a = {{Cl|INT}}({{Cl|RND}} * 10)
|
||
|
b$ = myFunc$(a)
|
||
|
{{Cl|PRINT}} a, , b$
|
||
|
{{Cl|_LIMIT}} 3
|
||
|
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|_KEYHIT}}
|
||
|
|
||
|
{{Cl|FUNCTION}} myFunc$ (value {{Cl|AS}} {{Cl|SINGLE}})
|
||
|
{{Cl|_ASSERT}} value > 0, "Value cannot be zero"
|
||
|
{{Cl|_ASSERT}} value <= 10, "Value cannot exceed 10"
|
||
|
|
||
|
{{Cl|IF}} value > 1 {{Cl|THEN}} plural$ = "s"
|
||
|
myFunc$ = {{Cl|STRING$}}(value, "*") + {{Cl|STR$}}(value) + " star" + plural$ + " :-)"
|
||
|
{{Cl|END}} {{Cl|FUNCTION}}
|
||
|
{{CodeEnd}}
|
||
|
|
||
|
|
||
|
{{PageSeeAlso}}
|
||
|
* [[_ASSERT]]
|
||
|
* [[$CHECKING]]
|
||
|
* [[Relational Operations]]
|
||
|
* [[ERROR Codes]]
|
||
|
|
||
|
|
||
|
{{PageNavigation}}
|
||
|
|