Adding Elements Before and After the Current Element

InstallShield 2020

As another example, the code segment shown below creates a new list and puts String 1 in the first position. String 2 is then added before String 1, leaving String 2 in the first position as the current string. Next, String 3 is added after the current string, resulting in the list depicted below.

// Create the empty list of strings.

listID = ListCreate (STRINGLIST);

 

// Test for a valid list

if (listID = LIST_NULL) then

    MessageBox ("List not created", SEVERE);

else

    // Add some strings to the list.

    szString = "String 1";

    ListAddString (listID, szString, AFTER);

 

    szString = "String 2";

    ListAddString (listID, szString, BEFORE);

 

    szString = "String 3";

    ListAddString (listID, szString, AFTER);

endif;

String 1 is added. Then String 2 is added before String 1. Last, String 3 is added after String 2.

In the example above, if String 3 were added before the current string, the result would be as shown below, with String 3 becoming the current string. This code segment is shown below:

// Create the empty list of strings.

listID = ListCreate (STRINGLIST);

 

// Test for a valid list

if (listID = LIST_NULL) then

    MessageBox ("List not created", SEVERE);

else

    // Add some strings to the list.

    szString = "String 1";

    ListAddString (listID, szString, AFTER);

    

    szString = "String 2";

    ListAddString (listID, szString, BEFORE);

    

    szString = "String 3";

    ListAddString (listID, szString, BEFORE);

endif;

String 1 is added. Then String 2 is added before String 1. Last, String 3 is added before String 2.