home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh12 / CH12LIST / Classes / CH12_04LIST.uc < prev   
Encoding:
Text File  |  2006-02-03  |  1.2 KB  |  52 lines

  1. // %PARAMETERS = "CH12LIST C:\UT2004"
  2. //Identifies the package
  3. //CH12_04LIST.uc
  4. //-
  5. class CH12_04LIST extends Commandlet;
  6. function int Main(string Args)
  7. {
  8.   //#1
  9.   local int  iLines, iCount;
  10.   local string szLines, szReturn, szSource ;
  11.  
  12.   local array<string> ArrayForTragedy;
  13.  
  14.   szLines = "It is equal to living in a tragic land";
  15.   szLines $= Chr(10);
  16.   szLines $= " To live in a tragic time";
  17.   szSource = "Wallace Stevens, 'Dry Loaf'";
  18.   szReturn = "";
  19.   iLines = 0;
  20.   iCount = 0;
  21.  
  22.   log("*************");
  23.   log(Chr(10) @ " CH12_04LIST Split and join");
  24.  
  25.   //#2
  26.   log(Chr(10) @ szLines @ Chr(10) @ "         --" $ szSource);
  27.  
  28.   log( Chr(10));
  29.  //#1 Separate line using spaces
  30.    log(" A - Use of Split ");
  31.    iLines = Split(szLines, " ", ArrayForTragedy);
  32.    log("     Lines " $ iLines);
  33.    iCount = 0;
  34.    while(iCount < iLines){
  35.       log("  " $ ArrayForTragedy[iCount]);
  36.       ++iCount;
  37.    }
  38.  
  39.   log( Chr(10));
  40.   //#3
  41.     log(" B - Join the elements back together: ");
  42.     iCount = 0;
  43.     szReturn = "";
  44.     while(iCount < iLines){
  45.        szReturn @= ArrayForTragedy[iCount];
  46.       iCount++;
  47.     }
  48.     log(szReturn);
  49.  
  50.   return 0;
  51. }
  52.