home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh18 / CH18LIST / Classes / CH18_01LIST.uc < prev    next >
Encoding:
Text File  |  2006-02-21  |  1.7 KB  |  46 lines

  1. // %PARAMETERS = "CH18LIST C:\UT2004"
  2. //Identifies the package
  3. //CH08_01LIST.uc
  4.  
  5. class CH18_01LIST extends Commandlet;
  6. function int Main(string Args)
  7. {
  8.   //#1
  9.   //Declare an identifier of the Cast type
  10.   local Cast firstCast;
  11.   local int iCtr;
  12.   //Create an instance of the Cast class
  13.   firstCast = new class'Cast';
  14.  
  15.   Log(Chr(10)$ "     Cast Functions");
  16.   //#2 The call to showName() calls the init() function
  17.   Log(Chr(10)$ "1.   The Cast private init() sets the name");
  18.   Log(         "     and showName() displays it--" );
  19.   firstCast.showName();
  20.   //#3 The attribute value from its local scope
  21.   Log(Chr(10)$ "2.   Name returned from getInnerName() function : "
  22.              $ firstCast.getInnerName());
  23.   //#4 Travers the cast array
  24.   Log(Chr(10)$ "3.   Show names array 'selectListName( )' : ");
  25.   for(iCtr = 0; iCtr < firstCast.getListLength(); iCtr++){
  26.        firstCast.selectListName(iCtr);
  27.        Log("     From selectListName("$iCtr$") "
  28.                                       $ firstCast.getName());
  29.   }//end for
  30.   //#5 Access the name attribute after traversing the cast array
  31.   Log(Chr(10)$ "4.   Accessor now returns : "
  32.              $ firstCast.getName());
  33.   //#6 Name added to array 
  34.   Log(Chr(10)$ "5.   Add a name to the list (Aegisthus): ");
  35.   firstCast.addToList("Aegisthus");
  36.   //#7 Show the new number of names and then the names
  37.   Log(Chr(10)$ "6.   Show names array 'selectListName()' : ");
  38.   Log(Chr(10)$ "     List length now: " $ firstCast.getListLength());
  39.   for(iCtr = 0; iCtr < firstCast.getListLength(); iCtr++){
  40.       firstCast.selectListName(iCtr);
  41.       Log("     From selectListName("$iCtr$") "
  42.                                      $ firstCast.getName());
  43.   }//end for
  44.   return 0;
  45. }
  46.