# Testing various procedures
# --------------------------
#
#  Syntax: rep_proc input_dir output_dir
#   
#  Example: rep_proc data output
#
$debug 1
$indent
$goto continue {%0% >= 2}
    $show Syntax: rep_proc input_dir output_dir
    $show Syntax error. Report aborted.
    $return
$label continue

$define input_dir %1%
$define output_dir %2%
# Define output destination
# -------------------------
$PrintDest %output_dir%\rep_proc.a2m A2M

# ----------------------------------------------------------
# printtbl: prints a list of variables on a specific period
$procdef printtbl year vars
    $foreach var %vars%
        %var%[%year%] = {%var%[%year%]}
    $next var
$procend

# ----------------------------------------------------------
$ sumvars: creates a new series names %result% = sum of %vars%
$procdef sumvars result vars
    $define eq 0
    $foreach var %vars%
        $define eq %eq% + %var%
    $next var
    $DataCalcVar %result% %eq%
$procend

# ----------------------------------------------------------
$ sumvarsmsg: displays msg, then calls sumvars result vars
$procdef sumvarsmsg msg result vars
    %msg%
    $ During the call : result = '%result%' vars = '%vars%'
    $procexec sumvars %result% %vars%
    %result%[1992Y1] = {%result%[1992Y1]}
$procend

$WsSample 1990Y1 2000Y1
$DataCalcVar PIB_A t
$DataCalcVar PIB_B ln t
$DataCalcVar PIB_C sin(t)
$procexec sumvarsmsg "Hello IODE!" PIB PIB_A PIB_B
$procexec sumvarsmsg "Hello World" PIB3 PIB_A PIB_C
$procexec printtbl 1992Y1 PIB_A PIB_B PIB_C PIB PIB3

# Load objects
# ------------
$WsLoadCmt %input_dir%\fun
$WsLoadEqs %input_dir%\fun
$WsLoadIdt %input_dir%\fun
$WsLoadLst %input_dir%\fun
$WsLoadScl %input_dir%\fun
$WsLoadTbl %input_dir%\fun
$WsLoadVar %input_dir%\fun

$procdef print_eq eqs
.par1 tit_1 Equations with coefficients
    $PrintObjLec 1
    $foreach eq %eqs%
        $PrintObjDefEqs %eq%
    $next eq    
$procend 
$procexec print_eq ACAG ACAF