Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Upgrading from 5.7 to 6.2a and Nested Macros (https://www.kinook.com/Forum/showthread.php?t=2208)

jkeffer 12-20-2006 04:08 PM

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_%, 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 04: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/showthre...?threadid=1249

jkeffer 12-21-2006 08: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 09:34 AM

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

And then use like so:

[AppendShortName("TESTPCUSERNAME")] -pw [AppendShortName("TESTPCPASSWORD")] "%BUILDDIR_RND%\Setup\*" [AppendShortName("TESTPC")]:[AppendShortName("TESTPCDIR" )]


All times are GMT -5. The time now is 10:44 PM.


Copyright © 1999-2023 Kinook Software, Inc.