Assignment Operator

InstallShield 2019 » InstallScript Language Reference

Use the assignment operator ( = ) to copy a constant, literal, variable, expression result, or function result to a variable of the same type, as shown in the example code fragment below:

    STRING szName;

    LONG nValue;

    BOOL bDone;

    HWND hInstance;

    INT  iStyle;

    LIST LISTINFO;

 

    szName = "InstallShield";

    nValue = 15;

    bDone = FALSE;

    hInstance = 0;

    iStyle = DLG_MSG_STANDARD|DLG_CENTERED;

 

    LISTINFO = ListCreate(STRINGLIST);

InstallShield automatically sizes string variables that are declared without an explicit length, as in the example above. By default, InstallShield autosizes the string variable to 256 bytes. If you assign to that variable a string longer than 256 bytes (including the null terminator), InstallShield increases the amount of memory reserved for that string variable.

If you declare a string variable with an explicit length, you must make it long enough to receive the string you assign to it. In the example below, the string literal contains 51 characters. Therefore, both szStringVarA and szStringVarB must have a declared length of at least 52, which is just large enough to accommodate the string itself and the null terminator that is added automatically to the end of the string.

    STRING szStringVarA[52], szStringVarB[52];

    szStringVarA = "This is a sample string that is 51 characters long.";

    szStringVarB = szStringVarA;

Caution • Unlike C++, InstallScript does not support multiple assignment operations in a single statement. In InstallScript, the statement a = b = c is equivalent to the C++ statement a = b == c. That is, the first operator is interpreted as an assignment operator; the second is interpreted as a relational operator. If b is equal to c, the value 1 (TRUE) is assigned to a; if b is not equal to c, the value 0 (FALSE) is assigned to a.