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

*

* StrLength is called to retrieve the number of characters in a

* string that an end user enters. The number of characters is

* displayed in a message box.

*

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

 

#define TITLE_TEXT "StrLength Example"

 

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

#include "Ifx.h"

 

export prototype ExFn_StrLength(HWND);

 

function ExFn_StrLength(hMSI)

    STRING svString, szTitle, szMsg;

    NUMBER nLength;

begin

 

    // Get a line of text from the end user.

    AskText ("Enter a line of text. ", "", svString);

 

    // Get the number of characters in the string.

    nLength = StrLength (svString);

 

    if (nLength < 0) then

        MessageBox ("StrLength failed.", SEVERE);

    else

        // Display the string length.

        szMsg    = "String '%s' is %d characters long.";

        SprintfBox (INFORMATION, TITLE_TEXT, szMsg, svString, nLength);

    endif;

 

end;