InstallShield 11 Universal » String Resolution
Descriptions of, instructions for using, and examples of the following string resolver methods are provided below:
In order to achieve project portability to more than one build machine, InstallShield supports path variables for bean properties that store paths to files or directories on the build machine. A path variable is a build-time string resolver that, when resolved, performs a token replacement of the path variable's specification string in the property value with the value that you assigned to it. You can create as many path variables as you need for maximum flexibility.
A path variable is specified using the following syntax:
$A(pathVariableName)
Where
$A(IS_HOME) is a predefined path variable for the directory where InstallShield Universal is installed. Therefore, a value like $A(IS_HOME)/images resolves at build time to, for example, /opt/InstallShieldX/images.
The $D() string resolver provides the means to utilize a variable that resolves to the appropriate directory name on each targeted platform. This resolver has the following format:
$D(directoryName)
Where directoryName can be any of the following named directories, which are resolved for each targeted platform (for a list of the default directories on each supported platform, see Named Directories & Platform Pack Resolution):
| Named Directory | Description | install | Default installation location for each targeted platform |
|---|---|
| temp | Local system temporary directory for each targeted platform |
| lib | Local system library directory for each targeted platform |
| home | Current end user's home directory for each targeted platform |
| log | Local system's log directory for each targeted platform |
| os_main Windows Platforms only |
Local Windows operating system main directory |
| common Windows Platforms only |
Directory where common files shared by multiple vendors should be installed |
Examples of how to specify a named directory variable are as follows.
The following sample code resolves to the installation home directory on each targeted platform. For example, it resolves to C:\Program Files\ on Windows and /opt on Linux.
$D(install)
To resolve this string in a custom bean, you would type the following:
String str = resolveString("$D(install)");
To resolve to the local system library level, specify the string resolver method as follows:
$D(lib)
The above example resolves to the C:\WINNT\System32 directory on Windows 2000, and /usr/lib on Solaris.
The $E() string resolver can be used to access the environment variable settings on the target machine. This resolver has the following format:
$E(PATH)
--OR--
$E(ENV_VAR_NAME)
where PATH would be the name of a path environment variable, either user or system, and ENV_VAR_NAME would be the name of the environment variable other than a path. The environment variable specification is case-sensitive.
Examples of how to specify an Environment string resolution variable are as follows.
To resolve to the target machine's Path, specify the string resolver method as follows:
$E(PATH)
This example could resolve to, for example, on a Windows system:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\wbem;
C:\j2sdk1.4.0;C:\j2sdk1.4.0\bin
The environment variable name specified can be any environment variable that is set on the target machine. For example, to resolve to the target machine's system-defined TEMP variable, specify the string resolver method as follows:
$E(TEMP)
This example could resolve to, for example on a Linux machine:
/user/tmp
The $J() string resolver provides the means to access Java properties on the target machine (for a list of predefined properties, see the Java Web site at http://java.sun.com). You can also create custom Java properties using System.setProperty and then resolve them later with $J(). This resolver has the following format:
$J(javaPropertyName)
Where javaPropertyName is one of the predefined Java properties.
Examples of how to specify a Java system property variable are as follows.
To resolve to the end user's home directory, specify this string resolver as follows:
$J(user.home)
To resolve to the working directory where the installation was launched on the end user's machine, specify this string resolver as follows:
$J(user.dir)

This string resolves to the Temp directory if the installation was launched from a CD-ROM. In that case, you can use the InstallShield-defined Java system property is.external.home. Using is.external.home to determine the working directory can only be used with installations that were launched using the platform-specific native launcher, for example, setup.exe on Windows. You need to check that the value is not null before using it. For more information, see Knowledge Base Article Q105887 "HOWTO: Getting the CD-ROM Drive When the Setup is Launched From a CD-ROM."
User-defined system properties can also be resolved. For example:
String str = resolveString("$J(java.home)");
// predefined Java system property
String str2 = resolveString("$J(wizard.home)");
// user-defined Java system property
The $L() string resolver resolves to the locale either selected by the end user or the system locale of the target machine. It provides the means to display information in the appropriate language to the end user at run time. This resolver has the following format:
$L(resourceBundle,resourceKey{, resourceArgument})
The Localized resolver string must include both the resourceBundle and resourceKey. It can have zero or more resourceArguments. For example:
String str = resolveString("$L(com.installshield.product.i18n
.ProductResources, Files.replaceExistingFile)");
String str2 = resolveString("$L(com.installshield.product.i18n
.ProductResources, Files.installError, myFile.java)");
The $N() string resolver takes one or two arguments, and then normalizes the specified path with the optional specified path separator. On all platforms, $N returns the normalized canonical path. This resolver has the following format:
$N(<path>, <optional path separator>)

".." indicates to go up one directory, and "." indicates the current directory.
On Windows platforms:
$N(C:/dir1\dir2) resolves to C:\dir1\dir2
$N(C:\dir1\dir2, /) resolves to C:/dir1/dir2
$N(C:\test\..\test) resolves to C:\test
On UNIX platforms:
$N(/usr/bin/../bin/.) resolves to /usr/bin
$N(C:\test\..\test, /) resolves to C:/test
This string resolver can also be nested. For example, $N($D(install), /) on Windows platforms, resolves to C:/Program Files.
The $P() string resolver provides the means to obtain the value of a Product bean property. This resolver has the following format:
$P(beanID.productBeanPropertyName)
Where
If no beanID is specified, then the Bean ID of the root product is used by default.
Below is an example of resolving the Install Location of a specific Feature:
$P(feature1.installLocation)

The value of $P(installLocation) can be changed if the user changes the installation location via a Destination dialog. To ensure that the actual installation location of the bean is found, use $P(beanId.absoluteInstallLocation), which resolves to the exact location to which the bean was installed. If, however, the resolved location could be the root path, use the $PATH string resolver instead (described below) as follows:
$PATH($P(absoluteInstallLocation))
--OR--
$PATH($P(appFiles.absoluteInstallLocation), MyApp)

The $P string resolver can also be used for a Shortcut that executes an application Launcher for a Java application and targets multiple platforms. Type the following (instead of clicking the ellipsis) for the Standard Target property of the Shortcut, which dynamically resolves to the executable file name for each targeted platform at run time:
$P(<beanId>.installedFileName)
where beanId is the Bean ID property value of the Launcher, and installedFileName is a read-only property that is populated after the bean executes. The installedFileName property resolves to the appropriate File Name property of the Launcher bean for each targeted platform.
The $PATH() string resolver ensures that the resolved path does not end in a separator, and uses the normalized path separator that is appropriate for the target machine. Therefore, if either (or both) arguments contain a mixture of "\" and "/" as separators, the resolved string converts them to the appropriate separator for the target machine.
This resolver has the following formats:
$PATH(context)
--OR--
$PATH(context, fileName)
Where
If no fileName is specified, then the specified context location is returned with the path separator normalized. It appends fileName (if specified) to the context providing the appropriate separator between them if it was not already specified. If fileName is absolute, then the normalized version of fileName is returned. The resolved string never ends in a trailing separator unless it is the root path.
Specifying
"$PATH($D(install), InstallShield/Universal)"
resolves on Windows platforms to
C:\Program Files\InstallShield\Universal
and on UNIX platforms to
/opt/InstallShield/Universal

When using string resolution to provide an absolute path, always enclose it in double quotes because the end user could install the product to a path that contains spaces.
This string resolver solves the problem with using $W and $P when the root path is used. For example, if you have an expression like $P(absoluteInstallLocation)/MyDir, and the installation location happens to be the root path, then the resolved string on Windows platforms is C:\MyDir. If you specify instead
$PATH($P(absoluteInstallLocation), MyDir)
then the resolved string is C:\MyDir, which is what you would expect.
The $V() string resolver provides the means to obtain the value of a Variable property (for example, a control in a dialog, the exit code and/or output of an Execute Process action, etc.).
This resolver has the following format:
$V(VariableName)
Where VariableName is the name of the variable being referenced.
The following example returns the value of the Variable field in a Text control in a dialog. The Name property of the variable is textField1:
$V(textField1)

A variation of this variable (-V versus $V()) can be used to set the value of a variable on the command line and/or in a response/options file. See Variable Command Line Option for details.
The $W() string resolver provides the means to obtain the value of a wizard bean property. This resolver has the following format:
$W(beanID.propertyName)
Where
With wizard beans, the Bean ID must be specified.
Below is an example of resolving a wizard bean property value in an Install Check dialog.
$W(check.active)
Where
To obtain the value of a property in a wizard bean from a custom wizard bean in the Installation Sequence of a Universal Dynamic Suite, get an instance of the required wizard bean in the sequence of the assembly as follows:
MyBean mb = (MyBean)getWizard().getExternalWizard("assemblies/abcd3948fjKK338844JHRO30284839JE/1.0.0/assembly.dat")
.getWizardTree().findWizardBean("beanId")
Where
In the example above, MyBean is the class name for the type of wizard bean from which you need to get the property value(s).
Once you have an instance of the wizard bean "MyBean," you can then directly call the get method for the property in question. For example:
String myProperty = mb.getMyProperty();
See Also
String Resolution
String Comparison Conditions
Command Line Options
Locating Localized Strings