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

  1. // %PARAMETERS = "CH18LIST C:\UT2004"
  2. //Identifies the package
  3. //Decoration.uc
  4.  
  5. //This class provides math functions useful for working with basic math
  6. class Decoration extends Commandlet;
  7.  
  8. //#1
  9. //-------------- makeWord ----------------------------
  10. static function string makeWord(int A){
  11.     return string(A);
  12. }
  13. //#2
  14. //--------------addDecoration--------------------------
  15. //Use of out allows you tranform the word without return
  16. public function addDecoration(out string word, string decor){
  17.     word = decor @ word;
  18.     word = word @ decor;
  19. }
  20. //#3
  21. //-------------- joinTerms ------------------------
  22. //Casts the arguments as a strings and returns them
  23. public function string joinTerms(coerce string strA, coerce string strB){
  24.     local string exp;
  25.     exp = strA @ "and" @ strB;
  26.     return exp;
  27. }
  28. //#4
  29. //-------------- addSpace ----------------------------
  30. //The sectond argument, for number of spaces, is optional
  31. //The function defaults to 1
  32. //#2
  33. public function string addSpace(string expression, optional int spaces){
  34.     local int iLoc, iCtr;;
  35.     local string szExp, szSpace;
  36.     iLoc = 0; iCtr = 0;
  37.     if(spaces <=0){spaces = 1;}
  38.     while(iCtr < spaces){
  39.        szSpace $= "-";
  40.        iCtr++;
  41.     }
  42.  
  43.     while(iLoc <= Len(expression)){
  44.         //Log(Left( expression, iLoc));
  45.         szExp $= Right( Left( expression, iLoc) , 1) ;
  46.         szExp $= szSpace;
  47.         //szExp $= "-";
  48.         iLoc++;
  49.     }
  50.     return szExp;
  51. }
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.