InstallShield 2016 » 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 ListDeleteItem function.
*
* This script first creates a list of numbers and prompts the
* user for a number to delete. Then ListFindItem is called to
* make the selected number the current item. Next,
* ListDeleteItem is called to delete the selected number from
* the list. Finally, the numbers remaining in the list are
* displayed.
*
\*--------------------------------------------------------------*/
#define TITLE_TEXT "ListDeleteItem Example"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_ListDeleteItem(HWND);
function ExFn_ListDeleteItem(hMSI)
STRING svItem, szMsg;
LIST listID;
NUMBER nvItem, nvResult;
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 1, 2, 3, and 4 to the list.
for nvItem = 1 to 4
ListAddItem (listID, nvItem, AFTER);
endfor;
repeat
// Disable the Back button.
Disable (BACKBUTTON);
// Prompt user to select a number to delete.
if AskText ("The numbers 1, 2, 3, and 4 have been added to a list.\n"+
"Select one of those numbers to delete.", "", svItem)then
endif;
// Convert the value from string data to a number data.
nvResult = StrToNum (nvItem, svItem);
if (nvItem < 1) || (nvItem > 4) then
MessageBox ("You must enter a number between 1 and 4.", WARNING);
endif;
until (nvItem > 0) && (nvItem <5);
// Make the first list element the current element
// so ListFindItem will search from the top of the list.
ListSetIndex (listID, 0);
// Search for the selected number.
nvResult = ListFindItem(listID, nvItem);
// Delete the selected number from the list.
if (ListDeleteItem (listID) < 0) then
MessageBox ("Unable to delete selected number.", SEVERE);
else
// Start building the message to report the remaining numbers.
szMsg = "The list now contains the following numbers:\n\n";
// Get the remaining 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 remaining numbers.
MessageBox (szMsg, INFORMATION);
endif;
// Remove the list from memory.
ListDestroy (listID);
end;
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |