home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH12LIST C:\UT2004"
- //Identifies the package
- //CH12_02LIST.uc
-
- class CH12_02LIST extends Commandlet;
- function int Main(string Args)
- {
- //#1
- local int iLocation;
- local string szLines, szSearch, szReturn,
- szFirst, szSecond, szSource ;
-
- szLines = "The intellect of man is forced to choose";
- szLines $= Chr(10);
- szLines $= " Perfection of the life, or of the work";
- szSearch = "our";
- szSource = "W. B. Yeats, 'The Choice'";
- szReturn = "";
- szFirst = "The intellect of man is forced to choose";
- szSecond = "Perfection of the life, or of the work";
-
- log("*************");
- log(Chr(10) @ " CH12_02LIST More string functions");
- //#2
- log(Chr(10) @ szLines @ Chr(10) @ " --" $ szSource);
-
- //Get charcters up to length
- iLocation = Len(szFirst);
-
- log(" A - Length of the string " @ Len(szFirst));
- EatStr(szReturn, szLines, iLocation);
- log(" B - EatStr up to length " );
- log(" " @ szReturn);
-
- //#3 if true - false show different lines
- szReturn = Eval(true, szFirst, szSecond);
- log(" C - When Eval is true");
- log(" " @ szReturn);
-
- szReturn = Eval(false, szFirst, szSecond);
- log(" When Eval is false" );
- log(" " @ szReturn);
-
- log(" Eval (2 < 3) && (1 < 2)");
- szReturn = Eval((2 < 3) && (1 < 2), szFirst, szSecond);
- log(" " @ szReturn);
-
- //#4 Replace a word and use case
- szReturn = Repl(szFirst, "intellect", "mind", true);
- log(" D - Using Repl to change the word");
- log(" Before: " @ Chr(10) @ " " @ szFirst);
- log(" After: " @ Chr(10) @ " " @ szReturn);
-
- //#5 Replace the word
- log(" E - Using ReplaceText to change the word");
- log(" Before: " @ Chr(10) @ " " @ szSecond);
- ReplaceText(szSecond, "life", "living");
- log(" After: " @ Chr(10) @ " " @ szSecond);
- return 0;
- }
-