Page 1 of 1

Macros

Posted: Wed Jan 18, 2023 3:55 pm
by Ann
Reference Manual -> Advanced Keywords -> Macro : EndMacro

Somewhere on that page, there is

Example: Advanced multi-line macro
that shows Assert and two examples.

It may be a joke (on those who love to use assert) or a typo: A "Not" is missing, so the code only asserts errors :)

Thanks for your attention.

Re: Macros

Posted: Fri Mar 10, 2023 8:57 pm
by Andre
Sorry, I don't really understand (but I'm not English-native)...

This is the related example code from the help --> could you show us, how it should look like? Thanks!

Code: Select all

  Macro DoubleQuote
    "
  EndMacro

  Macro Assert(Expression)
    CompilerIf #PB_Compiler_Debugger  ; Only enable assert in debug mode
      If Expression
        Debug "Assert (Line " + #PB_Compiler_Line + "): " + DoubleQuote#Expression#DoubleQuote
      EndIf
    CompilerEndIf
  EndMacro

  Assert(10 <> 10) ; Will display nothing
  Assert(10 <> 15) ; Should display the assert