MACROS/OBJECTS
Macros and Objects is almost the same,
but the syntax is a little bit different.
Objects is using a Main-Parameter and the
other parameters must be inside brackets ( ).
Usage:
name MACRO (params) ; Start of a macro
; code here...
(name) ENDM ; End of macro
name OBJECT mainParam ((params))
; Start an object
(name) ENDO ; End of object
Example 1:
NewMessage MACRO str ; Create a macro
ECHO str ; Echo contents from parameter
ENDM ; End of macro
NewMessage 'Hello!' ; Run macro
Example 2:
NewMessage MACRO str ; Create a macro
.IFNB {str} ; If not parameter is blank
ECHO str ; Echo contents from parameter
.ELSE ; ELSE
ECHO 'Is Blank!!!' ; ECHO Message if blank
.ENDIF ; ENDIF
ENDM
NewMessage 'Hello!' ; Run macro
NewMessage ; Run macro without parameter
Example 3:
TmyObj OBJECT name (val); Create an object
~~name&.Value = val ; Set value to global equate
ENDO
TmyObj myList (100) ; Run object
ECHO myList.Value ; Write value
Example 4:
mac1 MACRO par1 ; Create a macro
ECHO {par1} ; Echo "par1"
ECHO par1 ; Echo contents of "par1"
ENDM ; End of macro
mac1 'ABC...' ; Run macro
Example 5:
mac2 MACRO par2 ; Create a macro
newlabel&par2: ; Create a label
ENDM ; End of macro
mac2 x ; Run macro