home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh14 / CH14LIST / Classes / CH14_03LIST.uc < prev    next >
Encoding:
Text File  |  2006-02-07  |  1.1 KB  |  49 lines

  1. // %PARAMETERS = "CH14LIST C:\UT2004"
  2. //Identifies the package
  3. //CH14_03LIST.uc
  4.  
  5. class CH14_03LIST extends Commandlet;
  6.  
  7. function int Main(string Args){
  8. //#1
  9. local Array<string> rgMinerals;
  10. local string szMinerals;
  11. local int iLIMIT, iCtr;
  12. iCtr = 0;
  13. szMinerals = "Covelite Galena Stibinite " $
  14.              "Molybdenite Graphite Pyrolusite Basalt";
  15. iLIMIT =  Split(szMinerals, Chr(32) , rgMinerals);
  16.  
  17. Log(Chr(10) @ "CH14_03LIST" @ Chr(10));
  18.  
  19. //#2
  20. Log("  List 1 Use of 'break' to stop at 2:" );
  21.  
  22. // Use of break
  23.   for(iCtr = iLIMIT-1; iCtr >= 0 ; --iCtr){
  24.      Log("    "  $iCtr $ ". "  $ rgMinerals[iCtr] );
  25.      if(iCtr == 3){
  26.          break;
  27.      }
  28.   }
  29.  
  30. //#3
  31. Log("  List 2 Use of 'continue' to skip to: " );
  32.   for(iCtr = iLIMIT-1; iCtr >= 0 ; --iCtr){
  33.  
  34.      if(iCtr == 2 || iCtr == 4){
  35.         continue;
  36.      }
  37.      Log("    "  $iCtr $ ". "  $ rgMinerals[iCtr] );
  38.   }
  39.  
  40.  
  41. //#4 No braces -- Troublesome form
  42. Log("  List 3 No braces:" );
  43.    for(iCtr = iLIMIT-4; iCtr >= 0 ; --iCtr)
  44.      Log("    "  $iCtr $ ". "  $ rgMinerals[iCtr] );
  45.  
  46.   return 0;
  47. }
  48.  
  49.