MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: Formatted Strings[Next]: Square Brackets - Escaping
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Windows Installer FAQ (the basics)->Formatted Strings->$$WI_FMT PPWIZARD Transformation for Commands

$$WI_FMT PPWIZARD Transformation for Commands

If you wanted to create a shortcut where either the "target" or "arguments" contains "[" or "]" (left or right square brackets), but not for intentional Windows Installer formatting) then this ppwizard transformation is probably the best way to handle it.

The following "Shortcut" command's fragment will fail:

<$Shortcut Arguments='//NoLogo "[INSTALLDIR]Something[SquareCharsBeforeAndAfterCanBeMisInterpreted].vbs"' ...>

This one using the transformation will not fail (as it escapes any square brackets it finds):

#define  VBSNAME  Something[SquareCharsBeforeAndAfterCanBeMisInterpreted].vbs
<$Shortcut Arguments='//NoLogo "[INSTALLDIR]<$VBSNAME $$WI_FMT>"' ...>

The above allows you to automatically apply the transformation, for example "VBSNAME" might be used a number of times and its value may vary but the value will always be correctly formatted, if you don't mind manually doing it (perhaps the VBS is not referred to anywhere else) then this is how I'd do it for readability and reliability (the codes are quite cryptic and would be easy to get wrong):

<$Shortcut Arguments='//NoLogo "[INSTALLDIR]Something<$LSB>SquareCharsBeforeAndAfterCanBeMisInterpreted<$RSB>.vbs"' ...>

MAKEMSI CODE

The transformation's MAKEMSI definitions:

;----------------------------------------------------------------------------
;--- Define the "$$" transformation "$$WI_FMT" ------------------------------
;----------------------------------------------------------------------------
;    SEE:
;         1. http://makemsi-manual.dennisbareis.com/formatted_strings.htm
;         2. http://dennisbareis.com/ppwizard/dd_qm.htm
;----------------------------------------------------------------------------
#define  LSB  [\[]        ;;[
#define  RSB  [\]]        ;;]
#DefineRexx "REXX_$$WI_FMT"
    ;--- Swap the problematic characters with pacemarkers -------------------
    @@LSB_PM = "{@@LSB}"
    @@RSB_PM = "{@@RSB}"
    TheValue = ReplaceString(TheValue, '[',      @@LSB_PM);
    TheValue = ReplaceString(TheValue, ']',      @@RSB_PM);

    ;--- Replace the place markers with the codes ---------------------------
    TheValue = ReplaceString(TheValue, @@LSB_PM, '<$LSB>');
    TheValue = ReplaceString(TheValue, @@RSB_PM, '<$RSB>');
#DefineRexx


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Formatted Strings[Next]: Square Brackets - Escaping


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Friday October 13 2017 at 2:08pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.