StrCompare Example

InstallShield 2020 ยป InstallScript Language Reference

Note:To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.

/*--------------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the StrCompare function.

*

* StrCompare is called to compare two strings.  The result of

* the comparison is displayed in a message box.

*

\*--------------------------------------------------------------*/

 

#define TITLE_TEXT "StrCompare Example"

#define MSG_TEXT   "Please enter two strings to compare:"

#define FIELD_A    "String A:"

#define FIELD_B    "String B:"

 

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

 

export prototype ExFn_StrCompare(HWND);

 

function ExFn_StrCompare(hMSI)

    STRING svStringA, svStringB;

    NUMBER nResult;

begin

 

    // Get two strings from the user.

    SdShowDlgEdit2 (TITLE_TEXT, MSG_TEXT, FIELD_A, FIELD_B, svStringA, svStringB);

 

    // Compare the strings.

    nResult = StrCompare (svStringA, svStringB);

 

    // Display the result.

    if (nResult = 0) then

        MessageBox (svStringA + " and " +  svStringB + " are equal.", INFORMATION);

    elseif (nResult < 0) then

        MessageBox (svStringB + " is greater than " + svStringA, INFORMATION);

    else

        MessageBox (svStringA + " is greater value than " + svStringB, INFORMATION);

    endif;

 

end;