home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH15LIST C:\UT2004"
- //Identifies the package
- //CH15_02LIST.uc
-
- class CH15_02LIST extends Commandlet;
-
- function int Main(string Args)
- {
-
- local Array<string> rgElectraCast;
- local int iLen, iCtr;
- iLen = 0;
- //call Length to obtain number of characters
- iLen = rgElectraCast.Length;
- //Report number
-
- Log(Chr(10) $ " CH15_02LIST -- Dynamic Array" $ Chr(10));
- Log(" Initial length: " $ iLen $ Chr(10));
-
- //#2 Add elements to array
- Log(" Add 3 characters: ");
- rgElectraCast[0] = "Orestes";
- rgElectraCast[1] = "Electra";
- rgElectraCast[2] = "Chrysothemis";
-
- //call Length to obtain number of characters
- iLen = rgElectraCast.Length;
-
- //Report number
- Log(" Number of characters: " $ iLen);
-
- //Set counter and show characters
- iCtr = 0;
- for(iCtr = 0; iCtr < iLen; iCtr++){
- Log(" " $ rgElectraCast[iCtr]);
- }
-
- //#3
- //Add at the beginning
- Log(Chr(10) $ " Add Clytemnestra to the start - Insert(0, 1): ");
- rgElectraCast.Insert(0, 1);
- rgElectraCast[0] = "Clytemnestra";
- iLen = rgElectraCast.Length;
-
- //#4
- //Add at the end
- Log(" Add Aegisthus to the end - Insert(iLen, 1): ");
- rgElectraCast.Insert(iLen, 1);
- iLen = rgElectraCast.Length;
- rgElectraCast[iLen-1] = "Aegisthus";
- Log(" Insert[iLen-1] = Aegisthus" );
-
- //Report
- iLen = rgElectraCast.Length;
- Log(" Number of characters: " $ iLen);
- iCtr = 0;
- for(iCtr = 0; iCtr < iLen; iCtr++){
- Log(" " $ rgElectraCast[iCtr]);
- }
-
- //#5
- Log(Chr(10) $ " Remove Clytemnestra and Aegisthus ");
- Log(" - Remove(0,1) - Remove (3, 1)");
-
- rgElectraCast.Remove(0,1);
- iLen = rgElectraCast.Length;
- rgElectraCast.Remove(iLen - 1,1);
-
- //Report
- iLen = rgElectraCast.Length;
- Log(" Number of characters: " $ iLen);
- iCtr = 0;
- for(iCtr = 0; iCtr < iLen; iCtr++){
- Log(" " $ rgElectraCast[iCtr]);
- }
-
- return 0;
- }
-
-