ListCurrentItem Example

InstallShield 2015 ยป 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 ListCurrentItem function.

*

* This script adds three numbers to a list and then retrieves

* and displays the value of the current list item.

*

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

 

#define TITLE_TEXT "ListCurrentItem Example"

    

 

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

#include "Ifx.h"

 

export prototype ExFn_ListCurrentItem(HWND);

 

function ExFn_ListCurrentItem(hMSI)

    STRING szMsg;

    LIST   listID;

    NUMBER nItem;

begin

 

    // Create the number list.

    listID = ListCreate (NUMBERLIST);

 

    // If an error occurred, report it; then terminate.

    if (listID = LIST_NULL) then

        MessageBox ("Unable to create list.", SEVERE);

        abort;

    endif;

 

    // Add the numbers 100, 200, and 300 to the list.

    for nItem = 100 to 300 step 100

        ListAddItem (listID, nItem, AFTER);

    endfor;

 

    // Get the current element from the number list.

    if (ListCurrentItem (listID, nItem) < 0) then

        MessageBox ("ListCurrentItem failed.", SEVERE);

    else

        // Report the value of the current item.

        szMsg = "Value of current element in list: %d";

        SprintfBox (INFORMATION, TITLE_TEXT, szMsg, nItem);

    endif;

 

end;