|
#1
|
|||
|
|||
Upgrading from 5.7 to 6.2a and Nested Macros
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 |
#2
|
|||
|
|||
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/showthre...?threadid=1249 |
#3
|
|||
|
|||
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? |
#4
|
|||
|
|||
Sure -- create a project or global script function like this:
Code:
Function AppendShortName(macroName) AppendShortName = vbld_AllMacros().Item(macroName & vbld_AllMacros().Item("SHORTNAME").Value).Value End Function [AppendShortName("TESTPCUSERNAME")] -pw [AppendShortName("TESTPCPASSWORD")] "%BUILDDIR_RND%\Setup\*" [AppendShortName("TESTPC")]:[AppendShortName("TESTPCDIR" )] |
|
|