StrLengthChars Example

InstallShield 2020 ยป InstallScript Language Reference

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

*

* InstallShield Example Script

*

* Demonstrates the StrLengthChars function.

*

* StrLengthChars 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 "StrLengthChars Example"

 

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

#include "Ifx.h"

 

export prototype ExFn_StrLengthChars(HWND);

 

function ExFn_StrLengthChars(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 = StrLengthChars (svString);

 

    if (nLength < 0) then

        MessageBox ("StrLengthChars failed.", SEVERE);

    else

        // Display the number of code units in the string.

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

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

    endif;

 

end;