ListGetFirstItem 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 ListGetFirstItem and ListGetNextItem

* functions.

*

* This script starts by creating a number list and adding

* three numbers to it.  ListGetFirstItem is called then to get

* the first number from the list.  This call also makes the

* first number the current element.  A loop process follows to

* display the number retrieved from the list and then call

* ListGetNextItem to get the next number.  The loop executes

* until ListGetFirstItem or ListGetNextItem reaches the end

* of the list.

*

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

 

#define TITLE_TEXT "ListGetFirstItem & ListGetNextItem"

 

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

#include "Ifx.h"

 

export prototype ExFn_ListGetFirstItem(HWND);

 

function ExFn_ListGetFirstItem(hMSI)

    STRING szMsg;

    LIST   listID;

    NUMBER nvItem, nResult;

begin

 

    // Create a 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 three numbers to the list.

    ListAddItem (listID, 1024, AFTER);

    ListAddItem (listID, 360, AFTER);

    ListAddItem (listID, 777, AFTER);

 

    // Get the first number from the list.

    nResult = ListGetFirstItem (listID, nvItem);

 

    // Loop while not at end of list.

    while (nResult != END_OF_LIST)

        // Display the number retrieved from the list.

        SprintfBox (INFORMATION, TITLE_TEXT, "%i", nvItem);

 

        // Get the next number from the list.

        nResult = ListGetNextItem (listID, nvItem);

    endwhile;

 

    // Remove the list from memory.

    ListDestroy (listID);

 

end;