StrFind 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 StrFind function.

*

* StrFind is called to search for a substring within a string.

* If successful, StrFind returns the location of the substring.

*

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

 

#define TITLE_TEXT "StrFind Example";

 

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

#include "Ifx.h"

 

export prototype ExFn_StrFind(HWND);

 

function ExFn_StrFind(hMSI)

    STRING szString, szFindMe, szTitle, szMsg;

    NUMBER nLocation;

begin

 

    // Set up parameters for call to StrFind.

    szString = "This is a sample string to be searched.";

    szFindMe = "Sample String";

 

    // Find the substring specified by szFindMe.

    nLocation = StrFind (szString, szFindMe);

 

    // Display the location of the text if it was found.

    if (nLocation < 0) then

        MessageBox (szFindMe + " not found in " + szString + ".", WARNING);

    else

        szMsg    = "'%s' starts at byte %d of\n'%s'";

        SprintfBox (INFORMATION, szTitle, szMsg, szFindMe, nLocation, szString);

    endif;

 

end;