home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / macintosh-c / macc-carbon-demos-nonbinhex.sit / macc-carbon-demos-nonbinhex / chap26-demo / MLTETextEditor.c < prev    next >
C/C++ Source or Header  |  2001-05-31  |  18KB  |  708 lines

  1. // *******************************************************************************************
  2. // MLTETextEditor.c
  3. // *******************************************************************************************
  4.  
  5. // ………………………………………………………………………………………………………………………………………………………………………………………………………………………… includes
  6.  
  7. #include "MLTETextEditor.h"
  8.  
  9. // …………………………………………………………………………………………………………………………………………………………………………………………………… global variables
  10.  
  11. SInt16                        gAppResFileRefNum;
  12. Boolean                        gRunningOnX = false;
  13. Boolean                        gDone;
  14. TXNFontMenuObject    gTXNFontMenuObject;
  15. RgnHandle                    gCursorRgnHdl;
  16. extern SInt16            gCurrentNumberOfWindows;
  17.  
  18. // ************************************************************************************** main
  19.  
  20. void  main(void)
  21. {
  22.     MenuBarHandle    menubarHdl;
  23.     SInt32                response;
  24.     MenuRef                menuRef;
  25.     OSStatus            osStatus = noErr;
  26.  
  27.     // ……………………………………………………………………………………………………………………………………………………………………………………………… do preliminaries
  28.  
  29.     doPreliminaries();
  30.  
  31.     // ………………………………………………………………………………………… save application's resource file file reference number
  32.  
  33.     gAppResFileRefNum = CurResFile();
  34.  
  35.     // ……………………………………………………………………………………………………………………………………………………………………… set up menu bar and menus
  36.     
  37.     menubarHdl = GetNewMBar(rMenubar);
  38.     if(menubarHdl == NULL)
  39.         doErrorAlert(MemError());
  40.     SetMenuBar(menubarHdl);
  41.  
  42.     CreateStandardWindowMenu(0,&menuRef);
  43.     SetMenuID(menuRef,mWindow);
  44.     InsertMenu(menuRef,0);
  45.     DeleteMenuItem(menuRef,1);
  46.  
  47.     Gestalt(gestaltMenuMgrAttr,&response);
  48.     if(response & gestaltMenuMgrAquaLayoutMask)
  49.     {
  50.         menuRef = GetMenuRef(mFile);
  51.         if(menuRef != NULL)
  52.         {
  53.             DeleteMenuItem(menuRef,iQuit);
  54.             DeleteMenuItem(menuRef,iQuit - 1);
  55.         }
  56.  
  57.         gRunningOnX = true;
  58.     }
  59.  
  60.     // ……………………………………………………………………………………………………………… build hierarchical font menu and draw menu bar
  61.  
  62.     menuRef = GetMenuRef(mFont);
  63.     osStatus = TXNNewFontMenuObject(menuRef,mFont,mFirstHierarchical,&gTXNFontMenuObject);
  64.     if(osStatus != noErr)
  65.         doErrorAlert(osStatus);
  66.  
  67.     DrawMenuBar();
  68.  
  69.     // ……………………………………………………………………………………………………………………………………… install required Apple event handlers
  70.  
  71.     doInstallAEHandlers();
  72.  
  73.     // ……………………………………………………………………………………………………………………………………………………………………………………………… enter event loop
  74.  
  75.     eventLoop();
  76. }
  77.  
  78. // *************************************************************************** doPreliminaries
  79.  
  80. void  doPreliminaries(void)
  81. {
  82.     MoreMasterPointers(960);
  83.     InitCursor();
  84.     FlushEvents(everyEvent,0);
  85.  
  86.     doInitialiseMTLE();
  87. }
  88.  
  89. // ************************************************************************** doInitializeMTLE
  90.  
  91. void  doInitialiseMTLE(void)
  92. {
  93.     TXNMacOSPreferredFontDescription    defaultFont[1];
  94.     OSStatus                                                    osStatus = noErr;
  95.     SInt16                                                        fontID;
  96.  
  97.     GetFNum("\pNew York",&fontID);
  98.  
  99.     defaultFont[0].fontID            = fontID;    
  100.     defaultFont[0].pointSize    = 0x000C0000;
  101.     defaultFont[0].fontStyle    = kTXNDefaultFontStyle;
  102.     defaultFont[0].encoding        = kTXNSystemDefaultEncoding;
  103.  
  104.     osStatus = TXNInitTextension(&defaultFont[0],1,kTXNWantMoviesMask);
  105.     if(osStatus != noErr)
  106.         doErrorAlert(osStatus);
  107. }
  108.  
  109. // *********************************************************************** doInstallAEHandlers
  110.  
  111. void  doInstallAEHandlers(void)
  112. {
  113.     OSStatus    osStatus = noErr;
  114.  
  115.     osStatus = AEInstallEventHandler(kCoreEventClass,kAEOpenApplication,
  116.                                                     NewAEEventHandlerUPP((AEEventHandlerProcPtr) openAppEventHandler),
  117.                                                     0L,false);
  118.     if(osStatus != noErr)    doErrorAlert(eInstallHandler);
  119.  
  120.     osStatus = AEInstallEventHandler(kCoreEventClass,kAEReopenApplication,
  121.                                                     NewAEEventHandlerUPP((AEEventHandlerProcPtr) reopenAppEventHandler),
  122.                                                     0L,false);
  123.     if(osStatus != noErr)    doErrorAlert(eInstallHandler);
  124.  
  125.     osStatus = AEInstallEventHandler(kCoreEventClass,kAEOpenDocuments,
  126.                                     NewAEEventHandlerUPP((AEEventHandlerProcPtr) openAndPrintDocsEventHandler),
  127.                                                     kOpen,false);
  128.     if(osStatus != noErr)    doErrorAlert(eInstallHandler);
  129.  
  130.     osStatus = AEInstallEventHandler(kCoreEventClass,kAEPrintDocuments,
  131.                                     NewAEEventHandlerUPP((AEEventHandlerProcPtr) openAndPrintDocsEventHandler),
  132.                                                     kPrint,false);
  133.     if(osStatus != noErr)    doErrorAlert(eInstallHandler);
  134.  
  135.     osStatus = AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,
  136.                                                     NewAEEventHandlerUPP((AEEventHandlerProcPtr) quitAppEventHandler),
  137.                                                     0L,false);
  138.     if(osStatus != noErr)    doErrorAlert(eInstallHandler);
  139. }
  140.  
  141. // ********************************************************************************* eventLoop
  142.  
  143. void  eventLoop(void)
  144. {
  145.     EventRecord eventStructure;
  146.  
  147.     gDone = false;
  148.     gCursorRgnHdl = NewRgn();
  149.  
  150.     while(!gDone)
  151.     {
  152.         if(WaitNextEvent(everyEvent,&eventStructure,doGetSleepTime(),gCursorRgnHdl))
  153.             doEvents(&eventStructure);
  154.         else
  155.         {
  156.             if(eventStructure.what == nullEvent)
  157.             {
  158.                 doIdle();
  159.                 doSynchroniseFiles();
  160.             }
  161.         }
  162.     }
  163. }
  164.  
  165. // **************************************************************************** doGetSleepTime
  166.  
  167. UInt32  doGetSleepTime(void)
  168. {
  169.     WindowRef    windowRef;
  170.     UInt32        sleepTime;
  171.     TXNObject    txnObject = NULL;
  172.  
  173.     windowRef = FrontWindow();
  174.  
  175.     if(isApplicationWindow(windowRef,&txnObject))
  176.         sleepTime = TXNGetSleepTicks(txnObject);
  177.     else
  178.         sleepTime = GetCaretTime();
  179.  
  180.     return sleepTime;
  181. }
  182.  
  183. // ************************************************************************************ doIdle
  184.  
  185. void  doIdle(void)
  186. {
  187.     WindowRef    windowRef;
  188.     TXNObject    txnObject = NULL;
  189.  
  190.     windowRef = FrontWindow();
  191.     if(isApplicationWindow(windowRef,&txnObject))
  192.     {
  193.         if(TXNGetChangeCount(txnObject))
  194.             SetWindowModified(windowRef,true);
  195.     }
  196. }
  197.  
  198. // ********************************************************************************** doEvents
  199.  
  200. void    doEvents(EventRecord *eventStrucPtr)
  201. {
  202.     WindowRef    windowRef;
  203.     TXNObject    txnObject = NULL;
  204.  
  205.     switch(eventStrucPtr->what)
  206.     {
  207.         case kHighLevelEvent:
  208.             AEProcessAppleEvent(eventStrucPtr);
  209.             break;
  210.  
  211.         case mouseDown:
  212.             doMouseDown(eventStrucPtr);
  213.             break;
  214.     
  215.         case keyDown:
  216.             if(eventStrucPtr->modifiers & cmdKey)
  217.             {
  218.                 doAdjustAndPrepareMenus();
  219.                 doMenuChoice(MenuEvent(eventStrucPtr));
  220.             }
  221.             break;
  222.  
  223.         case updateEvt:
  224.             doUpdate(eventStrucPtr);
  225.             break;
  226.  
  227.         case activateEvt:
  228.             doActivate(eventStrucPtr);
  229.             break;
  230.  
  231.         case osEvt:
  232.             switch((eventStrucPtr->message >> 24) & 0x000000FF)
  233.             {
  234.                 case suspendResumeMessage:
  235.                     if(eventStrucPtr->message & resumeFlag)
  236.                         SetThemeCursor(kThemeArrowCursor);
  237.                     break;
  238.                     
  239.                 case mouseMovedMessage:
  240.                     windowRef = FrontWindow();
  241.                     if(isApplicationWindow(windowRef,&txnObject))
  242.                         TXNAdjustCursor(txnObject,gCursorRgnHdl);
  243.             }
  244.             break;
  245.     }
  246. }
  247.  
  248. // ******************************************************************************* doMouseDown
  249.  
  250. void    doMouseDown(EventRecord *eventStrucPtr)
  251. {
  252.     WindowRef                windowRef;
  253.     WindowPartCode    partCode;
  254.     OSStatus                osStatus    = noErr;
  255.     TXNObject             txnObject = NULL;
  256.     Boolean                    handled        = false;
  257.     SInt32                    itemSelected;
  258.  
  259.     partCode = FindWindow(eventStrucPtr->where,&windowRef);
  260.  
  261.     switch(partCode)
  262.     {
  263.         case inMenuBar:
  264.             doAdjustAndPrepareMenus();
  265.             doMenuChoice(MenuSelect(eventStrucPtr->where));
  266.             break;
  267.  
  268.         case inContent:
  269.             if(windowRef != FrontWindow())
  270.                 SelectWindow(windowRef);
  271.             else
  272.             {
  273.                 if(isApplicationWindow(windowRef,&txnObject))
  274.                     TXNClick(txnObject,eventStrucPtr);
  275.             }  
  276.             break;
  277.  
  278.         case inGoAway:
  279.             if(TrackGoAway(windowRef,eventStrucPtr->where))
  280.                 doCloseCommand(kNavSaveChangesClosingDocument);
  281.             break;
  282.  
  283.         case inProxyIcon:
  284.             osStatus = TrackWindowProxyDrag(windowRef,eventStrucPtr->where);
  285.             if(osStatus == errUserWantsToDragWindow)
  286.                 handled = false;
  287.             else if(osStatus == noErr)
  288.                 handled = true;
  289.  
  290.         case inDrag:
  291.             if(!handled)
  292.             {
  293.                 if(IsWindowPathSelectClick(windowRef,eventStrucPtr))
  294.                 {
  295.                     if(WindowPathSelect(windowRef,NULL,&itemSelected) == noErr)
  296.                     {
  297.                         if(LoWord(itemSelected) > 1)
  298.                             doBringFinderToFront();
  299.                     }
  300.  
  301.                     handled = true;
  302.                 }
  303.             }
  304.             if(!handled)
  305.                 DragWindow(windowRef,eventStrucPtr->where,NULL);
  306.  
  307.             if(isApplicationWindow(windowRef,&txnObject))
  308.                 TXNAdjustCursor(txnObject,gCursorRgnHdl);
  309.  
  310.             break;
  311.  
  312.         case inGrow:
  313.             if(isApplicationWindow(windowRef,&txnObject))
  314.             {
  315.                 TXNGrowWindow(txnObject,eventStrucPtr);
  316.                 TXNAdjustCursor(txnObject,gCursorRgnHdl);
  317.             }
  318.             break;
  319.  
  320.         case inZoomIn:
  321.         case inZoomOut:
  322.             if(TrackBox(windowRef,eventStrucPtr->where,partCode))
  323.             {
  324.                 if(isApplicationWindow(windowRef,&txnObject))
  325.                 {
  326.                     TXNZoomWindow(txnObject,partCode);
  327.                     TXNAdjustCursor(txnObject,gCursorRgnHdl);
  328.                 }
  329.             }
  330.             break;
  331.     }
  332. }
  333.  
  334. // ********************************************************************** doBringFinderToFront
  335.  
  336. void  doBringFinderToFront(void)
  337. {
  338.     ProcessSerialNumber    finderProcess;
  339.  
  340.     if(doFindProcess('MACS','FNDR',&finderProcess) == noErr)
  341.         SetFrontProcess(&finderProcess);
  342.     else
  343.         doErrorAlert(eCantFindFinderProcess);
  344. }
  345.  
  346. // ***************************************************************************** doFindProcess
  347.  
  348. OSStatus  doFindProcess(OSType creator,OSType type,ProcessSerialNumber *outProcSerNo)
  349. {    
  350.     ProcessSerialNumber    procSerialNo;
  351.     ProcessInfoRec            procInfoStruc;
  352.     OSStatus                        osStatus = noErr;
  353.  
  354.     procSerialNo.highLongOfPSN = 0;
  355.     procSerialNo.lowLongOfPSN  = kNoProcess;
  356.  
  357.     procInfoStruc.processInfoLength    = sizeof(ProcessInfoRec);
  358.     procInfoStruc.processName                = NULL;
  359.     procInfoStruc.processAppSpec        = NULL;
  360.     procInfoStruc.processLocation        = NULL;
  361.  
  362.     while(true)
  363.     {
  364.         osStatus = GetNextProcess(&procSerialNo);
  365.         if(osStatus != noErr)
  366.             break;
  367.  
  368.         osStatus = GetProcessInformation(&procSerialNo,&procInfoStruc);
  369.         if(osStatus != noErr)
  370.             break;
  371.         if((procInfoStruc.processSignature == creator) && (procInfoStruc.processType == type))
  372.             break;
  373.     }
  374.  
  375.     *outProcSerNo = procSerialNo;
  376.  
  377.     return osStatus;
  378. }
  379.  
  380. // ******************************************************************************** doActivate
  381.  
  382. void  doActivate(EventRecord *eventStrucPtr)
  383. {
  384.     WindowRef        windowRef;
  385.     TXNObject        txnObject = NULL;
  386.     Boolean            becomingActive;
  387.     TXNFrameID     txnFrameID = 0;
  388.  
  389.     windowRef = (WindowRef) eventStrucPtr->message;
  390.  
  391.     if(isApplicationWindow(windowRef,&txnObject))
  392.     {
  393.         becomingActive = ((eventStrucPtr->modifiers & activeFlag) == activeFlag);
  394.         GetWindowProperty(windowRef,kFileCreator,'tFRM',sizeof(TXNFrameID),NULL,&txnFrameID);
  395.         
  396.         if(becomingActive)
  397.             TXNActivate(txnObject,txnFrameID,becomingActive);
  398.         else
  399.             TXNActivate(txnObject,txnFrameID,becomingActive);
  400.  
  401.         TXNFocus(txnObject,becomingActive);
  402.     }
  403. }
  404.  
  405. // ********************************************************************************** doUpdate
  406.  
  407. void  doUpdate(EventRecord *eventStrucPtr)
  408. {
  409.     WindowRef    windowRef;
  410.     GrafPtr        oldPort;
  411.     TXNObject    txnObject = NULL;
  412.  
  413.     windowRef = (WindowRef) eventStrucPtr->message;
  414.  
  415.     GetPort(&oldPort);
  416.     SetPortWindowPort(windowRef);
  417.  
  418.     if(isApplicationWindow(windowRef,&txnObject))
  419.         TXNUpdate(txnObject);
  420.  
  421.     SetPort(oldPort);
  422. }
  423.  
  424. // *********************************************************************** isApplicationWindow
  425.  
  426. Boolean  isApplicationWindow(WindowRef windowRef,TXNObject *txnObject)
  427. {
  428.     OSStatus osStatus = noErr;
  429.  
  430.     osStatus = GetWindowProperty(windowRef,kFileCreator,'tOBJ',sizeof(TXNObject),NULL,
  431.                                                              txnObject);
  432.  
  433.     return (windowRef != NULL) && (GetWindowKind(windowRef) == kApplicationWindowKind);
  434. }
  435.  
  436. // ***************************************************************************** doAboutDialog
  437.  
  438. void  doAboutDialog(void)
  439. {
  440.     DialogRef    dialogRef;
  441.     SInt16        itemHit;
  442.  
  443.     dialogRef = GetNewDialog(rAboutDialog,NULL,(WindowRef) -1);
  444.     ModalDialog(NULL,&itemHit);
  445.     DisposeDialog(dialogRef);
  446. }
  447.  
  448. // ************************************************************************ doSynchroniseFiles
  449.  
  450. void  doSynchroniseFiles(void)
  451. {
  452.     UInt32                currentTicks;
  453.     WindowRef            windowRef;
  454.     static UInt32    nextSynchTicks = 0;
  455.     OSStatus            hasNoAliasHdl = noErr;
  456.     Boolean                aliasChanged;
  457.     AliasHandle        aliasHdl = NULL;
  458.     FSSpec                newFSSpec;
  459.     OSStatus            osStatus = noErr;
  460.     SInt16                trashVRefNum;
  461.     SInt32                trashDirID;
  462.     TXNObject            txnObject = NULL;
  463.  
  464.     currentTicks = TickCount();
  465.     windowRef    = FrontWindow();
  466.  
  467.     if(currentTicks > nextSynchTicks)
  468.     {
  469.         while(windowRef != NULL)
  470.         {
  471.             hasNoAliasHdl = GetWindowProperty(windowRef,kFileCreator,'tALH',sizeof(AliasHandle),
  472.                                                                                 NULL,&aliasHdl);
  473.             if(hasNoAliasHdl)
  474.                 break;
  475.  
  476.             aliasChanged = false;
  477.             ResolveAlias(NULL,aliasHdl,&newFSSpec,&aliasChanged);
  478.             if(aliasChanged)
  479.             {
  480.                 SetWindowProperty(windowRef,kFileCreator,'FiSp',sizeof(FSSpec),&newFSSpec);
  481.                 SetWTitle(windowRef,newFSSpec.name);
  482.             }
  483.  
  484.             osStatus = FindFolder(kUserDomain,kTrashFolderType,kDontCreateFolder,
  485.                                                         &trashVRefNum,&trashDirID);
  486.  
  487.             if(osStatus == noErr)
  488.             {
  489.                 do
  490.                 {
  491.                     if(newFSSpec.parID == fsRtParID)
  492.                         break;
  493.  
  494.                     if((newFSSpec.vRefNum == trashVRefNum) && (newFSSpec.parID == trashDirID))
  495.                     {
  496.                         GetWindowProperty(windowRef,kFileCreator,'tOBJ',sizeof(TXNObject),NULL,
  497.                                                             &txnObject);
  498.                         TXNDeleteObject(txnObject);
  499.                         DisposeWindow(windowRef);
  500.                         gCurrentNumberOfWindows --;
  501.                         break;
  502.                     }
  503.                 } while(FSMakeFSSpec(newFSSpec.vRefNum,newFSSpec.parID,"\p",&newFSSpec) == noErr);
  504.             }
  505.  
  506.             windowRef = GetNextWindow(windowRef);
  507.         }
  508.  
  509.         nextSynchTicks = currentTicks + 15;
  510.     }
  511. }
  512.  
  513. // *********************************************************************** openAppEventHandler
  514.  
  515. OSStatus  openAppEventHandler(AppleEvent *appEvent,AppleEvent *reply,SInt32 handlerRefCon)
  516. {
  517.     OSStatus    osStatus = noErr;
  518.  
  519.     osStatus = doHasGotRequiredParams(appEvent);
  520.     if(osStatus == noErr)
  521.         osStatus = doNewCommand();
  522.  
  523.     return osStatus;
  524. }
  525.  
  526. // ********************************************************************* reopenAppEventHandler
  527.  
  528. OSStatus  reopenAppEventHandler(AppleEvent *appEvent,AppleEvent *reply,
  529.                                                                 SInt32 handlerRefCon)
  530. {
  531.     OSStatus    osStatus = noErr;
  532.  
  533.     osStatus = doHasGotRequiredParams(appEvent);
  534.     if(osStatus == noErr)
  535.         if(!FrontWindow())
  536.             osStatus = doNewCommand();
  537.  
  538.     return osStatus;
  539. }
  540.  
  541. // ************************************************************** openAndPrintDocsEventHandler
  542.  
  543. OSStatus  openAndPrintDocsEventHandler(AppleEvent *appEvent,AppleEvent *reply,
  544.                                                                              SInt32 handlerRefcon)
  545. {
  546.     FSSpec            fileSpec;
  547.     AEDescList    docList;
  548.     OSStatus        osStatus, ignoreErr;
  549.     SInt32            index, numberOfItems;
  550.     Size                actualSize;
  551.     AEKeyword        keyWord;
  552.     DescType        returnedType;
  553.     FInfo                fileInfo;
  554.     TXNObject        txnObject;
  555.  
  556.     osStatus = AEGetParamDesc(appEvent,keyDirectObject,typeAEList,&docList);
  557.  
  558.     if(osStatus == noErr)
  559.     {
  560.         osStatus = doHasGotRequiredParams(appEvent);
  561.         if(osStatus == noErr)
  562.         {
  563.             osStatus = AECountItems(&docList,&numberOfItems);
  564.             if(osStatus == noErr)
  565.             {
  566.                 for(index=1;index<=numberOfItems;index++)
  567.                 {
  568.                     osStatus = AEGetNthPtr(&docList,index,typeFSS,&keyWord,&returnedType,
  569.                                                                  &fileSpec,sizeof(fileSpec),&actualSize);
  570.                     if(osStatus == noErr)
  571.                     {
  572.                         osStatus = FSpGetFInfo(&fileSpec,&fileInfo);
  573.                         if(osStatus == noErr)
  574.                         {
  575.                             if(osStatus = doOpenFile(fileSpec,fileInfo.fdType))
  576.                                 doErrorAlert(osStatus);
  577.                             
  578.                             if(osStatus == noErr && handlerRefcon == kPrint)
  579.                             {
  580.                                 if(isApplicationWindow(FrontWindow(),&txnObject))
  581.                                 {
  582.                                     if(osStatus = TXNPrint(txnObject))
  583.                                         doErrorAlert(osStatus);
  584.                                         
  585.                                     if(osStatus = doCloseCommand(kNavSaveChangesOther))
  586.                                         doErrorAlert(osStatus);
  587.                                 }
  588.                             }
  589.                         }
  590.                     }
  591.                     else
  592.                         doErrorAlert(osStatus);
  593.                 }
  594.             }
  595.         }
  596.         else
  597.             doErrorAlert(osStatus);
  598.  
  599.         ignoreErr = AEDisposeDesc(&docList);
  600.     }
  601.     else
  602.         doErrorAlert(osStatus);
  603.  
  604.     return osStatus;
  605. }
  606.  
  607. // *********************************************************************** quitAppEventHandler
  608.  
  609. OSStatus  quitAppEventHandler(AppleEvent *appEvent,AppleEvent *reply,SInt32 handlerRefcon)
  610. {
  611.     OSStatus    osStatus = noErr;
  612.  
  613.     osStatus = doHasGotRequiredParams(appEvent);
  614.     if(osStatus == noErr)
  615.     {
  616.         while(FrontWindow())
  617.         {
  618.             osStatus = doCloseCommand(kNavSaveChangesQuittingApplication);
  619.  
  620.             if(osStatus != noErr && osStatus != kNavAskSaveChangesCancel)
  621.                 doErrorAlert(osStatus);
  622.             if(osStatus == kNavAskSaveChangesCancel)
  623.                 return noErr;
  624.         }
  625.     }
  626.  
  627.     gDone = true;
  628.  
  629.     return osStatus;
  630. }
  631.  
  632. // ******************************************************************** doHasGotRequiredParams
  633.  
  634. OSStatus  doHasGotRequiredParams(AppleEvent *appEvent)
  635. {
  636.     DescType    returnedType;
  637.     Size            actualSize;
  638.     OSStatus    osStatus = noErr;
  639.  
  640.     osStatus = AEGetAttributePtr(appEvent,keyMissedKeywordAttr,typeWildCard,&returnedType,
  641.                                                              NULL,0,&actualSize);
  642.     if(osStatus == errAEDescNotFound)
  643.         osStatus = noErr;
  644.     else if(osStatus == noErr)
  645.         osStatus = errAEParamMissed;
  646.  
  647.     return osStatus;
  648. }
  649.  
  650. // ****************************************************************************** doErrorAlert
  651.  
  652. void  doErrorAlert(SInt16 errorCode)
  653. {
  654.     Str255    errorString, theString;
  655.     SInt16    itemHit;
  656.  
  657.     if(errorCode == kATSUFontsMatched)
  658.         return;
  659.  
  660.     if(errorCode == eInstallHandler)
  661.         GetIndString(errorString,rErrorStrings,1);
  662.     else if(errorCode == eMaxWindows)
  663.         GetIndString(errorString,rErrorStrings,2);
  664.     else if(errorCode == eCantFindFinderProcess)
  665.         GetIndString(errorString,rErrorStrings,3);
  666.     else
  667.     {
  668.         GetIndString(errorString,rErrorStrings,4);
  669.         NumToString((SInt32) errorCode,theString);
  670.         doConcatPStrings(errorString,theString);
  671.     }
  672.  
  673.     if(errorCode != memFullErr)
  674.         StandardAlert(kAlertCautionAlert,errorString,NULL,NULL,&itemHit);
  675.     else
  676.     {
  677.         StandardAlert(kAlertStopAlert,errorString,NULL,NULL,&itemHit);
  678.         ExitToShell();
  679.     }
  680. }
  681.  
  682. // ***************************************************************************** doCopyPString
  683.  
  684. void  doCopyPString(Str255 sourceString,Str255 destinationString)
  685. {
  686.     SInt16    stringLength;
  687.  
  688.     stringLength = sourceString[0];
  689.     BlockMove(sourceString + 1,destinationString + 1,stringLength);
  690.     destinationString[0] = stringLength;
  691. }
  692.  
  693. // ************************************************************************** doConcatPStrings
  694.  
  695. void  doConcatPStrings(Str255 targetString,Str255 appendString)
  696. {
  697.     SInt16    appendLength;
  698.  
  699.     appendLength = MIN(appendString[0],255 - targetString[0]);
  700.  
  701.     if(appendLength > 0)
  702.     {
  703.         BlockMoveData(appendString+1,targetString+targetString[0]+1,(SInt32) appendLength);
  704.         targetString[0] += appendLength;
  705.     }
  706. }
  707.  
  708. // *******************************************************************************************