home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH12LIST C:\UT2004"
- //Identifies the package
- //CH12_04LIST.uc
- //-
- class CH12_04LIST extends Commandlet;
- function int Main(string Args)
- {
- //#1
- local int iLines, iCount;
- local string szLines, szReturn, szSource ;
-
- local array<string> ArrayForTragedy;
-
- szLines = "It is equal to living in a tragic land";
- szLines $= Chr(10);
- szLines $= " To live in a tragic time";
- szSource = "Wallace Stevens, 'Dry Loaf'";
- szReturn = "";
- iLines = 0;
- iCount = 0;
-
- log("*************");
- log(Chr(10) @ " CH12_04LIST Split and join");
-
- //#2
- log(Chr(10) @ szLines @ Chr(10) @ " --" $ szSource);
-
- log( Chr(10));
- //#1 Separate line using spaces
- log(" A - Use of Split ");
- iLines = Split(szLines, " ", ArrayForTragedy);
- log(" Lines " $ iLines);
- iCount = 0;
- while(iCount < iLines){
- log(" " $ ArrayForTragedy[iCount]);
- ++iCount;
- }
-
- log( Chr(10));
- //#3
- log(" B - Join the elements back together: ");
- iCount = 0;
- szReturn = "";
- while(iCount < iLines){
- szReturn @= ArrayForTragedy[iCount];
- iCount++;
- }
- log(szReturn);
-
- return 0;
- }
-