How I can check validity of a macro ?

PROC MAIN()

    nResult   := NIL
    nDivident := 1
    nDivisor  := 0
    cMacro    := " nResult := nDivident / nDivisor "  
    QOutResult( nDivident, nDivisor, cMacro ) // 1  0  UE macro is inValid

    nDivisor  := 2
    QOutResult( nDivident, nDivisor, cMacro ) // 1  2  N  Result is :  0.50

    cMacro    := "AT( 'OK', MyUDF() ) > 0"              
    QOutResult( 'AT( OK', 'MyUDF()', cMacro ) // AT( OK ... U macro is inValid

    cMacro    :=  "{ 1, 2 }[ 2 ]"                       
    QOutResult( '{ 1, 2 }', '[2]', cMacro ) // { 1, 2 } [2]   N Result is : 2

    cMacro    :=  "{ 1, 2 }[ 5 ]"  
    QOutResult( '{ 1, 2 }', '[5]', cMacro ) // { 1, 2 } [5] UE macro is inValid

    lCond := 0
    cMacro    :=  "if( lCond, 'true', MyUDF() )"
    QOutResult( lCond, '', cMacro )           // 0        U macro is inValid   
    ?
    WAIT

RETU // Main()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

PROC QOutResult( xVal1, xVal2, cMacro )

	LOCAL cType := TYPE( cMacro )

	? PAD( xVal1, 10 ), PAD( xVal2, 10 ),  PAD( cType, 3 )

    IF ( cType # "U") 
       ?? "Result is :", &cMacro
    ELSE
       ?? "macro is inValid"
    ENDIF

RETU // QOutResult()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._

See Also:

& (macro evaluation unary) Operator 

Macro Compiler

HB_SetMacro()

ValType()

TYPE()

C5_TYPE()

Advertisements

One response to “How I can check validity of a macro ?

  1. Pingback: How I Can Do … | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s