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

*

* StrToNum is called to convert "1222240" to 1222240 and

* "1222ABC40" to 1222.

*

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

 

#define TITLE_TEXT "StrToNum Example"

#define MSG_TEXT   "String:  %s\n\nNumber:  %d"

 

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

#include "Ifx.h"

 

export prototype ExFn_StrToNum(HWND);

 

function ExFn_StrToNum(hMSI)

    STRING szString, szMsg;

    NUMBER nVar;

begin

 

    // Convert a string with numeric characters to a number.

    szString = "1222240";

 

    if (StrToNum (nVar, szString) < 0) then

        MessageBox ("StrToNum failed.", SEVERE);

    else

        SprintfBox (INFORMATION, TITLE_TEXT, MSG_TEXT, szString, nVar);

    endif;

 

    // Convert string with non-numeric characters to a number.

    szString = "1222ABC40";

 

    if (StrToNum (nVar, szString) < 0) then

        MessageBox ("StrToNum failed.", SEVERE);

    else

        SprintfBox (INFORMATION, TITLE_TEXT, MSG_TEXT, szString, nVar);

    endif;

 

end;