home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Snippets / TStr255 class / shell.cp < prev    next >
Encoding:
Text File  |  1995-10-03  |  1.8 KB  |  71 lines  |  [TEXT/CWIE]

  1. /*
  2. *    shell.cp
  3. *
  4. *    Main function to show off 'TStr255' class,
  5. *    a class which is a drop-in replacement
  6. *    for the pascal Str255 type the macintosh
  7. *    is so bloody fond of.
  8.  
  9. *    The class allows for (amongst other things)
  10. *    the easy assignment and concatenation of strings.
  11.  
  12. *    © Andrew Nemeth Warrimoo  Australia  1995
  13. *    aznemeng@zeta.org.au
  14.  
  15. *    File created:        5 Jun;
  16. *    File ammended:        3 Oct 95
  17. */
  18.  
  19.  
  20. #include    "AZN_TStr255.h"                                //    Wrapper class for Str255
  21.  
  22.  
  23.  
  24. void        main( void )
  25. //
  26. //    Hint: Step through all the following code in a source level debugger!
  27. //    A '.dsi' file has been provided for Jasik lovers/haters,
  28. //    otherwise use the Metrowerks debugger to follow the values of
  29. //    of the variables
  30. //
  31. {
  32.     TStr255    objString_1,
  33.             objString_2     = "\pInit with me!";
  34.     long        lgNum         = 2L;
  35.     char        *txtItem         = { "C String to my heart's content!" };
  36.     Str255    str255Item     = { "\pThe bad old way" };
  37.     Boolean    boolSame         = FALSE;
  38.     char        chElement        = '\0';
  39.     short    shSize        = 0;
  40.  
  41. //                                                        copy strings
  42.     objString_1 = objString_2;
  43.     objString_2 = str255Item;
  44.     objString_1 = txtItem;
  45.     objString_1 = objString_2 = str255Item;
  46. //                                                        compare strings
  47.     boolSame = ( objString_1 == objString_2 );
  48.     boolSame = ( objString_2 == str255Item );
  49. //                                                        concat strings
  50.     objString_1 += str255Item;
  51.     objString_2 += txtItem;
  52. //                                                        play with toolbox
  53.     objString_1 = "\p12";
  54.     ::StringToNum( objString_1, &lgNum ); 
  55.  
  56.     objString_1 = str255Item;
  57.     boolSame = ::EqualString( str255Item, objString_1, TRUE, TRUE );
  58. //                                                        index array
  59.     chElement = objString_1[3];
  60.     chElement = objString_2[0];
  61.     shSize    = *objString_2;
  62.  
  63. //    Uncomment two 2 lines below & then try to compile
  64.  
  65. /*    TStr255    * ptrObjString = NULL;
  66.  
  67.     ptrObjString = new TStr255; */
  68.  
  69. //    ( Fails because operator new for class is declared private! )
  70. }
  71.