home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-174.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  47.5 KB  |  1,442 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Sun, 04 Oct 92       Volume 1 : Issue 174
  2.  
  3. Today's Topics:
  4.  
  5.     Looking for some sample appletalk ATP code...
  6.     MacinTalk MPW C Interfaces
  7.     screenBits, off-screen drawing and memory allocation
  8.     ZREF error
  9.     Getting my hands on the real CLUT
  10.     FSpExchangeFiles Problem
  11.     Accepting AppleEvents?
  12.  
  13.  
  14.  
  15. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  16.  
  17. The digest is a collection of article threads from the internet newsgroup
  18. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  19. regularly and want an archive of the discussions.  If you don't know what a
  20. newsgroup is, you probably don't have access to it.  Ask your systems
  21. administrator(s) for details.  (This means you can't post questions to the
  22. digest.)
  23.  
  24. Each issue of the digest contains one or more sets of articles (called
  25. threads), with each set corresponding to a 'discussion' of a particular
  26. subject.  The articles are not edited; all articles included in this digest
  27. are in their original posted form (as received by our news server at
  28. cs.uoregon.edu).  Article threads are not added to the digest until the last
  29. article added to the thread is at least one month old (this is to ensure that
  30. the thread is dead before adding it to the digest).  Article threads that
  31. consist of only one message are generally not included in the digest.
  32.  
  33. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  34. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  35. file /pub/mac/csmp-digest/README before downloading any files.  The most
  36. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  37. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  38. archive has a mail server; send a message with the text '$MACarch help' (no
  39. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  40.  
  41. The digest is also available via email.  Just send a note saying that you
  42. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  43. automatically receive each new issue as it is created.  Sorry, back issues
  44. are not available through the mailing list.
  45.  
  46. Send administrative mail to mkelly@cs.uoregon.edu.
  47.  
  48.  
  49. -------------------------------------------------------
  50.  
  51. From: bratton@sparc3.cs.uiuc.edu (Alex Bratton)
  52. Subject: Looking for some sample appletalk ATP code...
  53. Organization: University of Illinois at Urbana-Champaign
  54. Date: Tue, 1 Sep 1992 03:36:35 GMT
  55.  
  56. I've been doing some work with ATP, trying to get a socket opened and the
  57. name registered.  It returns noErr, but when I examine the network from
  58. another computer, the new socket doesn't show up.  It also produces an
  59. error (no matching name) when I try to unregister the name.
  60.  
  61. If you have some sample code (ATP) that opens, registers, and dumps some
  62. data, I'd really appreciate seeing it.  This has been bugging me for a while
  63. and I think I need to look at some working code to see what I'm missing.
  64.  
  65. I'm sticking with ATP to insure system 6 & 7 compatability.
  66.  
  67. Thanks,
  68. Alex Bratton
  69.  
  70. +++++++++++++++++++++++++++
  71.  
  72. From: cheshire@cs.stanford.edu (Stuart Cheshire)
  73. Date: 2 Sep 92 17:58:33 GMT
  74. Organization: Stanford University
  75.  
  76. In article <1992Sep1.033635.28604@sunb10.cs.uiuc.edu> Alex Bratton,
  77. bratton@sparc3.cs.uiuc.edu writes:
  78. >If you have some sample code (ATP) that opens, registers, and dumps some
  79. >data, I'd really appreciate seeing it.  This has been bugging me for a
  80. while
  81. >and I think I need to look at some working code to see what I'm missing.
  82.  
  83. Here is some sample code which includes ATP calls. It is the code I use
  84. to obtain the list of AppleTalk zones to display in my game Bolo, and
  85. judging by the time it took to get all the wrinkles worked out, and make
  86. it run with both Phase 1 and Phase 2, it probably should be in some
  87. sample code library somewhere for other people's use.
  88.  
  89. The ATP calls are in the Phase 1 part, which has to communicate directly
  90. with the bridge via ATP.
  91.  
  92. The code gets the list of zones, sorts them into alphabetical order using
  93. heap sort, and then appends them in order to the list identified by the
  94. parameter "zonelist", which should be initialized before calling
  95. getzonelist.
  96.  
  97. The code is written for Think C 5.
  98.  
  99. #include <AppleTalk.h>
  100.  
  101. #define local static
  102. #define export
  103. #define import extern
  104.  
  105. typedef struct
  106.     {
  107.     BYTE sysLAPAddr;
  108.     BYTE destnode;
  109.     BYTE srcnode;
  110.     BYTE ALAPproto;
  111.     WORD length;
  112.     union
  113.         {
  114.         struct
  115.             {
  116.             BYTE destsocket;
  117.             BYTE srcsocket;
  118.             BYTE DPPproto;
  119.             BYTE userdata[15];
  120.             } shortheader;
  121.         struct
  122.             {
  123.             WORD checksum;
  124.             WORD destnet;
  125.             WORD srcnet;
  126.             BYTE destnode;
  127.             BYTE srcnode;
  128.             BYTE destsocket;
  129.             BYTE srcsocket;
  130.             BYTE DPPproto;
  131.             BYTE userdata[7];
  132.             } longheader;
  133.         } u;
  134.     BYTE unused;
  135.     BYTE sysABridge;
  136.     WORD sysNetNum;
  137.     WORD vSCCEnable;
  138.     } MPPglobals;
  139.  
  140. extern MPPglobals *ABusVars : 0x2D8;
  141.  
  142. #define        atpMaxData                578            // size of buffer for zone names
  143. #define        kZIPSocket                6            // the Zone Information Protocol socket
  144. #define        kATPTimeOutVal            3            // re-try ATP SendRequest every 3 seconds
  145. #define        kATPRetryCount            5            // for five times
  146. #define        kGZLCall                0x08000000    // GetZoneList indicator
  147. #define        kGMZCall                0x07000000    // GetMyZone indicator
  148. #define        kZoneCount                0x0000FFFF     // mask to count zones in buffer
  149. #define        kNoMoreZones            0xFF000000     // mask to see if more zones to come
  150.  
  151. #define xCall               246
  152. #define zipGetLocalZones    5
  153. #define zipGetZoneList      6
  154. #define zipGetMyZone        7
  155.  
  156. typedef struct
  157.     {
  158.     QElemPtr         qLink;
  159.     short            qType;
  160.     short            ioTrap;
  161.     Ptr              ioCmdAddr;
  162.     ProcPtr          ioCompletion;
  163.     OSErr            ioResult;
  164.     StringPtr        ioNamePtr;
  165.     short            ioVRefNum;
  166.     short            ioRefNum;
  167.     short            csCode;
  168.     short            xppSubCode;
  169.     unsigned char    xppTimeOut;
  170.     unsigned char    xppRetry;
  171.     short            filler;
  172.     Ptr              zipBuffPtr;
  173.     short            zipNumZones;
  174.     short            zipLastFlag;
  175.     short            zipInfoField[35];
  176.     } xCallParam;
  177.  
  178. #define MAX_ZONES 1000
  179. typedef struct { unsigned char c[34]; } ZONE_NAME;
  180. ZONE_NAME *zone_array, **zone_heap;
  181. local int num_zones;
  182.  
  183. local void addtoheap(int place, ZONE_NAME *new)
  184.     {
  185.     int parent = (place-1)>>1;
  186.     zone_heap[place]=new;
  187.     while (place>0 && IUCompString(zone_heap[parent]->c,
  188. zone_heap[place]->c)>0)
  189.         {
  190.         ZONE_NAME *temp   = zone_heap[place ];
  191.         zone_heap[place ] = zone_heap[parent];
  192.         zone_heap[parent] = temp;
  193.         place=parent;
  194.         parent=(place-1)>>1;
  195.         }
  196.     }
  197.  
  198. local ZONE_NAME *removefromheap(int last)    // last is index of last item
  199. on heap
  200.     {
  201.     ZONE_NAME *top = zone_heap[0];            // extract top element
  202.     int gap   = 0;                            // top is now empty
  203.     int left  = 1;
  204.     int right = 2;
  205.     while(left<=last)                        // move gap to bottom
  206.         {
  207.         if(right>last || IUCompString(zone_heap[right]->c,
  208. zone_heap[left]->c)>0)
  209.             { zone_heap[gap]=zone_heap[left ]; gap=left;  }
  210.         else{ zone_heap[gap]=zone_heap[right]; gap=right; }
  211.         left  = (gap<<1)+1;
  212.         right = left + 1;
  213.         }
  214.     if(last != gap) addtoheap(gap, zone_heap[last]);    // fill gap
  215.     return(top);    // and heap is now one element smaller
  216.     }
  217.  
  218. local void BuildZoneListPhase1(unsigned char *myzone)
  219.     {
  220.     ATPParamBlock    pb;
  221.     BDSElement        dBDS;
  222.     unsigned char    datapacket[atpMaxData];
  223.     short            zIndex=1, zCount=0, i;
  224.  
  225.     dBDS.buffSize    = atpMaxData;
  226.     dBDS.buffPtr     = (Ptr)datapacket;
  227.  
  228.     pb.ATPatpFlags   = 0;
  229.     pb.ATPreqLength  = 0;
  230.     pb.ATPreqPointer = NULL;
  231.     pb.ATPbdsPointer = (Ptr) &dBDS;
  232.     pb.ATPnumOfBuffs = 1;
  233.     pb.ATPtimeOutVal = kATPTimeOutVal;
  234.     pb.ATPretryCount = kATPRetryCount;
  235.  
  236.     pb.ATPaddrBlock.aNet    = ABusVars->sysNetNum;
  237.     pb.ATPaddrBlock.aNode   = GetBridgeAddress();
  238.     pb.ATPaddrBlock.aSocket = kZIPSocket;
  239.  
  240.     if (!pb.ATPaddrBlock.aNode) return;        // no bridge -- no zones
  241.  
  242.     do    {
  243.         unsigned char *ptr = datapacket;
  244.         pb.ATPuserData = kGZLCall + zIndex;
  245.         PSendRequest(&pb, false);
  246.         zCount += dBDS.userBytes & kZoneCount;
  247.         while(zIndex++ <= zCount)
  248.             {
  249.             int count = 1 + *ptr;
  250.             unsigned char *dest = zone_array[num_zones].c;
  251.             while (count-- > 0) *dest++ = *ptr++;
  252.             addtoheap(num_zones, &zone_array[num_zones]);
  253.             num_zones++;
  254.             }
  255.         } until(dBDS.userBytes & kNoMoreZones);
  256.     
  257.     pb.ATPuserData = kGMZCall;
  258.     datapacket[0] = 0;
  259.     if (PSendRequest(&pb, false) == noErr && datapacket[0] &&
  260. datapacket[0]<32)
  261.         for (i=0; i<=datapacket[0]; i++) myzone[i] = datapacket[i];
  262.     }
  263.  
  264. local void BuildZoneListPhase2(unsigned char *myzone)
  265.     {
  266.     short XPPRefNum;
  267.     xCallParam        xpb;
  268.     unsigned char    datapacket[atpMaxData];
  269.     short            zIndex=1, zCount=0;
  270.     
  271.     if (OpenDriver("\p.XPP", &XPPRefNum)) return;
  272.  
  273.     xpb.zipInfoField[0] = 0;
  274.     xpb.zipLastFlag = FALSE;
  275.     xpb.ioRefNum    = XPPRefNum;
  276.     xpb.csCode      = xCall;
  277.     xpb.xppSubCode  = zipGetZoneList;
  278.     xpb.xppTimeOut  = kATPTimeOutVal;
  279.     xpb.xppRetry    = kATPRetryCount;
  280.     xpb.zipBuffPtr  = (Ptr)datapacket;
  281.  
  282.     while (!xpb.zipLastFlag && !PBControl((ParmBlkPtr)&xpb, FALSE))
  283.         {
  284.         unsigned char *ptr = datapacket;
  285.         zCount += xpb.zipNumZones;
  286.         while(zIndex++ <= zCount)
  287.             {
  288.             int count = 1 + *ptr;
  289.             unsigned char *dest = zone_array[num_zones].c;
  290.             while (count-- > 0) *dest++ = *ptr++;
  291.             addtoheap(num_zones, &zone_array[num_zones]);
  292.             num_zones++;
  293.             }
  294.         }
  295.  
  296.     xpb.zipInfoField[0] = 0;
  297.     xpb.xppSubCode  = zipGetMyZone;
  298.     xpb.zipBuffPtr  = (Ptr)myzone;
  299.     PBControl((ParmBlkPtr)&xpb, FALSE);
  300.     // Mustn't close XPP driver (see IM V 532)
  301.     }
  302.  
  303. local short addrow(ListHandle list, unsigned char *newdata)
  304.     {
  305.     Point pt = { 0, 0 };
  306.     pt.v = (*list)->dataBounds.bottom;
  307.     LAddRow(1, pt.v, list);
  308.     LSetCell(newdata+1, newdata[0], pt, list);
  309.     return(pt.v);
  310.     }
  311.  
  312. export int getzonelist(ListHandle zonelist)
  313.     {
  314.     unsigned char myzone[33];
  315.     Point pt = { 0, 0 };
  316.     SysEnvRec sysenvirons;
  317.     SysEnvirons(1, &sysenvirons);
  318.     zone_array = (ZONE_NAME  *) NewPtr(MAX_ZONES * sizeof(ZONE_NAME  ));
  319.     zone_heap  = (ZONE_NAME **) NewPtr(MAX_ZONES * sizeof(ZONE_NAME *));
  320.     myzone[0] = num_zones = 0;
  321.     if (sysenvirons.atDrvrVersNum < 53) BuildZoneListPhase1(myzone);
  322.     else                                BuildZoneListPhase2(myzone);
  323.     
  324.     while (num_zones-->0) addrow(zonelist, removefromheap(num_zones)->c);
  325.     DisposPtr((Ptr)zone_array);
  326.     DisposPtr((Ptr)zone_heap);
  327.  
  328.     LSearch(myzone+1, *myzone, NULL, &pt, zonelist);
  329.     LSetSelect(TRUE, pt, zonelist);
  330.     LAutoScroll(zonelist);
  331.     return(pt.v);
  332.     }
  333.  
  334.  
  335. Stuart Cheshire <cheshire@cs.stanford.edu>
  336.  * Liliore Green Rains Houses Resident Computer Coordinator
  337.  * Stanford Distributed Systems Group Research Assistant
  338.  * Macintosh Programmer
  339.  
  340. +++++++++++++++++++++++++++
  341.  
  342. From: Stuart Cheshire <cheshire@cs.stanford.edu>
  343. Organization: Stanford University
  344. Date: Wed, 2 Sep 92 18:11:08 GMT
  345.  
  346. In article <1992Sep1.033635.28604@sunb10.cs.uiuc.edu> Alex Bratton,
  347. bratton@sparc3.cs.uiuc.edu writes:
  348. >If you have some sample code (ATP) that opens, registers, and dumps some
  349. >data, I'd really appreciate seeing it.  This has been bugging me for a
  350. while
  351. >and I think I need to look at some working code to see what I'm missing.
  352.  
  353. Here is some more sample code, which opens and registers an ATP socket.
  354. It is from the Macintosh User Authenticator mentioned in a previous post
  355. be me.
  356.  
  357. The code is written for Think C 5.
  358.  
  359. #include <Traps.h>
  360. #include <GestaltEqu.h>
  361. #include <Folders.h>
  362. #include <AppleTalk.h>
  363.  
  364. #define local static
  365. #define export
  366. #define import extern
  367. typedef unsigned char  BYTE;
  368. typedef unsigned short WORD;
  369. typedef unsigned long  DWORD;
  370. #define until(A) while (!(A))
  371.  
  372. typedef struct
  373.     {
  374.     BYTE sysLAPAddr;
  375.     BYTE destnode;
  376.     BYTE srcnode;
  377.     BYTE ALAPproto;
  378.     WORD length;
  379.     union
  380.         {
  381.         struct
  382.             {
  383.             BYTE destsocket;
  384.             BYTE srcsocket;
  385.             BYTE DPPproto;
  386.             BYTE userdata[15];
  387.             } shortheader;
  388.         struct
  389.             {
  390.             WORD checksum;
  391.             WORD destnet;
  392.             WORD srcnet;
  393.             BYTE destnode;
  394.             BYTE srcnode;
  395.             BYTE destsocket;
  396.             BYTE srcsocket;
  397.             BYTE DPPproto;
  398.             BYTE userdata[7];
  399.             } longheader;
  400.         } u;
  401.     BYTE unused;
  402.     BYTE sysABridge;
  403.     WORD sysNetNum;
  404.     WORD vSCCEnable;
  405.     } MPPglobals;
  406.  
  407. extern MPPglobals *ABusVars : 0x2D8;
  408.  
  409. typedef struct
  410.     {
  411.     ATPParamBlock p;
  412.     long *myglobals;
  413.     } myATPParamBlock;
  414.  
  415. local NamesTableEntry myNTE;    /* DONT TOUCH THIS -- IT'S USED CONTINUOUSLY
  416. BY NBP */
  417.  
  418. // name must be 8 characters long
  419. local void construct_name(AddrBlock addr, unsigned char *name)
  420.     {
  421.     static unsigned char hextable[] = "0123456789ABCDEF";
  422.     name[0] = 7;
  423.     name[1] = hextable[(addr.aNet  >> 12) & 0xF];
  424.     name[2] = hextable[(addr.aNet  >>  8) & 0xF];
  425.     name[3] = hextable[(addr.aNet  >>  4) & 0xF];
  426.     name[4] = hextable[(addr.aNet  >>  0) & 0xF];
  427.     name[5] = '.';
  428.     name[6] = hextable[(addr.aNode >>  4) & 0xF];
  429.     name[7] = hextable[(addr.aNode >>  0) & 0xF];
  430.     }
  431.  
  432. local void awaitrequest(void);
  433. local void acceptrequest(void)
  434.     {
  435.     static char dummy;
  436.     static BDSElement bds;
  437.     
  438.     myATPParamBlock *atp_pb;
  439.     long *saveGptr;
  440.     asm    {    move.l    GLOBREG, saveGptr
  441.             move.l    a0, atp_pb
  442.             move.l    myATPParamBlock.myglobals(a0), GLOBREG
  443.         }
  444.     
  445.     // if (atp_pb->p.ATPioResult) What to do if error?
  446.  
  447. // do whatever you want here to prepare your response...
  448.     
  449.     bds.buffSize  = sizeof(dummy);
  450.     bds.buffPtr   = (Ptr)&dummy;
  451.     bds.dataSize  = 0;
  452.     bds.userBytes = 0;
  453.     
  454.     atp_pb->p.ATPioCompletion = awaitrequest;
  455.     atp_pb->p.ATPatpFlags   = atpEOMvalue;
  456.     atp_pb->p.ATPbdsPointer = (Ptr)&bds;
  457.     atp_pb->p.ATPnumOfBuffs = 1;
  458.     atp_pb->p.ATPbdsSize    = 1;
  459.     
  460.     PSendResponse(&atp_pb->p, TRUE);
  461.  
  462.     asm { move.l saveGptr, GLOBREG }
  463.     }
  464.  
  465. local void awaitrequest(void)
  466.     {
  467.     static MACAUTH_REQUEST req;
  468.     myATPParamBlock *atp_pb;
  469.     long *saveGptr;
  470.     asm    {    move.l    GLOBREG, saveGptr
  471.             move.l    a0, atp_pb
  472.             move.l    myATPParamBlock.myglobals(a0), GLOBREG
  473.         }
  474.     atp_pb->p.ATPioCompletion = acceptrequest;
  475.     atp_pb->p.ATPatpSocket    = myNTE.nt.nteAddress.aSocket;
  476.     atp_pb->p.ATPreqLength    = sizeof(req);
  477.     atp_pb->p.ATPreqPointer   = (Ptr)&req;
  478.     PGetRequest(&atp_pb->p, TRUE);
  479.     asm { move.l saveGptr, GLOBREG }
  480.     }
  481.  
  482. local OSErr AppleTalkInit(void)    // returns non-zero if init failed
  483.     {
  484.     OSErr retcode;
  485.     short MPPRefNum;
  486.     MPPParamBlock p;
  487.     ATPParamBlock atp;
  488.     static myATPParamBlock req_pb;
  489.     static AddrBlock zeroaddress;
  490.     static unsigned char regname[8];
  491.     
  492.     if (retcode = OpenDriver("\p.MPP", &MPPRefNum))
  493.         { DebugStr("\pCouldn't open AppleTalk driver"); return(retcode); }
  494.  
  495.     p.SETSELF.newSelfFlag = TRUE;
  496.     PSetSelfSend(&p, FALSE);     // no need to abort if this fails
  497.     
  498.     atp.ATPatpSocket = 0;
  499.     atp.ATPaddrBlock = zeroaddress;
  500.     if (retcode = POpenATPSkt(&atp, FALSE))
  501.         { DebugStr("\pCouldn't open ATP socket"); return(retcode); }
  502.  
  503.     myNTE.nt.nteAddress.aNet    = ABusVars->sysNetNum;
  504.     myNTE.nt.nteAddress.aNode   = ABusVars->sysLAPAddr;
  505.     myNTE.nt.nteAddress.aSocket = atp.ATPatpSocket;
  506.     
  507.     construct_name(myNTE.nt.nteAddress, regname);
  508.  
  509.     NBPSetNTE((Ptr)&myNTE,
  510.         (Ptr)regname, (Ptr)"\pMacintosh Authenticator", (Ptr)"\p*",
  511.         myNTE.nt.nteAddress.aSocket);
  512.     
  513.     p.NBPinterval    = 2;
  514.     p.NBPcount       = 2;
  515.     p.NBPntQElPtr    = (Ptr)&myNTE;
  516.     p.NBPverifyFlag  = TRUE;
  517.     if (retcode = PRegisterName(&p, FALSE))
  518.         { DebugStr("\pCouldn't Register name"); return(retcode); }
  519.  
  520.     asm    {    move.l    GLOBREG, req_pb.myglobals
  521.             lea        req_pb, a0
  522.             bsr        awaitrequest
  523.         }
  524.     }
  525.  
  526.  
  527. Stuart Cheshire <cheshire@cs.stanford.edu>
  528.  * Liliore Green Rains Houses Resident Computer Coordinator
  529.  * Stanford Distributed Systems Group Research Assistant
  530.  * Macintosh Programmer
  531.  
  532. ---------------------------
  533.  
  534. From: sc5h+@andrew.cmu.edu (Shawn James Cokus)
  535. Subject: MacinTalk MPW C Interfaces
  536. Date: 1 Sep 92 06:33:27 GMT
  537. Organization: Sophomore, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  538.  
  539.  
  540. After searching far and wide on Developer CD's (well, just the one I
  541. have access to, Vol. X) and Archie FTP servers, I have been at a total
  542. loss to find a header file for MacinTalk for MPW C and the (I believe)
  543. accompanying glue/library code that goes along with it.  If anyone could
  544. tell me where to get such a beast, or even point me to some C interfaces
  545. that I could convert to MPW C form, it would be most appreciated.
  546.  
  547. Thanks,
  548. - --Shawn.
  549. - --sc5h+@andrew.cmu.edu.
  550.  
  551.  
  552. - -- Shawn Cokus
  553. - --   sc5h+@andrew.cmu.edu
  554. - --   Carnegie-Mellon University, Pittsburgh, PA
  555. - --   (Witty phrase temporarily out of order.)
  556.  
  557. +++++++++++++++++++++++++++
  558.  
  559. From: ksand@apple.com (Kent Sandvik)
  560. Date: 2 Sep 92 00:35:08 GMT
  561. Organization: Apple
  562.  
  563. In article <EecrwrC00YV7Q1Vq9v@andrew.cmu.edu>, sc5h+@andrew.cmu.edu (Shawn
  564. James Cokus) wrote:
  565. > After searching far and wide on Developer CD's (well, just the one I
  566. > have access to, Vol. X) and Archie FTP servers, I have been at a total
  567. > loss to find a header file for MacinTalk for MPW C and the (I believe)
  568. > accompanying glue/library code that goes along with it.  If anyone could
  569. > tell me where to get such a beast, or even point me to some C interfaces
  570. > that I could convert to MPW C form, it would be most appreciated.
  571.  
  572. The headers were shipped with the ADPA product. Macintalk does not 
  573. run well under System 7 (especially with VM on), however there are 
  574. hackers who have gone around the problems (like the Moose developers).
  575.  
  576. The official DTS message is "stay tuned for something better".
  577.  
  578. Kent Sandvik/DTS
  579.  
  580. ---------------------------
  581.  
  582. From: Jerome Chan <yjc@po.cwru.edu>
  583. Subject: screenBits, off-screen drawing and memory allocation
  584. Organization: Alethea, The Twilight World!
  585. Date: Wed, 15 Jul 92 16:51:21 GMT
  586.  
  587.   In the case of multiple monitors, how do I get their various dimensions
  588. and locations? Does screenBits.bounds contain a RECT that includes all
  589. monitors available? I want to draw into an off-screen area but I don't
  590. want to draw onto another monitor for multi-monitor configurations. I
  591. don't have the hardware to test this. :)
  592.  
  593.   When a system trap causes memory to be compacted, only the current
  594. application's heap zone is affected right?
  595.  
  596.  
  597. - --NewBie Mac Programmer at Large--
  598. - --Day 3 and Still Going
  599.  
  600. - ---
  601.  Fading
  602.  
  603. "No Lah! Sure or not one? Dunno leh! Nebber Mind! Like that one!
  604. Terriblur Lah!"
  605.  
  606. +++++++++++++++++++++++++++
  607.  
  608. From: Bruce.Hoult@bbs.actrix.gen.nz
  609. Organization: Actrix Information Exchange
  610. Date: Thu, 16 Jul 1992 04:27:11 GMT
  611.  
  612. In article <1992Jul15.165121.5717@usenet.ins.cwru.edu> Jerome Chan <yjc@po.cwru.edu> writes:
  613. >   In the case of multiple monitors, how do I get their various dimensions
  614. > and locations? Does screenBits.bounds contain a RECT that includes all
  615. > monitors available?
  616.  
  617. Yes.  The GrayRgn is even better, since it is the real shape.
  618.  
  619.  
  620. >I want to draw into an off-screen area but I don't
  621. > want to draw onto another monitor for multi-monitor configurations. I
  622. > don't have the hardware to test this. :)
  623.  
  624. Offscreen bitmaps exist in a completely diferent coordinate system
  625. to the real screens.  You don't have to worry about them colliding.
  626.  
  627.  
  628. >   When a system trap causes memory to be compacted, only the current
  629. > application's heap zone is affected right?
  630.  
  631.  
  632. Yes.
  633.  
  634. - -- 
  635. Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 477 2116
  636. BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
  637. "Cray's producing a 200 MIPS personal computer with 64MB RAM and a 1 GB
  638. hard disk that fits in your pocket!"   "Great!  Is it PC compatable?"
  639.  
  640. +++++++++++++++++++++++++++
  641.  
  642. From: lari@bach.cs.unc.edu (Humayun Lari)
  643. Date: 17 Jul 92 02:55:23 GMT
  644. Organization: University of North Carolina, Chapel Hill
  645.  
  646. In article <1992Jul16.042711.23168@actrix.gen.nz> Bruce.Hoult@bbs.actrix.gen.nz writes:
  647. >In article <1992Jul15.165121.5717@usenet.ins.cwru.edu> Jerome Chan <yjc@po.cwru.edu> writes:
  648. >>   In the case of multiple monitors, how do I get their various dimensions
  649. >> and locations? Does screenBits.bounds contain a RECT that includes all
  650. >> monitors available?
  651. >
  652. >Yes.  The GrayRgn is even better, since it is the real shape.
  653.  
  654. If I remember correctly, screenBits.bounds is the rectangle of the main
  655. screen -- it doesn't enclose all monitors. Otherwise, programs that create
  656. or center windows based on screenBits.bounds would do rather strange things.
  657. :-)
  658.  
  659. Humayun Lari
  660. (lari@cs.unc.edu)
  661.  
  662. +++++++++++++++++++++++++++
  663.  
  664. From: grobbins@Apple.COM (Grobbins)
  665. Date: 18 Jul 92 02:04:00 GMT
  666. Organization: Core Technical Support
  667.  
  668. In article <1992Jul16.042711.23168@actrix.gen.nz> Bruce.Hoult@bbs.actrix.gen.nz writes:
  669. >In article <1992Jul15.165121.5717@usenet.ins.cwru.edu> Jerome Chan <yjc@po.cwru.edu> writes:
  670. >>   In the case of multiple monitors, how do I get their various dimensions
  671. >> and locations? Does screenBits.bounds contain a RECT that includes all
  672. >> monitors available?
  673. >Yes.  The GrayRgn is even better, since it is the real shape.
  674.  
  675. As Humayun Lari pointed out, screenBits.bounds is the rect of the
  676. main device.  The rgnBBox of the GrayRgn bounds all screens (minus the
  677. menu bar; see the graphic devices chapter of Inside Mac vols. V and VI
  678. for details on the multiple monitor environment.)  Sample code for
  679. walking the GDevice list (to get the rect or bit depth of each screen,
  680. for example) is in the Q&A Stack (available on ftp.apple.com in the
  681. /dts/mac/docs/stacks/ directory.)
  682.  
  683. >>I want to draw into an off-screen area but I don't
  684. >> want to draw onto another monitor for multi-monitor configurations. I
  685. >> don't have the hardware to test this. :)
  686.  
  687. Under System 7, GWorlds are definitely the way to go.  See IM VI, ch 21.
  688.  
  689. >>   When a system trap causes memory to be compacted, only the current
  690. >> application's heap zone is affected right?
  691. >Yes.
  692.  
  693. Remember that toolbox calls may use Temp Memory these days, so potentially
  694. the process manager heap and the system heap could get shuffled by any
  695. call which "moves memory."  Program defensively.
  696.  
  697.  
  698. Grobbins             grobbins@apple.com
  699.  
  700. Usual disclaimers apply.
  701.  
  702.  
  703. +++++++++++++++++++++++++++
  704.  
  705. From: Jerome Chan <yjc@po.cwru.edu>
  706. Organization: Alethea, The Twilight World!
  707. Date: Sat, 18 Jul 92 05:42:58 GMT
  708.  
  709. In article <70192@apple.Apple.COM> Grobbins, grobbins@Apple.COM writes:
  710. >As Humayun Lari pointed out, screenBits.bounds is the rect of the
  711. >main device.  The rgnBBox of the GrayRgn bounds all screens (minus the
  712.  
  713.   So I should get use the bounding rectangle of CURRENT graphics device
  714. if I want to perform screen calculations? And the bounding box of GrayRgn
  715. for a DragWindow call? screenBits can't be used if I want to drag over
  716. several monitors? (* I don't have the HardWare to test :( *)
  717.  
  718. - ---
  719.  Fading
  720.  
  721. "No Lah! Sure or not one? Dunno leh! Nebber Mind! Like that one!
  722. Terriblur Lah!"
  723.  
  724. +++++++++++++++++++++++++++
  725.  
  726. From: lari@bach.cs.unc.edu (Humayun Lari)
  727. Date: 18 Jul 92 16:52:29 GMT
  728. Organization: University of North Carolina, Chapel Hill
  729.  
  730. In article <1992Jul18.054258.12242@usenet.ins.cwru.edu> yjc@po.cwru.edu (Jerome Chan) writes:
  731. >  So I should get use the bounding rectangle of CURRENT graphics device
  732. >if I want to perform screen calculations? 
  733.  
  734. If you want the main screen, use screenBits.bounds; if you want a particular
  735. screen, you should walk the GDevice list and find the screen's rectangle.
  736.  
  737. >And the bounding box of GrayRgn
  738. >for a DragWindow call? screenBits can't be used if I want to drag over
  739. >several monitors? (* I don't have the HardWare to test :( *)
  740.  
  741. If you specify screenBits.bounds as the limit for DragWindow, the Window
  742. Manager is smart enough to use the GrayRgn bounds instead.
  743.  
  744.  
  745. Humayun Lari
  746. (lari@cs.unc.edu)
  747.  
  748. +++++++++++++++++++++++++++
  749.  
  750. From: keith@taligent.com (Keith Rollin)
  751. Date: 18 Jul 92 20:30:25 GMT
  752. Organization: Taligent
  753.  
  754. In article <1992Jul18.054258.12242@usenet.ins.cwru.edu>, yjc@po.cwru.edu (Jerome
  755. Chan) writes:
  756. > In article <70192@apple.Apple.COM> Grobbins, grobbins@Apple.COM writes:
  757. > >As Humayun Lari pointed out, screenBits.bounds is the rect of the
  758. > >main device.  The rgnBBox of the GrayRgn bounds all screens (minus the
  759. >   So I should get use the bounding rectangle of CURRENT graphics device
  760. > if I want to perform screen calculations? And the bounding box of GrayRgn
  761. > for a DragWindow call? screenBits can't be used if I want to drag over
  762. > several monitors? (* I don't have the HardWare to test :( *)
  763.  
  764. While passing a copy of the bounding box of grayRgn to DragWindow is the
  765. "proper" thing to do, passing screenBits.bounds is also OK. See the description
  766. of DragGrayRgn (which DragWindow calls (see IM I-289)) in Inside Mac V.
  767.  
  768. - --
  769. Keith Rollin
  770. Phantom Programmer
  771. Taligent, Inc.
  772.  
  773.  
  774. ---------------------------
  775.  
  776. From: sichase@csa1.lbl.gov (SCOTT I CHASE)
  777. Subject: ZREF error
  778. Date: 19 Jul 92 20:39:37 GMT
  779. Organization: Lawrence Berkeley Laboratory - Berkeley, CA, USA
  780.  
  781. I am a relative newcomer to THINK C.  I have on several occassions gotten
  782. an error message (the verbatim text of which I have forgotten) which
  783. announces a ZREF error and tells me to "Remove Objects."  But having done
  784. that as requested, the problem doesn't go away.  I can only rebuild my 
  785. application by starting over with a new project into which I load the 
  786. identical set of libraries and files.  It is as if the project file itself
  787. was corrupted.
  788.  
  789. How am I generating the state, and how do I fix it without starting over
  790. with a new project?  Thanks in advance.
  791.  
  792. - -Scott
  793.  
  794. - --------------------
  795. Scott I. Chase            "The question seems to be of such a character
  796. SICHASE@CSA2.LBL.GOV        that if I should come to life after my death
  797.                 and some mathematician were to tell me that it
  798.                 had been definitely settled, I think I would
  799.                 immediately drop dead again."      - Vandiver
  800.  
  801. +++++++++++++++++++++++++++
  802.  
  803. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  804. Date: 20 Jul 92 04:00:46 GMT
  805. Organization: Symantec Corp.
  806.  
  807. >>>>> On 19 Jul 92 20:39:37 GMT, sichase@csa1.lbl.gov (SCOTT I CHASE) said:
  808.  
  809.  > I am a relative newcomer to THINK C.  I have on several occassions
  810.  > gotten an error message (the verbatim text of which I have
  811.  > forgotten) which announces a ZREF error and tells me to "Remove
  812.  > Objects."  But having done that as requested, the problem doesn't
  813.  > go away.  I can only rebuild my application by starting over with a
  814.  > new project into which I load the identical set of libraries and
  815.  > files.  It is as if the project file itself was corrupted.
  816.  
  817.  > How am I generating the state, and how do I fix it without starting
  818.  > over with a new project?  Thanks in advance.
  819.  
  820. The infamous ZREF error is caused by an assertion error in some
  821. project manipulation code which is raised when the symbol table
  822. appears to be corrupt. In general, this error is caused by project
  823. corruption of some sort, and in most cases the corruption occurs
  824. during the program's execution. Sometimes this corruption is slight,
  825. so removing objects and recompiling will fix whatever's gone wrong.
  826. Sometimes the project must be trashed and rebuilt from scratch.
  827.  
  828. If you're seeing this error often, even after rebuilding your project
  829. from scratch, and if you have a large project (usually the two go hand
  830. in hand), you should make sure that you have a copy of your project
  831. which is never run, just compiled. I would have a backup that you
  832. update every day (week, whatever) which you can always fall back on if
  833. things get messed up, until you can find the bug that's causing the
  834. problem.
  835.  
  836.     -phil
  837. - --
  838.    Phil Shapiro                                   Software Engineer
  839.    Language Products Group                     Symantec Corporation
  840.            Internet: phils@cs.brandeis.edu
  841.  
  842. +++++++++++++++++++++++++++
  843.  
  844. From: mspace@netcom.com (Brian Hall)
  845. Date: 20 Jul 92 05:54:28 GMT
  846. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  847.  
  848. phils@chaos.cs.brandeis.edu (Phil Shapiro) writes:
  849.  
  850. >>>>>> On 19 Jul 92 20:39:37 GMT, sichase@csa1.lbl.gov (SCOTT I CHASE) said:
  851.  
  852. > > I am a relative newcomer to THINK C.  I have on several occassions
  853. > > gotten an error message (the verbatim text of which I have
  854. > > forgotten) which announces a ZREF error and tells me to "Remove
  855. > > Objects."  But having done that as requested, the problem doesn't
  856. > > go away.  I can only rebuild my application by starting over with a
  857. > > new project into which I load the identical set of libraries and
  858. > > files.  It is as if the project file itself was corrupted.
  859.  
  860. > > How am I generating the state, and how do I fix it without starting
  861. > > over with a new project?  Thanks in advance.
  862.  
  863. >The infamous ZREF error is caused by an assertion error in some
  864. >project manipulation code which is raised when the symbol table
  865. >appears to be corrupt. In general, this error is caused by project
  866. >corruption of some sort, and in most cases the corruption occurs
  867. >during the program's execution. Sometimes this corruption is slight,
  868. >so removing objects and recompiling will fix whatever's gone wrong.
  869. >Sometimes the project must be trashed and rebuilt from scratch.
  870.  
  871. I used to have this problem often with a +-5M project file (the app compiled
  872. to over 1 M).  I 'fixed' the problem by raising the memory givien to
  873. the Think C app significantly.  I think adding at least 2M was in order,
  874. and I likely had the partition set to 4M.  Once I did that, I *never*
  875. got the ZREF error again.  I'm sure that does not 'fix' the real problem,
  876. but perhaps Think C is more likely to corrupt the project information
  877. when in a low memory situation.
  878.  
  879. - -- 
  880.  
  881.  \ | /   | Brian Hall                 mspace@netcom.com
  882.  - : -   | Mark/Space Softworks       Applelink: markspace
  883.   /|\    |                            America Online: MarkSpace
  884.  |-+-|   |
  885. /-\|/-\  | People don't kill people, toasters kill people.
  886.  
  887. ---------------------------
  888.  
  889. From: millsm@nextnet.ccs.csus.edu (Matthew Mills)
  890. Subject: Getting my hands on the real CLUT
  891. Organization: California State University Sacramento
  892. Date: Sat, 18 Jul 1992 19:36:49 GMT
  893.  
  894. Hello all,
  895.   I need some advice and information on controlling the screens Color
  896.   Look-up table.  I am writing a game and using machine language for
  897.   most (if not all) the drawing, but I am having a tough time with
  898.   setting up the indexed colors.
  899.   The situation is this, I am moving some bullets around the screen
  900.   and picking up the bytes that were underneath to implement some form
  901.   of collision detection.  I would like to set up ranges of colors
  902.   used by the good guys, and another range for the enemies.  I have
  903.   looked into the palette manager but it is not truly associated with
  904.   the indexes of the video memory.
  905.   What is the proper way to look at and change the CLUT for a
  906.   particular display?  Being a game (which takes over the whole
  907.   screen) following the proper color manager practices is not
  908.   important.  I know this sounds like I will get a visit from the
  909.   Interface police but I'll do my time ;-)
  910.  
  911. Matthew
  912.  
  913. - -- 
  914. | Matthew Mills                       | To do is to be - Socrates 
  915. | Technical Lab Assistant (CSUS)      | To be is to do - Plato
  916. | mail-> millsm@csus.edu              | Do Be Do Be Do - Sinatra
  917.  
  918. +++++++++++++++++++++++++++
  919.  
  920. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  921. Organization: Kalamazoo College
  922. Date: Mon, 20 Jul 1992 00:03:18 GMT
  923.  
  924. millsm@nextnet.ccs.csus.edu (Matthew Mills) writes:
  925. >
  926. >  I need some advice and information on controlling the screens Color
  927. >  Look-up table.  I am writing a game and using machine language...
  928. >  ...I would like to set up ranges of colors
  929. >  used by the good guys, and another range for the enemies.  I have
  930. >  looked into the palette manager but it is not truly associated with
  931. >  the indexes of the video memory.
  932.  
  933. It can be.  If you set color n in the palette to be
  934. pmAnimated+pmExplicit, it will correspond to color n in the color table,
  935. for 0 < n < theIndexOfTheLastColorInTheCLUT.
  936.  
  937. >  What is the proper way to look at and change the CLUT for a
  938. >  particular display?  Being a game (which takes over the whole
  939. >  screen) following the proper color manager practices is not
  940. >  important.
  941.  
  942. If you can give up those first and last colors, use the Palette Manager.
  943. It's actually easier than the Color Manager (it cleans up for you) and
  944. you won't have to rip your hair out if you ever decide to put your game
  945. in a window smaller than a full screen.
  946.  
  947. To do this, set up a palette with pmAnimated+pmExplicit colors in the
  948. range from 1 to theSecondToLastColorInTheCLUT.  Attach the palette to
  949. your window with SetPalette().  To change their colors, call
  950. AnimatedPalette().  That's all there is to it, if you're writing
  951. directly to the screen (which it sounds like you are).
  952.  
  953. >  I know this sounds like I will get a visit from the
  954. >  Interface police but I'll do my time ;-)
  955.  
  956. Oh, you probably won't spend any time behind bars--the jails are full,
  957. and judges are starting to let people go with just warnings.
  958. - -- 
  959.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  960.  I just got Think C and I like it so much that I had to tell the world.
  961.  I used to be an MPW bigot, but no more.   - John Norstad, 10 July 1992
  962.  
  963. ---------------------------
  964.  
  965. From: zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
  966. Subject: FSpExchangeFiles Problem
  967. Date: 17 Jul 92 01:11:03 GMT
  968. Organization: Bucknell University, Lewisburg, Pa.
  969.  
  970. I'm having a problem with FSpExchangeFiles.
  971.  
  972. The problem occurs when I try to exchange a temporary file with a
  973. permanent file (the file that I'm trying to save) that is on a
  974. different volume than my system folder.  In this case, my call to
  975. FSpExchangeFiles returns a -50, "Error in user parameter list".  This
  976. puzzles me for two reasons.
  977.  
  978. - - The code works when the permanent file is on the same volume as the
  979. system folder.
  980.  
  981. - - I am able to write to the temporary file and read from the permanent
  982. file without any problems.  Doesn't this indicate that the FSSpec
  983. records for my files are correct?
  984.  
  985. Please help.
  986.  
  987. Rick Zaccone
  988. - --
  989. zaccone@bucknell.edu
  990.  
  991. +++++++++++++++++++++++++++
  992.  
  993. From: zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
  994. Date: 17 Jul 92 12:23:03 GMT
  995. Organization: Bucknell University, Lewisburg, Pa.
  996.  
  997. A couple of people have been kind enough to point out that
  998. FSpExchangeFiles can't work across volumes because it just exchanges
  999. directory information.  I've reread IM Vol. VI and it does indeed make
  1000. (quick) reference to the fact that both files should be on the same
  1001. volume.
  1002.  
  1003. This raises some disturbing questions for me.
  1004.  
  1005. - - How would I do a safe save when the file I'm trying to save is not
  1006. on the start-up volume?  Specifically, where would I put the temp
  1007. file?  How have other people handled this?  Why doesn't IM address
  1008. this issue?
  1009.  
  1010. - - Suppose there's no easy way to do a safe save in this situation.
  1011. I'm disturbed by the fact that there would be more security in a save
  1012. to the start-up volume than to other volumes.  I would like them all
  1013. to be equally safe.
  1014.  
  1015. Rick Zaccone
  1016. - --
  1017. zaccone@bucknell.edu
  1018.  
  1019. +++++++++++++++++++++++++++
  1020.  
  1021. From: laf@mitre.org (Lee Fyock)
  1022. Organization: The MITRE Corporation
  1023. Date: Fri, 17 Jul 1992 12:49:02 GMT
  1024.  
  1025. In article <ZACCONE.92Jul16211103@rigel.cs.bucknell.edu>,
  1026. zaccone@rigel.cs.bucknell.edu (Rick Zaccone) wrote:
  1027. > I'm having a problem with FSpExchangeFiles.
  1028. > The problem occurs when I try to exchange a temporary file with a
  1029. > permanent file (the file that I'm trying to save) that is on a
  1030. > different volume than my system folder.  In this case, my call to
  1031. > FSpExchangeFiles returns a -50, "Error in user parameter list".  This
  1032. > puzzles me for two reasons.
  1033. > - The code works when the permanent file is on the same volume as the
  1034. > system folder.
  1035. > - I am able to write to the temporary file and read from the permanent
  1036. > file without any problems.  Doesn't this indicate that the FSSpec
  1037. > records for my files are correct?
  1038.  
  1039. I've seen this error before, usually when using a working directory
  1040. refnum in a place where a straight volume refnum is expected.  This
  1041. seems to crop up with major problems only when filesharing is on...
  1042.  
  1043. Lee
  1044.  
  1045. - ------------------------------------------------------------------------
  1046. Lee Fyock                                          The MITRE Corporation
  1047. laf@mitre.org                                     Bedford, Massachusetts
  1048.  
  1049. +++++++++++++++++++++++++++
  1050.  
  1051. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  1052. Organization: Kalamazoo College
  1053. Date: Fri, 17 Jul 1992 13:51:21 GMT
  1054.  
  1055. zaccone@bucknell.edu writes:
  1056. >
  1057. >- How would I do a safe save when the file I'm trying to save is not
  1058. >on the start-up volume?  Specifically, where would I put the temp
  1059. >file?  How have other people handled this?  Why doesn't IM address
  1060. >this issue?
  1061.  
  1062. I don't see any reason why you would have to put the temp file in the
  1063. Temporary Items Folder (which it sounds like you're doing).  That's just
  1064. for files that remain open long enough for users to mess with them if
  1065. they're anywhere else.  :-)
  1066.  
  1067. If you create, write, swap, and delete the temporary file without
  1068. calling WaitNextEvent, the user will never see it, and you can put it
  1069. anywhere you want.
  1070. - -- 
  1071.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  1072.  I'm having a lot of trouble seeing how a request that you "shut up" can be
  1073.  interpreted as "looking to other people for validation."      - Tim Pierce
  1074.  
  1075. +++++++++++++++++++++++++++
  1076.  
  1077. From: keith@taligent.com (Keith Rollin)
  1078. Date: 17 Jul 92 19:10:48 GMT
  1079. Organization: Taligent
  1080.  
  1081. In article <ZACCONE.92Jul17082303@rigel.cs.bucknell.edu>,
  1082. zaccone@rigel.cs.bucknell.edu (Rick Zaccone) writes:
  1083. > A couple of people have been kind enough to point out that
  1084. > FSpExchangeFiles can't work across volumes because it just exchanges
  1085. > directory information.  I've reread IM Vol. VI and it does indeed make
  1086. > (quick) reference to the fact that both files should be on the same
  1087. > volume.
  1088. > This raises some disturbing questions for me.
  1089. > - How would I do a safe save when the file I'm trying to save is not
  1090. > on the start-up volume?  Specifically, where would I put the temp
  1091. > file?  How have other people handled this?  Why doesn't IM address
  1092. > this issue?
  1093. > - Suppose there's no easy way to do a safe save in this situation.
  1094. > I'm disturbed by the fact that there would be more security in a save
  1095. > to the start-up volume than to other volumes.  I would like them all
  1096. > to be equally safe.
  1097.  
  1098. I'm not sure what the problem here is. Performing a "safe save" refers to the
  1099. process of replacing the contents of a file with new information in such a way
  1100. that the old information is preserved in case an error arises. If the old file
  1101. is on volume A, and you are writing the new file to volume B, then you are not
  1102. replacing the old file, and "safe save" techniques are not needed. Just write
  1103. the new file to volume B. If it succeeds, delete the file from volume A (if
  1104. that's what you want). I don't see a need for temp files or for calling
  1105. FSpExchangeFiles.
  1106.  
  1107. - --
  1108. Keith Rollin
  1109. Phantom Programmer
  1110. Taligent, Inc.
  1111.  
  1112.  
  1113. +++++++++++++++++++++++++++
  1114.  
  1115. From: zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
  1116. Date: 18 Jul 92 01:17:06 GMT
  1117. Organization: Bucknell University, Lewisburg, Pa.
  1118.  
  1119. I now realize my problem.  I was always creating my temporary file on
  1120. the start-up volume.  I'm not sure where I got the idea that that was
  1121. the right place to do it, but clearly it's not.  If I want to make a
  1122. temporary file so that I can use FSpExchangeFiles, then I need to do
  1123. so on the same volume as the permanent file.
  1124.  
  1125. Rick
  1126. - --
  1127. zaccone@bucknell.edu
  1128.  
  1129.  
  1130. +++++++++++++++++++++++++++
  1131.  
  1132. From: lari@bach.cs.unc.edu (Humayun Lari)
  1133. Date: 18 Jul 92 17:25:32 GMT
  1134. Organization: University of North Carolina, Chapel Hill
  1135.  
  1136. In article <1992Jul17.135121.26241@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  1137. >I don't see any reason why you would have to put the temp file in the
  1138. >Temporary Items Folder (which it sounds like you're doing).  That's just
  1139. >for files that remain open long enough for users to mess with them if
  1140. >they're anywhere else.  :-)
  1141. >
  1142. >If you create, write, swap, and delete the temporary file without
  1143. >calling WaitNextEvent, the user will never see it, and you can put it
  1144. >anywhere you want.
  1145.  
  1146. But what if your program crashes while it's saving, or the power goes out?
  1147. If you use the temporary items folder, at least the portion of the document
  1148. you finished saving will show up in the "Rescued Items" folder at startup. If 
  1149. you put the file somewhere else, the user might not notice it, and need to
  1150. redo work unnecessarily.
  1151.  
  1152. Humayun Lari
  1153. (lari@cs.unc.edu)
  1154.  
  1155.  
  1156. +++++++++++++++++++++++++++
  1157.  
  1158. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  1159. Organization: Kalamazoo College
  1160. Date: Mon, 20 Jul 1992 18:01:36 GMT
  1161.  
  1162. lari@bach.cs.unc.edu (Humayun Lari) writes:
  1163. >k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  1164. >>I don't see any reason why you would have to put the temp file in the
  1165. >>Temporary Items Folder...
  1166. >
  1167. >But what if your program crashes while it's saving, or the power goes out?
  1168. >If you use the temporary items folder, at least the portion of the document
  1169. >you finished saving will show up in the "Rescued Items" folder at startup. If 
  1170. >you put the file somewhere else, the user might not notice it, and need to
  1171. >redo work unnecessarily.
  1172.  
  1173. Right.  I forgot that you can specify a temp folder on any volume.
  1174. - -- 
  1175.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  1176.  I suppose ya don't think I was run over by a streetcar!
  1177.  
  1178. ---------------------------
  1179.  
  1180. From: dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz)
  1181. Subject: Accepting AppleEvents?
  1182. Organization: University of Illinois at Urbana
  1183. Date: Thu, 16 Jul 1992 03:30:06 GMT
  1184.  
  1185. I am trying to write a very simple application that accepts the four
  1186. required AppleEvents.  I have been following the example in Inside Mac
  1187. VI, but I am writing in Think C, and I am having a little trouble
  1188. converting.
  1189.  
  1190. I mainly need the odoc event.  I have successfully installed a handler
  1191. to handle the odoc event, but when this function calls AEGetParamDesc,
  1192. it returns an error of -1704.  It seems that my AppleEvent is not
  1193. properly formed.
  1194.  
  1195. Does anyone have either of the following written in C:
  1196.  
  1197. (1) source code for a SIMPLE application that does nothing but accepts
  1198.     the four required AppleEvents, or
  1199. (2) source code for a handler function that handles the odoc
  1200.     AppleEvent.
  1201.  
  1202. Thanks.
  1203. - -- 
  1204. David M. Marcovitz                     |  internet: marcovitz@uiuc.edu
  1205. Computer-based Education Research Lab  |            dmmg1176@uxa.cso.uiuc.edu
  1206. University of Illinois                 |  novanet:  marco / cca / nova
  1207.  
  1208. +++++++++++++++++++++++++++
  1209.  
  1210. From: rla20@duts.ccc.amdahl.com (Roger Allen)
  1211. Date: 16 Jul 92 22:15:55 GMT
  1212. Organization: Amdahl Corporation, Sunnyvale CA
  1213.  
  1214. In article <BrGpq7.G7z@news.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes:
  1215. >
  1216. >Does anyone have either of the following written in C:
  1217. >
  1218. >(1) source code for a SIMPLE application that does nothing but accepts
  1219. >    the four required AppleEvents, or
  1220. >(2) source code for a handler function that handles the odoc
  1221. >    AppleEvent.
  1222. >
  1223.  
  1224. How about the basic TCL shell program that comes with THINK C?
  1225.  
  1226. Roger
  1227. - --
  1228. > Roger Allen                   |                                        <
  1229. > Amdahl Computer Development   | What are you looking here for?         <
  1230. > rla20@cd.amdahl.com           |                                        <
  1231.  
  1232. +++++++++++++++++++++++++++
  1233.  
  1234. From: dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz)
  1235. Organization: University of Illinois at Urbana
  1236. Date: Fri, 17 Jul 1992 00:47:30 GMT
  1237.  
  1238. rla20@duts.ccc.amdahl.com (Roger Allen) writes:
  1239.  
  1240. >In article <BrGpq7.G7z@news.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes:
  1241. >>
  1242. >>Does anyone have either of the following written in C:
  1243. >>
  1244. >>(1) source code for a SIMPLE application that does nothing but accepts
  1245. >>    the four required AppleEvents, or
  1246. >>(2) source code for a handler function that handles the odoc
  1247. >>    AppleEvent.
  1248. >>
  1249.  
  1250. >How about the basic TCL shell program that comes with THINK C?
  1251.  
  1252. Thanks for the advice.  I had been using the TCL shell to try to
  1253. figure it out.  It helped some.  After some hacking, I finally got the
  1254. program to work, but I'm still not sure why.
  1255.  
  1256. - -- 
  1257. David M. Marcovitz                     |  internet: marcovitz@uiuc.edu
  1258. Computer-based Education Research Lab  |            dmmg1176@uxa.cso.uiuc.edu
  1259. University of Illinois                 |  novanet:  marco / cca / nova
  1260.  
  1261. +++++++++++++++++++++++++++
  1262.  
  1263. From: grobbins@Apple.COM (Grobbins)
  1264. Date: 18 Jul 92 03:00:59 GMT
  1265. Organization: The Ortiz Organization
  1266.  
  1267. In article <BrGpq7.G7z@news.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes:
  1268. >Does anyone have either of the following written in C:
  1269. >(1) source code for a SIMPLE application that does nothing but accepts
  1270. >    the four required AppleEvents, or
  1271. >(2) source code for a handler function that handles the odoc
  1272. >    AppleEvent.
  1273.  
  1274. (2) is totally application dependent, so I doubt you'll find anything
  1275. more useful than Inside Mac VI's sample code.
  1276.  
  1277. Here's a 1-1/2 page faceless background application for System 7
  1278. which answers (1).
  1279.  
  1280. Grobbins                 grobbins@apple.com
  1281.  
  1282. Usual disclaimers apply.
  1283.  
  1284. - ---
  1285.  
  1286.  
  1287. #include "AppleEvents.h"
  1288. #include "GestaltEqu.h"
  1289.  
  1290. #define kSleepMax 50000  // long sleep time to avoid stealing cycles
  1291.  
  1292. Boolean gAppleEventsFlag, gQuitFlag;
  1293. long gSleepVal;
  1294.  
  1295. pascal OSErr DoAEOpenApplication(AppleEvent * theAppleEvent,
  1296.                                  AppleEvent * replyAppleEvent, 
  1297.                                  long refCon)
  1298. {
  1299. #pragma unused (theAppleEvent, replyAppleEvent, refCon)
  1300.   return noErr;
  1301. }
  1302.  
  1303. pascal OSErr DoAEOpenDocuments(AppleEvent * theAppleEvent,
  1304.                                AppleEvent * replyAppleEvent, 
  1305.                                long refCon)
  1306. {
  1307. #pragma unused (theAppleEvent, replyAppleEvent, refCon)
  1308.   return errAEEventNotHandled;
  1309. }
  1310.  
  1311. pascal OSErr DoAEPrintDocuments(AppleEvent * theAppleEvent,
  1312.                                 AppleEvent * replyAppleEvent, 
  1313.                                 long refCon)
  1314. {
  1315. #pragma unused (theAppleEvent, replyAppleEvent, refCon)
  1316.   return errAEEventNotHandled;
  1317. }
  1318.  
  1319. pascal OSErr DoAEQuitApplication(AppleEvent * theAppleEvent,
  1320.                                  AppleEvent * replyAppleEvent, 
  1321.                                  long refCon)
  1322. {
  1323. #pragma unused (theAppleEvent, replyAppleEvent, refCon)
  1324.   gQuitFlag = true;
  1325.   return noErr;
  1326. }
  1327.  
  1328. void InitAppleEventsStuff(void)
  1329. // install Apple event handlers
  1330. {
  1331.   OSErr retCode;
  1332.   
  1333.   if (gAppleEventsFlag) {
  1334.     
  1335.     retCode = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
  1336.                 (EventHandlerProcPtr) DoAEOpenApplication, 0, false);
  1337.     if (retCode == noErr)
  1338.       retCode = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
  1339.               (EventHandlerProcPtr) DoAEOpenDocuments, 0, false);
  1340.     if (retCode == noErr)
  1341.       retCode = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
  1342.               (EventHandlerProcPtr) DoAEPrintDocuments, 0, false);
  1343.     if (retCode == noErr)
  1344.       retCode = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
  1345.               (EventHandlerProcPtr) DoAEQuitApplication, 0, false);
  1346.     if (retCode != noErr) DebugStr("\pInstall event handler failed");
  1347.   }
  1348. }
  1349.  
  1350. void DoHighLevelEvent(EventRecord * theEventRecPtr)
  1351. // high-level event dispatching
  1352. {
  1353.   (void) AEProcessAppleEvent(theEventRecPtr);
  1354. }
  1355.  
  1356. main()
  1357. {
  1358.   OSErr retCode;
  1359.   long gestResponse;
  1360.   
  1361.   EventRecord mainEventRec;
  1362.   Boolean eventFlag;
  1363.   
  1364.   // initialize globals
  1365.   
  1366.   gQuitFlag = false;
  1367.   gSleepVal = kSleepMax;
  1368.   
  1369.   // is the Apple Event Manager available?
  1370.   retCode = Gestalt(gestaltAppleEventsAttr, &gestResponse);
  1371.   if (retCode == noErr &&
  1372.       (gestResponse & (1 << gestaltAppleEventsPresent)) != 0)
  1373.     gAppleEventsFlag = true;
  1374.   else gAppleEventsFlag = false;
  1375.  
  1376.   // install Apple event handlers
  1377.   InitAppleEventsStuff();
  1378.   
  1379.   while (!gQuitFlag) {
  1380.     eventFlag = WaitNextEvent(everyEvent, &mainEventRec, gSleepVal, nil);
  1381.     
  1382.     if (mainEventRec.what == kHighLevelEvent)
  1383.       DoHighLevelEvent(&mainEventRec);
  1384.   }
  1385. }
  1386.  
  1387.  
  1388. +++++++++++++++++++++++++++
  1389.  
  1390. From: potts@itl.itd.umich.edu (Paul Potts)
  1391. Organization: Instructional Technology Laboratory, University of Michigan
  1392. Date: Mon, 20 Jul 92 20:02:55 GMT
  1393.  
  1394. In article <BrICv7.KxE@news.cso.uiuc.edu> dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz) writes:
  1395. > ...After some hacking, I finally got the
  1396. >program to work, but I'm still not sure why.
  1397.  
  1398. Welcome to Macintosh programming! : )  Can I quote you? This sums it up
  1399. pretty well.
  1400.  
  1401.  
  1402. - -- 
  1403. ..though I respect that a lot, I'd be fired if that were my job, after 
  1404. killing Jason off and countless screaming argonauts... (They Might Be Giants)
  1405. Paul R. Potts, Software Designer --- potts@itl.itd.umich.edu <--- me!
  1406.  
  1407. +++++++++++++++++++++++++++
  1408.  
  1409. From: dmmg1176@uxa.cso.uiuc.edu (David M Marcovitz)
  1410. Organization: University of Illinois at Urbana
  1411. Date: Mon, 20 Jul 1992 21:24:40 GMT
  1412.  
  1413. I believe that the important part of getting my AppleEvents handlers
  1414. to work was to declare the functions to be of type    pascal OSErr.
  1415. The "pascal" part is very important.
  1416.  
  1417. pascal OSErr myEventHandler(AppleEvent *event, AppleEvent *reply, long ref);
  1418.  
  1419. I believe this is the correct header.
  1420.  
  1421. - -- 
  1422. David M. Marcovitz                     |  internet: marcovitz@uiuc.edu
  1423. Computer-based Education Research Lab  |            dmmg1176@uxa.cso.uiuc.edu
  1424. University of Illinois                 |  novanet:  marco / cca / nova
  1425.  
  1426. ---------------------------
  1427.  
  1428. End of C.S.M.P. Digest
  1429. **********************
  1430.