home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH16LIST C:\UT2004"
- //Identifies the package
- //CH16_02LIST.uc
-
- class CH16_02LIST extends Commandlet;
-
- //#1
- //Declaration of struct at class scope
- struct Play{
- var string szTitle; //struct members
- var string szAuthor;
- var int iReference;
- var int iCastNumber;
- var string szPrimeChar;
- };
-
- function int Main(string Args){
-
- //#2
- //Declaration of abstract identifier of the type Play
- local Play PlayA, PlayB, PlayC;
- local Array<Play> rgPlaySet;
- local int iCtr, iLoc;
-
- //#3
- //Definition of struct members
-
- PlayA.szTitle = "Electra";
- PlayA.szAuthor = "Sophocles";
- PlayA.iReference = 156;
- PlayA.iCastNumber = 7;
- PlayA.szPrimeChar = "Electra";
-
- PlayB.szTitle = "Oedipus the King";
- PlayB.szAuthor = "Sophocles";
- PlayB.iReference = 99;
- PlayB.iCastNumber = 14;
- PlayB.szPrimeChar = "Iocasta";
-
- //Then assign them to an array
- rgPlaySet[0] = PlayA;
- rgPlaySet[1] = PlayB;
-
-
- //#4 Assign a iReference to the array
- rgPlaySet[2] = PlayC;
-
- //Then assign items to members directly
- rgPlaySet[2].szTitle = "Antigone";
- rgPlaySet[2].szAuthor = "Sophocles";
- rgPlaySet[2].iReference = 131;
- rgPlaySet[2].iCastNumber = 10;
- rgPlaySet[2].szPrimeChar = "Antigone";
-
- Log(Chr(10) $ " CH16_02LIST -- Structures and Arrays" $ Chr(10));
- //Call of function to display one structure
-
- //#5
-
- //Use of the array to print the array of Play items
- iLoc = rgPlaySet.Length;
- iCtr = 0;
- while(iCtr < iLoc){
- showInfo(rgPlaySet[iCtr] );
- iCtr++;
- }
-
- return 0;
- }
-
- //#6
- //function receives struct and retrieves members
- function int showInfo(Play playName){
- Log(Chr(10));
- Log(" Name: " $ playName.szTitle );
- Log(" szAuthor: " $ playName.szAuthor );
- Log(" Page ref: " $ playName.iReference );
- Log(" Number in cast: " $ playName.iCastNumber );
- Log(" Character example: " $ playName.szPrimeChar );
-
- return 0;
- }
-
-
-