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

*

* This script first creates a number list and then adds two

* numbers to it.  Next, the list is displayed in a dialog.

* ListSetCurrentItem is then called to update the value of

* the current element in the list.  Finally, this new list is

* displayed.

*

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

 

#define  MSG_TEXT   "Elements in listID:\n\n"

 

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

#include "Ifx.h"

 

export prototype ExFn_ListSetCurrentItem(HWND);

 

function ExFn_ListSetCurrentItem(hMSI)

    LIST   listID;

    NUMBER nItem, nvResult, nvItem;

    STRING szMsg, svItem;

begin

 

    // Create an empty 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 two numbers to the list.

    ListAddItem (listID, 1024, AFTER);

    ListAddItem (listID, 360, AFTER);

 

    // Disable the Back button in setup dialogs.

    Disable (BACKBUTTON);

 

        // Start building the message to report the numbers.

        szMsg = MSG_TEXT;

 

        // Get the numbers and add them to the message.

        nvResult = ListGetFirstItem (listID, nvItem);

        while (nvResult != END_OF_LIST)

            NumToStr (svItem, nvItem);

            szMsg = szMsg + svItem + "  ";

            nvResult = ListGetNextItem (listID, nvItem);

        endwhile;

 

        // Display the numbers.

        MessageBox (szMsg, INFORMATION);

 

    // Replace the value of the second item with a new value.

    if (ListSetCurrentItem (listID, 777) < 0) then

        MessageBox ("ListSetCurrentItem failed.", SEVERE);

    else

        // Start building the message to report the numbers.

        szMsg = MSG_TEXT;

 

        // Get the numbers and add them to the message.

        nvResult = ListGetFirstItem (listID, nvItem);

 

        while (nvResult != END_OF_LIST)

            NumToStr (svItem, nvItem);

            szMsg = szMsg + svItem + "  ";

            nvResult = ListGetNextItem (listID, nvItem);

        endwhile;

 

        // Display the numbers.

        MessageBox (szMsg, INFORMATION);

    endif;

 

    // Remove list from memory.

    ListDestroy (listID);

 

end;