Using Built-In Functions

InstallShield 2020 » InstallScript Language Reference

InstallShield has several hundred built-in functions that you can use in your setup scripts to create program groups and items, manipulate folders, work with lists, monitor the status of the setup, create dialogs, manipulate files, and much more. Because the InstallShield Script Compiler already recognizes these function names, you do not have to declare them before you can use them.

Learning About Function Names and Formats

In order call a built-in function, you must know both its name and its format.

To find a function that will fit your requirements, review Built-In Functions by Category, which describes each of the major categories of available functions. Click a category link to view a list of functions and descriptions that pertain to that category.

All of the built-in functions are listed alphabetically in the Built-in Functions sections. To display a complete description of any function in that list, click its name. The help topic for that function provides the function’s format.

For example, AskYesNo is a built-in function that displays a query in a dialog and then waits for the end user to respond by clicking a button, either Yes or No. AskYesNo has the following format:

AskYesNo (szQuestion, nDefault);

The format shows the correct spelling of the function name, which is followed by the function's parameter list, enclosed in parentheses. In the help topic for a built-in function, each parameter is expressed in Hungarian notation, which indicates the type of data that must be passed in that position. AskYesNo requires two parameters: the first parameter is a string; the second is a number.

Note:Like C, InstallScript is case sensitive. Be sure to pay close attention to the capitalization of letters in the built-in function names.

Using Built-In Functions in Your Script

To use a built-in function in your script, pass the required number of parameters, and make sure that the data you pass in each parameter is the type indicated for that position. If you pass the incorrect number of parameters, or if you pass the wrong type of data in any parameter positions, the script will not compile.

The specific documentation for each built-in function provides a description of its parameters. For AskYesNo, szQuestion is the question to be displayed in the dialog and nDefault indicates which button to preselect—Yes or No. One of two predefined constants can be passed in nDefault: YES or NO.

Consider a dialog in which the Yes button is preselected. To display this dialog, call AskYesNo as shown below:

AskYesNo ("Installation Complete. Would you like to view the ReadMe file now?", YES);

Note:String literals passed as parameters must be enclosed in single or double quotation marks, for example: “Please wait while files are transferred”, or 'This is a string', or “C:\\Myfolder\\Myfile.ext”.

Troubleshooting

Note the following:

InstallScript functions do not allow you to pass an assignment statement as a parameter. In addition, you cannot use the && or || operators within an argument to a function.
An autosized string variable that is passed by reference to a function will not be autosized within the called function. If the function attempts to assign a value whose length is greater than the current size of that parameter, run-time error 401 occurs. To avoid this error, declare strings with a specific size when they are to be passed by reference to a function.