home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-03 | 1.8 KB | 71 lines | [TEXT/CWIE] |
- /*
- * shell.cp
- *
- * Main function to show off 'TStr255' class,
- * a class which is a drop-in replacement
- * for the pascal Str255 type the macintosh
- * is so bloody fond of.
-
- * The class allows for (amongst other things)
- * the easy assignment and concatenation of strings.
-
- * © Andrew Nemeth Warrimoo Australia 1995
- * aznemeng@zeta.org.au
-
- * File created: 5 Jun;
- * File ammended: 3 Oct 95
- */
-
-
- #include "AZN_TStr255.h" // Wrapper class for Str255
-
-
-
- void main( void )
- //
- // Hint: Step through all the following code in a source level debugger!
- // A '.dsi' file has been provided for Jasik lovers/haters,
- // otherwise use the Metrowerks debugger to follow the values of
- // of the variables
- //
- {
- TStr255 objString_1,
- objString_2 = "\pInit with me!";
- long lgNum = 2L;
- char *txtItem = { "C String to my heart's content!" };
- Str255 str255Item = { "\pThe bad old way" };
- Boolean boolSame = FALSE;
- char chElement = '\0';
- short shSize = 0;
-
- // copy strings
- objString_1 = objString_2;
- objString_2 = str255Item;
- objString_1 = txtItem;
- objString_1 = objString_2 = str255Item;
- // compare strings
- boolSame = ( objString_1 == objString_2 );
- boolSame = ( objString_2 == str255Item );
- // concat strings
- objString_1 += str255Item;
- objString_2 += txtItem;
- // play with toolbox
- objString_1 = "\p12";
- ::StringToNum( objString_1, &lgNum );
-
- objString_1 = str255Item;
- boolSame = ::EqualString( str255Item, objString_1, TRUE, TRUE );
- // index array
- chElement = objString_1[3];
- chElement = objString_2[0];
- shSize = *objString_2;
-
- // Uncomment two 2 lines below & then try to compile
-
- /* TStr255 * ptrObjString = NULL;
-
- ptrObjString = new TStr255; */
-
- // ( Fails because operator new for class is declared private! )
- }
-