Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 4.84 KB

macros.md

File metadata and controls

41 lines (34 loc) · 4.84 KB

Documentation

Pre-processor macros

macro [name] [code]

A macro is a capitalized keyword of at least 2 characters associated with a single line of code containing at least one statement. Each time the macro's keyword occurs in the source it is substituted with its associated line of code. This task is executed by the pre-processor before the compilation phase starts.

macro WAIT delay 100

while true
  print "Hello World!"
  WAIT
next

After the pre-processing phase the code above looks like this:

while true
  print "Hello World!"
  delay 100
next

Macros are useful to associate a keyword with an integer constant or a string literal, without consuming a variable address. Macros can be used also to associate a keyword to a system function call or a function call with a predefined set of parameters.