Hi Justin,
My take:
Macros are not procedures/functions/etc. They are code blocks that PureBasic "copies" and "pastes" into place when it encounters the macro name elsewhere in the code.
The "parameters" in the macros are placemarkers that are further replaced by the parameters encountered where the macro is used.
Everything is text.
So:
Is really saying to PureBasic: When you see "AddOne" in the code, then:
Further, where you see "a" in the macro,
- Replace it with the "parameter" value supplied by the macro placemarker.
Manually done, we would copy some code, paste it elsewhere, change a few bits.
So in code:
Any "AddOne(z)" becomes "z+1". It is like an automatic copy/paste with bells on. It saves retyping repetitive code, and gives the macro name a temporary importance or keyword status in the code containing the macro. But it is not a procedure in and of itself.
Another Eg:
Code: Select all
Macro AddToList(myList)
AddElement(myList())
EndMacro
...
AddToList(things)
becomes
And then PureBasic compiles it.
@}--`--,-- A rose by any other name ..