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

  1. // %PARAMETERS = "CH12LIST C:\UT2004"
  2. //Identifies the package
  3. //CH12_02LIST.uc
  4.  
  5. class CH12_02LIST extends Commandlet;
  6. function int Main(string Args)
  7. {
  8.   //#1
  9.   local int  iLocation;
  10.   local string szLines, szSearch, szReturn,
  11.                szFirst, szSecond, szSource ;
  12.                
  13.   szLines = "The intellect of man is forced to choose";
  14.   szLines $= Chr(10);
  15.   szLines $= " Perfection of the life, or of the work";
  16.   szSearch = "our";
  17.   szSource = "W. B. Yeats, 'The Choice'";
  18.   szReturn = "";
  19.   szFirst  = "The intellect of man is forced to choose";
  20.   szSecond = "Perfection of the life, or of the work";
  21.  
  22.   log("*************");
  23.   log(Chr(10) @ " CH12_02LIST More string functions");
  24.   //#2
  25.   log(Chr(10) @ szLines @ Chr(10) @ "         --" $ szSource);
  26.  
  27.   //Get charcters up to length
  28.   iLocation = Len(szFirst);
  29.  
  30.   log(" A - Length of the string " @ Len(szFirst));
  31.   EatStr(szReturn, szLines, iLocation);
  32.   log(" B - EatStr up to length " );
  33.   log("     " @ szReturn);
  34.  
  35.   //#3 if true - false show different lines
  36.   szReturn = Eval(true, szFirst, szSecond);
  37.   log(" C - When Eval is true");
  38.   log("     " @ szReturn);
  39.  
  40.   szReturn = Eval(false, szFirst, szSecond);
  41.   log("     When Eval is false" );
  42.   log("     " @ szReturn);
  43.  
  44.   log("     Eval (2 < 3) && (1 < 2)");
  45.   szReturn = Eval((2 < 3) && (1 < 2), szFirst, szSecond);
  46.   log("     " @ szReturn);
  47.  
  48.   //#4  Replace a word and use case
  49.   szReturn = Repl(szFirst, "intellect", "mind", true);
  50.   log(" D - Using Repl to change the word");
  51.   log("     Before: " @ Chr(10)  @ "    " @ szFirst);
  52.   log("     After: "  @ Chr(10)  @ "    " @ szReturn);
  53.  
  54.   //#5   Replace the word
  55.   log(" E - Using ReplaceText to change the word");
  56.   log("     Before: " @ Chr(10)  @ "    " @ szSecond);
  57.   ReplaceText(szSecond, "life", "living");
  58.   log("     After: "  @ Chr(10)  @ "    " @ szSecond);
  59.   return 0;
  60. }
  61.