MacroReturn
Posted: Sat Mar 11, 2006 10:38 am
Code: Select all
Macro test(a,b)
MacroReturn a+b
EndMacro
Debug test(1,2)
;which would equal:
Debug 1+2
Code: Select all
Macro test(a,b)
a+b
EndMacro
Debug test(1,2)
;which would equal:
Debug 1+2
Code: Select all
Macro test(a,b)
c=a+b
MacroReturn c
EndMacro
Debug test(1,2)
;which would equal:
c=1+2
Debug c
Code: Select all
Macro test(a,b)
c=a+b
MacroReturn c
c=a
MacroReturn c
EndMacro
Debug test(a,b)
;which would equal:
c=a+b
Debug c
so anything before it ends up inserted before the line with the test() macro call,
and what is on the same line as the MacroReturn will end up in-place
on the line where the macro is actually used.
Practical example:
Code: Select all
Macro LibraryFunctionAddress(Library,Function)
While NextLibraryFunction()
If LibraryFunctionName()=Function
*ptr=GetProcAddress_(LibraryID(Library),Function)
Break
EndIf
Wend
MacroReturn *ptr
EndMacro
#Somelib=0
OpenLibrary(#Somelib,"kernel32.dll")
Debug LibraryFunctionAddress(#SomeLib,"GetProcAddress")
;which would equal:
#Somelib=0
OpenLibrary(#Somelib,"kernel32.dll")
While NextLibraryFunction()
If LibraryFunctionName()="GetProcAddress"
*ptr=GetProcAddress_(LibraryID(#SomeLib),"GetProcAddress")
Break
EndIf
Wend
Debug *ptr
