xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_MacroCompile()

Compiles a macro string into a PCode sequence.

Syntax

HB_MacroCompile( <cMacro> ) --> cPCode

Arguments

<cMacro>
This is a character string holding a macro expression to compile.

Return

The function returns a characters string holding the PCode sequences of the compiled macro expression.

Description

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.

Info

See also:& (macro operator), Eval(), HB_VMExecute()
Category: Indirect execution , xHarbour extensions
Source:vm\macro.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe