home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH12LIST C:\UT2004"
- //Identifies the package
- //CH12_01LIST.uc
-
- class CH12_01LIST extends Commandlet;
- function int Main(string Args)
- {
- //#1
- local int iLocation;
- local string szLines, szSearch, szReturn,
- szFirst, szSecond, szSource ;
-
- szLines = "Sighs for folly said and done";
- szLines $= Chr(10);
- szLines $= " Twist our narrow days";
- szSearch = "our";
- szSource = "W. H. Auden, 'Twelve Songs'";
- szReturn = "";
- szFirst = "";
- szSecond = "";
-
- log("*************");
- log(Chr(10) @ " CH112_01LIST String functions" @ Chr(10));
-
- //#2
- log(Chr(10) @ szLines @ Chr(10) @ " --" $ szSource);
-
- log(" A - Length of the string " @ Len(szLines));
- //#Search a string using the InStr() function
- iLocation = InStr(szLines , szSearch);
- log(" B - String '" $ szSearch $ "' found at index "
- @ iLocation);
-
-
- //#3
- //From the beginning of the source sting to the start
- //of the search word
- szReturn = Left(szLines, iLocation);
- log(" C - Left from start of '" $ szSearch $ "': "
- @ Chr(10) @ szReturn);
- szReturn = "";
- //Subtract starting index of search term from the length
- //Gives you the remainder of the string
- szReturn = Right(szLines, Len(szLines) - iLocation);
- log(" D - Right from start of '" $ szSearch $ "': "
- @ Chr(10) @ szReturn);
-
- //#4
- //Break the string at the new line character
- Divide(szLines, chr(10), szFirst, szSecond);
- log(" Divide at the new line ");
- log(" E - First part: " @ Chr(10) @ szFirst);
- log(" E - Second part: " @ Chr(10) @ szSecond);
-
- //#5
- //Change to all lower case letters
- szFirst = Locs(szFirst);
- log(" F - First part in lower case: "
- @ Chr(10) @ szFirst);
- //Change to all capital letters
- szSecond = Caps(szSecond);
- log(" G - First part: " @ Chr(10) @ szSecond);
-
- //#6
- szReturn = "";
- //Subtract starting index of search term from the length
- //Gives you the remainder of the string
- szReturn = Mid(szLines, iLocation);
- log(" H - Mid from start of " $ iLocation $ ": "
- @ Chr(10) @ szReturn);
-
- return 0;
- }
-