home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh15 / CH15LIST / Classes / CH15_01LIST.uc next >
Encoding:
Text File  |  2006-03-08  |  1.5 KB  |  59 lines

  1. // %PARAMETERS = "CH15LIST C:\UT2004"
  2. //Identifies the package
  3. //CH15_01LIST.uc
  4.  
  5. class CH15_01LIST extends Commandlet;
  6. function int Main(string Args){
  7.  
  8.  //#1
  9.  //Define a constant
  10.  const iELECTRACAST = 5;
  11.  
  12.  //Declare and array using the constant
  13.  local string rgElectraCast[iELECTRACAST];
  14.  //Counter for traversing an array
  15.  local int iCtr, iLoc;
  16.  local string szDisplay, szName;
  17.  
  18.  //#2 Initialize the elements of an array
  19.  rgElectraCast[0] = "Electra";
  20.  rgElectraCast[1] = "Orestes";
  21.  rgElectraCast[2] = "Chrysothemis";
  22.  rgElectraCast[3] = "Clytemnestra";
  23.  rgElectraCast[4] = "Aegisthus";
  24.  iLoc = 0;
  25.  
  26.  log(Chr(10) $ "CH15_01LIST -- Static Array" $ Chr(10));
  27.  
  28.  //# 3 Traversing the elements of an array
  29.  iCtr = 0;
  30.  for(iCtr = 0; iCtr < iELECTRACAST; iCtr++){
  31.   Log(" rgElectraCast[" $ iCtr  $ "] = " $ rgElectraCast[iCtr]);
  32.      // #4
  33.      //Access the elements and capitalize
  34.      rgElectraCast[iCtr] = Caps(rgElectraCast[iCtr]);
  35.      //Add Dashes between the letters
  36.      while(iLoc <= Len(rgElectraCast[iCtr]) ){
  37.      //Uncomment this to see how it works
  38.         //  Log(Left( rgElectraCast[iCtr], iLoc));
  39.           szName $= Right( Left( rgElectraCast[iCtr], iLoc) ,  1) ;
  40.           szName $= "-";
  41.           iLoc++;
  42.  
  43.      }
  44.  
  45.      //Make the display string
  46.      szDisplay $= "    ";
  47.      szDisplay $= szName;
  48.      szDisplay $= Chr(10);
  49.      //Reset the local counter and string
  50.      iLoc = 0;
  51.      szName = "";
  52.  }
  53.  
  54.  
  55.   Log(Chr(10) $ szDisplay);
  56.   return 0;
  57. }
  58.  
  59.