home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15118 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  26.0 KB

  1. Xref: sparky comp.sys.mac.programmer:15118 news.answers:2837
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!olivea!mintaka.lcs.mit.edu!bloom-picayune.mit.edu!news
  3. From: mkelly@sisters.cs.uoregon.edu ((Michael A. Kelly))
  4. Newsgroups: comp.sys.mac.programmer,news.answers
  5. Subject: Comp.Sys.Mac.Programmer Frequently Asked Questions Part 2/2 (8/3/92)
  6. Summary: Frequently Asked Questions list for comp.sys.mac.programmer
  7. Keywords: frequently asked questions faq
  8. Message-ID: <csmp-faq/part2_715928413@athena.mit.edu>
  9. Date: 8 Sep 92 05:04:06 GMT
  10. Expires: Tue, 29 Sep 1992 05:00:13 GMT
  11. References: <csmp-faq/part1_715928413@athena.mit.edu>
  12. Sender: news@athena.mit.edu (News system)
  13. Reply-To: mkelly@cs.uoregon.edu
  14. Followup-To: poster
  15. Organization: University of Oregon Computer and Information Sciences Dept.
  16. Lines: 718
  17. Approved: news-answers-request@MIT.Edu
  18. Supersedes: <csmp-faq/part2_715323611@athena.mit.edu>
  19. X-Last-Updated: 1992/08/11
  20. Nntp-Posting-Host: pit-manager.mit.edu
  21.  
  22. Archive-name: csmp-faq/part2
  23. Last-modified: 1992/08/03
  24.  
  25.  
  26.                      +---------------------------------+
  27.                      | Frequently Asked Questions List |
  28.                      |   for Comp.Sys.Mac.Programmer   |
  29.                      |         August 3, 1992          |
  30.                      |            PART  TWO            |
  31.                      +---------------------------------+
  32.  
  33.  
  34. This FAQ list is automatically posted once a week to comp.sys.mac.programmer.
  35. It is also available via anonymous ftp from ftp.cs.uoregon.edu [128.223.8.8]
  36. (user name 'anonymous', your internet address as password) in the files
  37. /pub/mac/csmp-faq-1 and /pub/mac/csmp-faq-2.
  38.  
  39. This FAQ list is maintained by Michael A. Kelly.  He can be reached at the
  40. following addresses:                                                         
  41.   
  42.    Internet:  mkelly@cs.uoregon.edu
  43.    SnailMail: Computer Science Dept.
  44.               University of Oregon
  45.               Eugene, Oregon  97403
  46.  
  47. The purpose of the FAQ list is to answer some of the most common questions
  48. asked on this group, and to refer people left with unanswered questions to
  49. available sources of additional help.  You should read the FAQ list before
  50. posting to comp.sys.mac.programmer.
  51.  
  52. Submissions, comments, etcetera, should be sent to Michael Kelly, as above.
  53. All such material sent will be considered to have entered the public domain
  54. (and will be subject to editing) unless specific text to the contrary
  55. accompanies the message (which may render the submission unusable).
  56.  
  57.  
  58.  
  59.                          Changes since July 24, 1992
  60.                          ---------------------------
  61.  
  62.  - Fixed some typos.
  63.  - Reorganized section 3.
  64.  - Added 3.2.1, 3.2.2, 3.2.3, and 3.3.3.
  65.  - Updated 3.1.2.
  66.  - Updated 4.1 and 4.2, moved 4.7 to 4.8 and added 4.7.
  67.  - Updated 6.8.1.
  68.  
  69.  
  70.  
  71.  
  72.                               Table of Contents
  73.                               -----------------
  74.  
  75. Part One  (separate file)
  76. ---------------------
  77.  
  78.   I.    Development Software
  79.           1. Compilers
  80.           2. Debuggers
  81.           3. Other Tools
  82.    
  83.   II.   Apple Developer Programs
  84.           1. The Associates and Partners Programs
  85.           2. Apple Developer University
  86.           3. APDA
  87.           4. Developer CDs
  88.  
  89.   III.  Sources of Information
  90.           1. Books and Periodicals
  91.                1. Technical Books
  92.                2. Teaching Books
  93.                3. Periodicals
  94.           2. Mailing Lists
  95.                1. Comp.Sys.Mac.Programmer Digest
  96.                2. Think Class Library Discussion
  97.                3. MacPsych
  98.           3. Miscellaneous
  99.                1. Usenet Mac Programmer's Guide (UMPG)
  100.                2. Kent Sandvik's Frequently Asked MPW C++ and MacApp Questions
  101.                3. Comp.Sys.Mac.FAQ
  102.  
  103.   IV.   Archive Sites
  104.           1. ftp.apple.com [130.43.2.3]
  105.           2. sumex-aim.stanford.edu [36.44.0.6]
  106.           3. rascal.ics.utexas.edu [128.83.138.20]
  107.           4. mac.archive.umich.edu [141.211.164.153]
  108.           5. ftp.cs.uoregon.edu [128.223.8.8]
  109.           6. ics.uci.edu [128.195.1.1]
  110.           7. ftp.brown.edu [128.148.176.55]
  111.           8. comp.binaries.mac [newsgroup]
  112.  
  113.   V.    One-liners
  114.           1. The Main Loop and Events
  115.           2. Menus
  116.           3. Resources
  117.           4. Windows, Alerts, and Dialogs
  118.           5. Drawing
  119.           6. Files
  120.           7. Interrupts and VBL Tasks
  121.           8. Handles and Pointers
  122.           9. General
  123.  
  124.  
  125. Part Two  (this file)
  126. -------------------------
  127.  
  128.   VI.   Specific Questions Answered
  129.           1. The Main Loop and Events
  130.                1. How do you tell if a specific key is being pressed?
  131.                2. How can I get millisecond timing from the keyboard
  132.                   (or mouse)?
  133.           2. Menus
  134.                1. When do you put an ellipsis on the end of a menu item?
  135.                2. How do I get the menubar to disappear and re-appear?
  136.                3. What's the difference between the resource ID of a 'MENU'
  137.                   resource and the menuID field of that resource?
  138.           3. Windows, Alerts, and Dialogs
  139.                1. How do you put a border around the default button in a
  140.                   dialog?
  141.           4. Drawing
  142.                1. What is the fastest way to paint one pixel on the screen?
  143.                2. How do you draw directly into a pixmap without using
  144.                   QuickDraw?
  145.                3. How do you draw directly onto the screen without using
  146.                   QuickDraw?
  147.                4. What RGB value does the system use for dimmed buttons,
  148.                   menus and window titles?
  149.           5. Files
  150.                1. Why is the File Manager so hard to use?
  151.                2. How do you get a full pathname?
  152.                3. How do you set the SFGet/PutFile directory?
  153.                4. How do you access the application's data fork?
  154.           6. Handles and Pointers
  155.                1. When should I call MoveHHi?
  156.                2. Why does malloc/calloc keep crashing or returning NULL in
  157.                   Think C?
  158.           7. Standalone Code
  159.                1. How do I write an INIT?
  160.           8. General
  161.                1. How do I register signatures and file types with Apple?
  162.                2. How do I go about writing serial port communications?
  163.  
  164.    
  165.   VII.  Eternal Debates:
  166.           1. Why doesn't the Mac do preemptive multitasking?
  167.    
  168.  
  169.  
  170. =============================================================================
  171.  
  172.  
  173.                  ===========================================
  174.                    Section VI: Specific Questions Answered
  175.                  ===========================================
  176.  
  177.  
  178.  
  179. 6.1  The Main Loop and Events
  180. -----------------------------
  181.  
  182.  
  183. ----------------------------------------------------------
  184. 6.1.1  How do you tell if a specific key is being pressed?
  185. ----------------------------------------------------------
  186.  
  187. Use GetKeys.  GetKeys fills a 16-byte KeyMap structure with the state of
  188. every key.  Each bit represents a single key on the keyboard; 1 means the
  189. key is down, 0 means it is up.  Note that there can be a maximum of seven
  190. keys being pressed at a time - any of the modifier keys plus at most two
  191. other keys.
  192.  
  193. Here's an example in C:
  194.  
  195. Boolean IsKeyDown(
  196.     unsigned short theKey )  // a keyboard-specific scan code for a key
  197. {
  198.  
  199.     unsigned char  keyMap[16];
  200.  
  201.     GetKeys( (void *) keyMap );
  202.     return ((keyMap[theKey>>3] >> (theKey & 7)) & 1);
  203.  
  204. }
  205.  
  206.  
  207.  
  208. -----------------------------------------------------------------------------
  209. 6.1.2  I'm writing a psychology experiment.  How can I get millisecond timing
  210.        from the keyboard (or mouse)?
  211. -----------------------------------------------------------------------------
  212.  
  213. The simple answer is that you can't.  Although the new time manager can call
  214. routines every couple of microseconds, input goes through the event manager,
  215. which only posts events about every 16 milliseconds.  Thus, even if you poll
  216. the keyboard every 30 microseconds, you will not get better than 16 ms.
  217. resolution.  If you really need millisecond accuracy, you need to use
  218. external hardware.
  219.  
  220. The good news is that you probably don't need better than 16 ms. resolution
  221. anyway.  Measuring with 16 ms. accuracy only increases the standard deviation
  222. of your RT means by about 4.8 msec.  Read: Ulrich, R. and Giray, M. (1989).
  223. Time resolution of clocks: Effects on reaction time measurement -- Good news
  224. for bad clocks.  British Journal of Mathematical and Statistical Psychology,
  225. 42, 1-12.
  226.  
  227. By the way, there is a mailing list dedicated to running psychology
  228. experiments on the Mac.  It frequently gets tied up in arguments about
  229. millisecond timing.  The address to write to is macpsych-request@stolaf.edu.
  230.  
  231.  
  232.  
  233.  
  234. 6.2  Menus
  235. ----------
  236.  
  237.  
  238. -------------------------------------------------------------
  239. 6.2.1  When do you put an ellipsis on the end of a menu item?
  240. -------------------------------------------------------------
  241.  
  242. Put an ellipsis (...) at the end of any menu item which requires more
  243. information in order to complete or simply displays information.  Usually
  244. this involves a dialog of some kind, be it modal or non modal.
  245.  
  246.  
  247.  
  248. -----------------------------------------------------------
  249. 6.2.2  How do I get the menubar to disappear and re-appear?
  250. -----------------------------------------------------------
  251.  
  252. A set of routines to do this in Pascal can be found in the Usenet
  253. Macintosh Programmer's Guide.  You can also ftp some sample code in C
  254. from skinner.cs.uoregon.edu in /pub/mac/menu-bar.c.
  255.  
  256.  
  257.  
  258. -----------------------------------------------------------------------------
  259. 6.2.3  What's the difference between the resource ID of a 'MENU' resource and
  260.        the menuID field of that resource?
  261. -----------------------------------------------------------------------------
  262.  
  263. The resource ID of a 'MENU' resource is just the resource ID - it has no
  264. hidden meaning.  What is normally expected by beginning programmers is that
  265. the number that MenuSelect and MenuKey return is the resource ID of the menu.
  266. In fact, the number returned is the value of the menuID field of the menu,
  267. and has no relation to the resource ID of the menu.  You can set the menuID
  268. to any number you want, but by convention it is expected to be the same as
  269. the resource ID of the menu.  (You can change this value in ResEdit by
  270. opening the menu you wish to change, and selecting 'Edit Menu & MDEF ID...'
  271. from the MENU menu.)
  272.  
  273.  
  274.  
  275.  
  276. 6.3  Windows, Alerts, and Dialogs
  277. ---------------------------------
  278.  
  279.  
  280. ---------------------------------------------------------------------
  281. 6.3.1  How do you put a border around the default button in a dialog?
  282. ---------------------------------------------------------------------
  283.  
  284. The most common way to do this is to create a dummy user item in the dialog,
  285. and use SetDItem to install a procedure that outlines the default button.
  286. The dialog's "Initially visible" bit should be false and you should call
  287. ShowWindow before calling ModalDialog; otherwise, if the button is very tall,
  288. part of the outline won't be drawn.  Here is an example in C:
  289.  
  290.  
  291. /* This function draws a border around dialog item #1 */
  292.  
  293. pascal void OutlineDefault(
  294.     DialogPtr theDialog,
  295.     short     theItem )
  296. {
  297.  
  298.     Rect     itemRect;
  299.     Handle   itemHandle;
  300.     short    itemType;
  301.     short    diameter;
  302.  
  303.     GetDItem( theDialog, 1, &itemType, &itemHandle, &itemRect );
  304.     diameter = (itemRect.bottom - itemRect.top) / 2 + 6;
  305.     if ( diameter < 16 )
  306.         diameter = 16;
  307.     PenSize( 3, 3 );
  308.     InsetRect( &itemRect, -4, -4 );
  309.     FrameRoundRect( &itemRect, diameter, diameter );
  310.  
  311. }
  312.  
  313.  
  314.  
  315. /* Assume myDialog has been initialized, and item #4 is the dummy
  316.    user item for outlining the default button.  The following lines
  317.    install the outlining procedure OutlineDefault into the user
  318.    item, so that OutlineDefault will be called by the Dialog Manager
  319.    each time the dialog needs to be redrawn.  Depending on your
  320.    compiler, you may have to cast OutlineDefault to a Handle. */
  321.  
  322. GetDItem( myDialog, 4, &itemType, &itemHandle, &itemRect );
  323. SetDItem( myDialog, 4, itemType, OutlineDefault, &itemRect );
  324.  
  325.  
  326.  
  327.  
  328. 6.4  Drawing
  329. ------------
  330.  
  331.  
  332. ----------------------------------------------------------------
  333. 6.4.1  What is the fastest way to paint one pixel on the screen?
  334. ----------------------------------------------------------------
  335.  
  336. Using QuickDraw, the fastest way to draw one pixel is
  337.    MoveTo( x, y );
  338.    Line( 0, 0 );
  339. making sure that the pen size is 1 by 1.  This is about twice as fast as
  340. setting the pen size to 0 by 1 or 1 by 0 and calling Line( 1, 0 ) or
  341. Line( 0, 1 ), respectively.  I'm not sure why....
  342.  
  343. See below for how to draw a pixel without using QuickDraw.
  344.  
  345.  
  346.  
  347. ----------------------------------------------------------------------
  348. 6.4.2  How do you draw directly into a pixmap without using QuickDraw?
  349. ----------------------------------------------------------------------
  350.  
  351. As an example, here is a routine that paints a single pixel in a pixmap.
  352. To use this procedure, you just have to know what 'value' to pass in.  This
  353. depends on the current bit-depth of 'thePixMap.'  The rightmost n bits of
  354. 'value' are used for the pixel value for depth = n.  For depths of eight or
  355. less, the value of each pixel is an index into a color table.  For depth = 16,
  356. each 16-bit pixel is interpreted as an RGB value, as follows:
  357.  
  358.          Bit: 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
  359.        Value:  R  R  R  R  R  G  G  G  G  G  B  B  B  B  B  U
  360.  
  361. where R = Red, G = Green, B = Blue, and U = Unused.  For depth = 32, each
  362. 32-bit pixel is interpreted as an RGB value as follows:
  363.  
  364.          Bit: 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
  365.        Value:  A  A  A  A  A  A  A  A  R  R  R  R  R  R  R  R
  366.  
  367.          Bit: 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
  368.        Value:  G  G  G  G  G  G  G  G  B  B  B  B  B  B  B  B
  369.  
  370. where R = Red, G = Green, B = Blue, and A = Alpha.
  371.  
  372.  
  373.  
  374. void SetPixel(
  375.     short           x,
  376.     short           y,
  377.     long            value,
  378.     PixMapHandle    thePixMap )
  379. {
  380.  
  381.     unsigned long   rowBytes;
  382.     unsigned char   mask;
  383.     unsigned char   shiftBits;
  384.     unsigned char   *thePixel;
  385.     unsigned char   pixelDepth;
  386.     char            mode = true32b;
  387.     Boolean         swapMode;
  388.     
  389.     swapMode = PixMap32Bit( thePixMap );
  390.  
  391.     LockPixels( thePixMap );
  392.  
  393.     rowBytes = (unsigned long) ((*thePixMap)->rowBytes & 0x1fff);
  394.     thePixel = (unsigned char *) GetPixBaseAddr( thePixMap );
  395.  
  396.     pixelDepth = (*thePixMap)->pixelSize;
  397.  
  398.     switch ( pixelDepth ) {
  399.     
  400.         case 1:
  401.         case 2:
  402.         case 4:
  403.         case 8:
  404.  
  405.             thePixel += (rowBytes * y) +
  406.                         (((unsigned long) pixelDepth * x) / 8L);
  407.  
  408.             shiftBits = ((8 - pixelDepth) - ((x * pixelDepth) % 8));
  409.  
  410.             mask = (unsigned char) ((1 << pixelDepth) - 1) << shiftBits;
  411.  
  412.             if ( swapMode ) {
  413.                 SwapMMUMode( &mode );
  414.             }
  415.        
  416.             *thePixel &= ~mask;
  417.             *thePixel |= (unsigned char) value << shiftBits;
  418.        
  419.             break;
  420.       
  421.       
  422.         case 16:
  423.  
  424.             thePixel += (rowBytes * y) + (2L * x);
  425.  
  426.             if ( swapMode ) {
  427.                 SwapMMUMode( &mode );
  428.             }
  429.        
  430.             *((unsigned short *)thePixel) = (unsigned short) value;
  431.           
  432.             break;
  433.    
  434.    
  435.         case 32:
  436.       
  437.             thePixel += (rowBytes * y) + (4L * x);
  438.        
  439.             if ( swapMode ) {
  440.                 SwapMMUMode( &mode );
  441.             }
  442.        
  443.             *((unsigned long *)thePixel) = value;
  444.        
  445.             break;
  446.    
  447.    
  448.         default:
  449.             break;
  450.     
  451.     }
  452.  
  453.     if ( swapMode ) {
  454.         SwapMMUMode( &mode );
  455.     }
  456.  
  457.     UnlockPixels( thePixMap );
  458.  
  459. }
  460.  
  461.  
  462.  
  463. ------------------------------------------------------------------------
  464. 6.4.3  How do you draw directly onto the screen without using QuickDraw?
  465. ------------------------------------------------------------------------
  466.  
  467. Get the pixmap for the monitor that you want to draw on, and send it to the
  468. above procedure.  For example, to draw a red dot at position 10,10 on the
  469. main screen (if the main screen is in 32-bit mode):
  470.  
  471.    GDHandle   theDevice;
  472.  
  473.    theDevice = GetMainDevice();
  474.  
  475.    SetPixel( x, y, 0x00FF0000, (*theDevice)->gdPMap );
  476.  
  477. If you are drawing directly to the screen, you should always wrap your
  478. drawing with calls to ShieldCursor and ShowCursor.  Some monitors such
  479. as the Radius Pivot series keep a virtual screen, and they don't update
  480. the real screen unless they have to.  When you write directly to the
  481. screen, you're actually writing to the virtual screen, and your drawing
  482. won't show up on the real screen until the system has some other reason
  483. to update the monitor.  Calling ShieldCursor each time you draw will
  484. force these systems to update the real screen when you expect them to.
  485.  
  486.  
  487.  
  488. -----------------------------------------------------------------------
  489. 6.4.4  What RGB value does the system use for dimmed buttons, menus and
  490.        window titles?
  491. -----------------------------------------------------------------------
  492.  
  493. The gray color does not have a fixed RGB value.  It is a weighted average of
  494. the foreground and background colors.  To obtain the appropriate 'gray' color
  495. for a given foreground and background color, use the Palette Manager routine
  496. GetGray (documented in Inside Macintosh Volume VI).
  497.  
  498. pascal Boolean GetGray( GDHandle device, const RGBColor *backGround,
  499.                         RGBColor *foreGround )
  500.   = {0x303C,0x1219,0xAAA2};
  501.  
  502. If at least one gray or intermediate color is available, GetGray stores the
  503. color in foreGround and returns true.  If no gray is available, or, if you
  504. supplied two colors, no third distinguishable color is available, the
  505. foreGround parameter is unchanged and the function returns false.
  506.  
  507. GetGray is not available in older versions of the system.  Use Gestalt to
  508. determine whether it is available.
  509.  
  510.  
  511.  
  512.  
  513. 6.5  Files
  514. ----------
  515.  
  516.  
  517. ----------------------------------------------
  518. 6.5.1  Why is the File Manager so hard to use?
  519. ----------------------------------------------
  520.  
  521. Its always those pesky wdrn's that are the problem.  Here is a summary of
  522. some of the things to know:
  523.  
  524.     vrn = volume reference number
  525.           (small negative number; e.g. -2)
  526.     wdrn = working directory reference number
  527.            (large negative number; e.g. -32123)
  528.     dirID = directory ID
  529.             (small (but long integer!) positive number; e.g. 4123)
  530.  
  531.     - vrn's and wdrn's can be used interchangably for the most part.
  532.     - A vrn represents either a volume, or the root directory of a volume.
  533.     - A wdrn represents a directory on a volume.
  534.     - A dirID represents nothing without a vrn or a wdrn.
  535.     - A dirID overrides the directory otherwise specified by the vrn or wdrn
  536.       unless it's zero, in which case it's ignored.  If it is 2 it specifies
  537.       the root directory of the volume.
  538.     - You should always use vrn,dirID pairs. To convert a wdrn into a
  539.       vrn,dirID pair use GetWDInfo, which returns the vRefNum, the dirID and
  540.       the procID of the wdRefNum.  The procID is almost always 'ERIK'.
  541.     - You can also use GetVol/SetVol to convert volume names to/from vrns.
  542.     - To store a vrn,dirID pair (between invocations of a program) convert
  543.       the vrn to a volume name & creation date (for verification) and store
  544.       them and the dirID (and a filename perhaps).
  545.  
  546.  
  547.  
  548. --------------------------------------
  549. 6.5.2  How do you get a full pathname?
  550. --------------------------------------
  551.  
  552. Take a look at Tech Note #238, available from APDA (and other places).  It
  553. tells you everything you need to know to get a full pathname, and why you
  554. should, in general, use a volume name, dirID, filename (and perhaps volume
  555. creation date) triple instead.  Also check out the code snippets available
  556. from ftp.apple.com et al.  There are a couple of snippets that give code to
  557. get a full pathname, as well as many other cool file manager tricks.
  558.  
  559.  
  560.  
  561. --------------------------------------------------
  562. 6.5.3  How do you set the SFGet/PutFile directory?
  563. --------------------------------------------------
  564.  
  565. To set the directory that is displayed by SFGet/PutFile, stuff the volume
  566. reference number into SFSaveDisk, and the dirID into CurDirStore.
  567.  
  568.      CurDirStore = $398;   Current dirID from Standard File (long)
  569.      SFSaveDisk = $214;    Negative of current vRefNum
  570.  
  571.  
  572.  
  573. -----------------------------------------------------
  574. 6.5.3  How do you access the application's data fork?
  575. -----------------------------------------------------
  576.  
  577. Call CurResFile when the application starts up.
  578. Call PBGetFCBInfo to convert that refNum into a vRefNum, dirID and name.
  579. Call HOpen with the vRefNum, dirID, and name to open up your data fork.
  580.  
  581.  
  582.  
  583.  
  584. 6.6  Handles and Pointers
  585. -------------------------
  586.  
  587.  
  588. ----------------------------------
  589. 6.6.1  When should I call MoveHHi?
  590. ----------------------------------
  591.  
  592. MoveHHi is an expensive operation; calling it when you don't need to can
  593. significantly slow down your program.  Additionally, over-calling of MoveHHi
  594. can fragment the top of your heap.  Call MoveHHi before locking a handle that
  595. is followed by some memory allocation.  To efficiently move a handle high in
  596. the heap and then lock it, you might want to call HLockHi, a call new with
  597. MPW 3.2 and THINK C 5.0 (probably THINK Pascal 4.0 as well).
  598.  
  599.  
  600.  
  601. -------------------------------------------------------------------------
  602. 6.6.2  Why does malloc/calloc keep crashing or returning NULL in Think C?
  603. -------------------------------------------------------------------------
  604.  
  605. #include <stdlib.h>
  606.  
  607. Explanation:  In THINK C, parameters and return values are 2-byte ints by
  608. default, which causes the value passed to malloc to be $10000 times as large
  609. as you think it is, and causes the upper bytes of the return value to be
  610. zeroed.  Including stdlib includes a prototype which overrides the defaults.
  611.  
  612. Another common cause of problems with malloc is overwriting the end of a
  613. string, such as only mallocing the size of the string and then writing the
  614. string plus a null into the malloc'd space.  Think's malloc algorithm stores
  615. block size information in space adjacent to the storage it allocates, so
  616. overwriting the storage tends to cause havoc. The problem may not show
  617. immediately since it will probably be the next malloc that encounters
  618. problems.
  619.  
  620.  
  621.  
  622.  
  623. 6.7  Standalone Code
  624. --------------------
  625.  
  626.  
  627. ------------------------------
  628. 6.7.1  How do I write an INIT?
  629. ------------------------------
  630.  
  631. There is a simple INIT (SetWindow INIT) with source code and explanations in
  632. the Usenet Macintosh Programmer's Guide.  There is also a chapter on writing
  633. system extensions in Macintosh Programming Secrets (2nd Ed.).  Be sure to
  634. check out the ftp sites (especially ftp.apple.com) for sample inits.
  635.  
  636.  
  637.  
  638.  
  639. 6.8  General
  640. ------------
  641.  
  642.  
  643. --------------------------------------------------------------
  644. 6.8.1  How do I register signatures and file types with Apple?
  645. --------------------------------------------------------------
  646.  
  647. Registering a signature and file type is free, and you don't have to be an
  648. Apple Partner or Associate.  You can ftp the registration form from
  649. ftp.apple.com; it's available as
  650.      /dts/mac/registration/creator-file-type-form.txt.
  651.  
  652.  
  653.  
  654. -------------------------------------------------------------------------
  655. 6.8.2  How do I go about writing serial port communications?
  656.  
  657. These days, it is best to use the new Comunications Toolbox (CTB).  By
  658. utiizing the CTB, you will be able to write your code to a single
  659. specification, and the code will work with all current CTB "tools" and all
  660. future CTB tools. The CTB tools allow programmers to extend the CTB's
  661. functionality. There is a tool for each facet of the communications puzzle:
  662. Connection Tools, Terminal Tools, and File Transfer Tools.
  663.  
  664. For example, once I have written a piece of code that uses the Serial tool to
  665. connect me to a terminal server, combined with the VT102 Tool to emulate a
  666. vt102 terminal, and the XMODEM Macbinary Tool to transfer files, the same
  667. code will work with Apple Modem Tool, TCP/IP, AppleTalk ADSP, ISDN, X.25, and
  668. all future Connection Tools. Further, the terminal can emulate a VT320,
  669. ASCII, or other terminals. Files may be transfered with XMODEM, TEXT, and
  670. soon ZMODEM and Kermit protocols.
  671.  
  672. The disadvantage of the CTB is that you must limit yourself to the
  673. specification of the Connection, Terminal, and File Transfer interfaces.
  674. These limitations are *rarely* a problem, but clearly something like a FAX
  675. interface program or real time data analyzer, would have to seriously
  676. consider the interfaces before committing.
  677.  
  678. For most standard communications applications, such as terminal emulators,
  679. Bulletin Board Systems, etc., the CTB is the correct choice.
  680.  
  681. You can only get the CTB development kit from APDA.  It is affordable,
  682. somewhere just under $100.  This includes working sample code.
  683.  
  684.  
  685.  
  686.  
  687.  
  688.                       ================================
  689.                         Section VII: Eternal Debates
  690.                       ================================
  691.  
  692.  
  693. These questions have no final answers.  They pop up every few months and
  694. waste a tremendous amount of valuable network resources on discussions
  695. that will never be resolved.  Most people would be happy if they were
  696. never discussed again in this newsgroup.
  697.  
  698.  
  699. 7.1  Why doesn't the Mac do preemptive multitasking?
  700. ----------------------------------------------------
  701.  
  702. Pro-preemptives claim the current scheme is too vulnerable to ill-behaved
  703. applications and too much trouble for application writers.  Anti-
  704. preemptives claim that preemptive multitasking would reduce interactive
  705. response, and that the current cooperative system works well.
  706.  
  707.  
  708.  
  709.  
  710.  
  711.                        ==============================
  712.                          Credits / Acknowledgements
  713.                        ==============================
  714.  
  715.  
  716. Many thanks to Ben Haller, who started this whole thing, and did quite a lot
  717. of work on this posting before handing it off to me.
  718.  
  719. Thanks to these people for proofreading this list during its development:
  720.     Ben Haller
  721.     Wally Wedel
  722.     John B. Matthews
  723.     Patrick Beard
  724.     Steve Zellers
  725.  
  726. Thanks to Chris Webster for the one-liners.
  727.  
  728. Thanks to Peter Lewis for the answers to the following specific questions:
  729.     6.2.1  When do you put an ellipsis on the end of a menu item?
  730.     6.5.1  Why is the File Manager so hard to use?
  731.     6.5.2  How do you get a full pathname?
  732.     6.5.3  How do you set the SFGet/PutFile directory?
  733.  
  734. Thanks to Greg Ferrar for the review on TMON Pro.
  735.  
  736. Thanks to John Rinaldo for the review on Jasik's Debugger.
  737.  
  738. And thanks to everyone who has offered suggestions or constructive
  739. criticism....  Keep those comments coming!
  740.