Getting the First and Next Elements in a List
InstallShield 2025
Call the ListGetFirstString function or the ListGetFirstItem function to return the first string element or number element, respectively, from a list. The element that you retrieve then becomes the current element in the list.
Call the ListGetNextString function or the ListGetNextItem function to return the string element or number element after the current element in a list. The element that you retrieve then becomes the current element in the list.
// Create the empty list of strings.
listID = ListCreate (STRINGLIST);
// Test for a valid list.
if (listID = LIST_NULL) then
MessageBox ("List not created", SEVERE);
endif;
// Add some strings to the list.
ListAddString (listID, "String 1", AFTER);
ListAddString (listID, "String 2", AFTER);
ListAddString (listID, "String 3", AFTER);
// Traverse the list and display the strings in a message box.
lResult = ListGetFirstString(listID, szDriveName);
while (lResult != END_OF_LIST)
MessageBox (szDriveName, INFORMATION);
lResult = ListGetNextString (listID, szDriveName);
endwhile;
See Also