Daniel Dan - 2013-11-04

VCL Processor Variables and Functions

In VCL 1.1 we introduce the following VCL processor variables and functions.

  • Processor variables:

    • $currentfile - The currently processed file
    • $outputfile - The currently used output file
    • $outputdir - The currently used output directory
    • $defaultoutput - The default output given by command line argument or by running the processor with default values.
    • $debugmode - true if the VCL Processor is in debug mode. Can be set by command line argument or in VCL code
  • Processor funcitons:

    • $isFirst(<Multi-var>) - true if <Multi-var> is currently in the first iteration
    • $isLast(<Multi-var>) - true if <Multi-var> is currently in the last iteration
    • $size(<Var>) - number of elements in <Var>, if is not Multi-var the result is 1
    • $isNumeric(<Var>) - true if <Var>'s current value is numeric

Example 1:

#set modules = "Mod1", "Mod2"

#while modules
    #vcl.if ($isfirst(modules))
        //init code
    #vcl.endif

        // module -->
        ?@modules?
        // <--

    #vcl.if ($islast(modules))
        //closing code
    #vcl.endif
#endwhile

output:

    //init code

    // module -->
    Mod1
    // <--

    // module -->
    Mod2
    // <--

    //closing code

Example 2:

~~~~~~~~~~~~~~~~~~~~~~~~

set variables = "first", "second", "third", "fourth", "fifth"

vcl.if $debugmode

Default output is: ?$defaultoutput?
Current file is: ?$currentfile?
Current output is ?$outfile?
Changing output to ?$outdir?"\out2.txt"
--

output ?$outdir?"\out2.txt"

Current output dir is: ?$outdir?
Current output is ?$outfile?
back to ?$defaultoutput?

output ?$defaultoutput?

Back at ?$outfile?

vcl.endif

Number of variables: ?$size(variables)?

while variables

#vcl.if $isfirst(variables)

( ?@variables?,

#vcl.endif
#vcl.if ($islast(variables) == false && $isfirst(variables) == false)

?@variables?,

#vcl.elif ($islast(variables))

?@variables? )

#vcl.endif

endwhile

out2.txt:

Current output dir is: D:\VCLCode
Current output is D:\VCLCode\out2.txt
back to D:\VCLCode\defaultOutput.txt

defaultOutput.txt

Default output is: D:\VCLCode\defaultOutput.txt
Current file is: D:\VCLCode\testInput.txt
Current output is D:\VCLCode\defaultOutput.txt
Changing output to D:\VCLCode\out2.txt
--
Back at D:\VCLCode\defaultOutput.txt

Number of variables: 5

( first,

second,

third,

fourth,

fifth )

~~~~~~~~~~~~~~~~~~~~~~~~~

 

Last edit: Daniel Dan 2013-11-06