PDA

View Full Version : Accessing macro array elements


Tony2
01-15-2014, 02:36 PM
Hi all

So I have a step which reads a file using a regex and matches 4 groups.
I have the option "Store matching groups in array"
And the macro it is going in is named DATABASE

If I log %DATABASE% to the output then I get 4 lines containing the information.
I need to be able to access each element individually so that I can run a command line putting the right elements in the right places....

How do I do this, I can't find anything on accessing a macro array in the help....

Thanks

kinook
01-15-2014, 02:52 PM
See the attached sample for how to access via a Loop action or Run Script action.

Tony2
01-15-2014, 03:10 PM
Thanks..

So no way to do %macro[1]% or something? I'm already in a loop so would now have nested loop and another 4 macros....

I'm almost thinking of having 4 different steps each matching one of the four groups I currently have. Would look less messy.

kinook
01-15-2014, 03:20 PM
Define a project or global script function like so:

Function ArrayElem(name, index)
a = vbld_TempMacro(name)
ArrayElem = a(index)
End Function

and call like this in a Run Script step:

Builder.LogMessage ArrayElem("DATABASE", 0)

or like this in a field:

[ArrayElem("DATABASE", 0)]

http://www.kinook.com/VisBuildPro/Manual/scripteditor.htm
http://www.kinook.com/VisBuildPro/Manual/scriptexpressions.htm