PDA

View Full Version : How do you pass a value to a macro using vbscript?


ambalboa
06-28-2007, 04:22 PM
I am trying to set a value for a macro using the Run Script action. I know how to pass a value from a macro to a variable, as in:

Set m = vbld_AllMacros()("VER_NUM") or

m = "%VER_NUM%

But now I want to do the opposite. I want (and I'm able) to get the version number of a file, but how do I pass that value to a macro? Let's assume the macro already exist. If the macro already has a version number stored in it, I would like to overwrite it. Does anyone know how to do this? Thanks in advance.

kinook
06-28-2007, 04:29 PM
http://www.visualbuild.com/Manual/scriptsample.htm

ambalboa
07-02-2007, 12:22 PM
Thank you.

I looked at the example and this is what I came up with. I am using two 'Run Script' action steps. The first one gets the version number of a file and set it to the project macro VER_NUM, as shown below.

Set objMacro = Application.Macros(vbldProject).Item("VER_NUM")

objMacro.Value = vbld_FSO.GetFileVersion("path")

The second step gets that number and increments it; both steps are simple.

I have to use two steps because when I check to see if the previous version number was overwritten after the first step is build, the macro still has the old version number. However, I only call the macro on the second step, and it increments it, that being the new retrieved number. Even though the old number is shown after the first step is build, in reality, the new number replaced it, right? Is there a one step delay in this process? Will the new number be displayed on the macros and output pane once a 'Run Script" step using that macro is ran again? Because that's what's happening.

I also combined the two, and now the macro value is updated on the macros pane, but when it logs the message on the output pane, is still displays the old version number. Is there a way around this?

Thank you for your help.

kinook
07-02-2007, 12:30 PM
The macro is updated immediately; the sample demonstrates retrieving and updating in the same step. You may have a temporary macro with the same name defined, which overrides the project macro value.
http://www.visualbuild.com/Manual/macrostab.htm

Otherwise, please ZIP and send or post:
1) The info from Help | About | Install Info
2) The .bld file demonstrating the problem
3) A build log file

Thanks.