PDA

View Full Version : Low level macros enhanced



Charles Pegge
21-08-2009, 18:30
Macro Block Parameters

Pass block of data as single parameter: (enclosing the data between brackets)




Oxygen Update http://community.thinbasic.com/index.php?topic=2517



'
'------------------
'MACRO BLOCK PARAMS
'==================


uses "oxygen","file"
dim src as string
src="
#basic
'
def pr print %1

pr `Hello`
pr ( `Hello` ` ` `Sky!` )
pr ( 21*2 )
terminate
"


'msgbox 0,o2_prep src
o2_basic src
if len(o2_error) then msgbox 0,o2_error
o2_exec

Charles Pegge
21-08-2009, 18:43
Families of Macros with dotted names.

Related macros can be bunched together - like methods the individual routines are referenced by dotted names. The macro members are defined inside the group macro.



'
'--------------
'MACRO FAMILIES
'==============


uses "oxygen","file"
dim s as string
s="
#basic

def mac
(
.hello
(
print `hello %1`
)
.goodbye
(
print `goobye %1`
)
)

mac.hello fred
mac.goodbye fred
terminate

"


'msgbox 0,o2_prep s
o2_basic s
if len(o2_error) then msgbox 0,o2_error
o2_exec