View Full Version : Upgrading from 5.7 to 6.2a and Nested Macros
jkeffer
12-20-2006, 05:08 PM
I'm attempting to upgrade from version 5.7 to version 6.2a and I'm having a problem with nested macros. I have the following:
%%["TESTPCPASSWORD"+"%SHORTNAME%"]%%
Previously, it would evaluate to %TESTPCPASSWORD_<value of SHORTNAME>%, which would then be evaluated. For example, if SHORTNAME evaluated to XYZ, the macro to be evaluated would be %TESTPCPASSWORD_XYZ% which would then be evaluated itself.
I can get to the stage of %TESTPCPASSWORD_XYZ%, but this does not get evaluated.
How do I structure this to get it to work for 6.2a?
Julia
kinook
12-20-2006, 05:37 PM
It was actually a bug (in versions prior to 6.2) that %% was not treated as a literal % character when the field also contained a script expression. See here for other ways to achieve this (which work in all versions of VBP):
http://www.kinook.com/Forum/showthread.php?threadid=1249
jkeffer
12-21-2006, 09:56 AM
Isn't there an easier way to do this? I use a lot of nested macros in statements in the scripts that look like this:
"%UTILSPATH%\pscp.exe" -q -1 -r -l %%["TESTPCUSERNAME"+"%SHORTNAME%"]%% -pw %%["TESTPCPASSWORD"+"%SHORTNAME%"]%% "%BUILDDIR_RND%\Setup\*" "%%["TESTPC"+"%SHORTNAME%"]%%:%%["TESTPCDIR"+"%SHORTNAME%"]%%"
As you can see, I'm combining the %SHORTNAME% macro with a number of different strings. If I use a solution as suggested, this would look like:
"%UTILSPATH%\pscp.exe" -q -1 -r -l %% [vbld_AllMacros().Item("TESTPCUSERNAME" & vbld_AllMacros().Item("SHORTNAME").Value).Value] -pw [vbld_AllMacros().Item("TESTPCPASSWORD" & vbld_AllMacros().Item("SHORTNAME").Value).Value] "%BUILDDIR_RND%\Setup\*" [vbld_AllMacros().Item("TESTPC" & vbld_AllMacros().Item("SHORTNAME").Value).Value]:[vbld_AllMacros().Item("TESTPCDIR" & vbld_AllMacros().Item("SHORTNAME").Value).Value]
This is not very readable. Creating additional macros to contain the values before using them in a statement like the above defeats the purpose of nesting them in the first place.
Are there any other options?
kinook
12-21-2006, 10:34 AM
Sure -- create a project or global script function like this:
Function AppendShortName(macroName)
AppendShortName = vbld_AllMacros().Item(macroName & vbld_AllMacros().Item("SHORTNAME").Value).Value
End Function
And then use like so:
[AppendShortName("TESTPCUSERNAME")] -pw [AppendShortName("TESTPCPASSWORD")] "%BUILDDIR_RND%\Setup\*" [AppendShortName("TESTPC")]:[AppendShortName("TESTPCDIR" )]
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.