| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Compiles a macro string into a PCode sequence.
HB_MacroCompile( <cMacro> ) --> cPCode
The function returns a characters string holding the PCode sequences of the compiled macro expression.
Function HB_MacroCompile() accepts a character string and compiles it into a PCode sequence. This, again, is a character string holding executable code, which is executed by passing it to function HB_VMExecute().
If <cMacro> is not a valid macro expression, a runtime error is raised.
| See also: | & (macro operator), Eval(), HB_VMExecute() |
| Category: | Indirect execution , xHarbour extensions |
| Source: | vm\macro.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example outlines two possibilities of calling a function
// indirectly via macro expression. The first compiles a macro
// to PCode, and the second creates a code block with the macro
// operator. Note that functions that are only included in macro
// expressions should be REQUESTed to make sure they are linked.
REQUEST QOut, Time
PROCEDURE Main
LOCAL cMacro := "QOut( Time() )"
LOCAL cPCode := HB_MacroCompile( cMacro )
LOCAL bBlock := &( "{||" + cMacro + "}" )
HB_VMExecute( cPCode )
EVal( bBlock )
RETURN
http://www.xHarbour.com