Thinking of buying PureBasic but have some questions :)

Everything else that doesn't fall into one of the other PB categories.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Thinking of buying PureBasic but have some questions :)

Post by Danilo »

tastyraspberry wrote:@danilo
Haven't quite got my head around the macro way yet. I'm sitting here tinkering away today so I am sure I can work it out later.
Easy. Every macro parameter is just text replaced with its argument.
If '#' is used, the text is merged/consolidated/concatenated.

Code: Select all

Macro Value(_theValue_)
    Debug _theValue_
EndMacro

Value(12) ; = Debug 12
Value(x)  ; = Debug x
x=5
Value(x)  ; = Debug x = Debug 5

Macro DQ
"
EndMacro

Macro Concat(_type_)
    Procedure _DebugType_#_type_()
        Debug DQ#_type_#DQ    ; debug "_type_"
    EndProcedure
    _DebugType_#_type_()
EndMacro

Concat(l) ; creates procedure _DebugType_l and calls _DebugType_l
Concat(i) ; creates procedure _DebugType_i and calls _DebugType_i
Concat(s) ; creates procedure _DebugType_s and calls _DebugType_s
Post Reply