home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #2 / Amiga Plus CD - 1995 - No. 2.iso / internet / faq / englisch / macprogramming < prev    next >
Encoding:
Text File  |  1995-04-11  |  86.1 KB  |  2,071 lines

  1. Archive-name: macintosh/programming-faq
  2.  
  3. The Public Domain Mac Programming FAQ Answer Sheet
  4. Last update: 16 Feb 95    "Early Morning Cold FAQ"
  5.  
  6. [out of town March 6, so this FAQ is set to expire in little over 2 weeks]
  7.  
  8. Please download a copy of this answer sheet and search it before you 
  9. post to the 'net, to help reduce bandwidth.
  10.  
  11. Please send all correspondence regarding content directly to the current 
  12. caretaker and content editor, Chris Thomas, <thunderone@delphi.com>.  
  13. All submissions sent will be considered to be in the public domain 
  14. unless stated otherwise (in which case they will not be included in this 
  15. FAQ sheet).  This sheet was started and is distributed by Jon W"atte, 
  16. whom you may reach as <h+@nada.kth.se>.
  17.  
  18. This sheet is currently archived on nada.kth.se where you can reach it 
  19. using afs as /afs/nada.kth.se/public/ftp/pub/hacks/mac-faq/CSMP_PD_FAQ 
  20. or using anonymous FTP as pub/hacks/mac-faq/CSMP_PD_FAQ You can also 
  21. find it on rtfm.mit.edu unedr the name macintosh/programming-faq.  An 
  22. HTML version is available.
  23.  
  24. No FAQ can substitute for real documentation (some of which is 
  25. mentioned in this FAQ) If you ask a question in comp.sys.mac.programmer 
  26. which has a good answer in one of the important sources, you will probably 
  27. not get an answer.  (Inside Macintosh, Macintosh Technical Notes being 
  28. important sources).
  29.  
  30. There is NO or VERY LIMITED error checking in the code examples, FOR 
  31. BREVITY ONLY.  You should make sure you ALWAYS check ALL return codes, 
  32. and handle any that you are not prepared to deal with appropriately.  
  33. Needless to say, do not use the code as is.
  34.  
  35. Exciting new stuff to search for: patmos, boycott of Apple, floating 
  36. point type, Client/Server
  37.  
  38. Topics:
  39. [search for *number* to find a topic quickly]
  40. [topics changed since last FAQ are marked with "+", new topics with ">"]
  41.  
  42.  1. +Development Tools
  43.          getting started, tool-specific issues
  44.  2. Memory
  45.          handles, large arrays, resource handles
  46.  3. +User Interfacing
  47.          menus, windows, events, multitasking
  48.  4. +Files
  49.          Mac fopen, wdrefnums, getting full pathnames
  50.  5. Imaging
  51.          QuickDraw and the means to avoid it
  52.  6. +Text
  53.          Text editing packages, strings to floats
  54.  7. Communications and Networking
  55.          Serial ports, TCP/IP, sockets
  56.  8. Interapplication Communication
  57.          AppleEvents, OSA, Scripting, and You
  58.  9. Dynamic Linking
  59.          the dynamics of external code resources
  60. 10. Compatibility
  61.          gestalt & glue
  62. 11. Optional System Software
  63.          11.1. QuickTime
  64.            codec details and the lack thereof
  65. 12. +Third-Party Solutions
  66.          databases
  67. 13. Dessert
  68.          yummies the Macintosh Way
  69. 14. Contributors
  70.          whodunnit
  71.  
  72. *1* Development and debugging tools for the Macintosh 
  73.  
  74. 1.1) Q: What do I need to start writing Macintosh software? 
  75.  
  76. A: A Mac, a lot of time, and a few hundred $.  Although you can develop 
  77. software on a Classic-type machine, it is not to be attempted by the 
  78. weak of heart or stressed of time.  If you're doing paid work and/or 
  79. work for a company, a Quadra-class machine or Centris 650 or better is 
  80. almost a must; remember that your time costs your employer much more than 
  81. just your salary.  A PowerMac is preferable.  16 MB is a minimum to run at 
  82. all comfortably, and Virtual Memory (including RamDoubler, unfortunately) 
  83. is not suited for development work.  Similarly, if you don't have at least 
  84. 80 MB free on your hard disk you need to buy more space.
  85.  
  86. You need a development system such as Think C, CodeWarrior C++, MPW C or 
  87. Prograph, you need at least some of the New Inside Mac books (Toolbox 
  88. Essentials, Files, Memory come to mind) and a good entry-level 
  89. third-party book may help.
  90.  
  91. Once you are up to speed on the general layout of the Mac and its 
  92. toolboxes, you should call APDA and order the monthly developer mailing, 
  93. which will give you a CD chock full of documentation, utilities and 
  94. system software once a month.  You will also, obviously, need a CD 
  95. player; one of which Apple's own CD300 is a very good buy at the time of 
  96. writing this.  If you don't have the dough for the monthly mailing 
  97. ($250/year) you can order a _develop_ subscription; this quarterly 
  98. magazine ($30-$50/year) comes with a CD containing most Inside Mac 
  99. documentation.  Another good product to order is the MacOS SDK, which 
  100. for $99 gives you a CD with every API in existence up to and including 
  101. the 7.5 Mac Toolbox additions.  <apda@appplelink.apple.com>
  102.  
  103. If you don't know how to program, go learn your language of choice 
  104. BEFORE attempting a "real" Mac application.  Programming is a discipline 
  105. often requiring different thought processes than your normal day job.  A 
  106. beginning book, like Lippman: The C++ Primer, or Sydow: Think THINK C 
  107. might help (the latter uses the Think C compiler, while the former can 
  108. be used with any C++ compiler)
  109.  
  110. Another tool which many find a must-have is the Think Reference version 
  111. 2.0.1, containing reference material on the most used parts of the Mac 
  112. toolbox with lightning-fast look-up and mostly correct usage hints and 
  113. code snippets.  It does not cover the newest system additions, nor the 
  114. modern "universal" headers format, though.
  115.  
  116. 1.2) Q: What is the most used Macintosh development system? 
  117.  
  118. A: Out of products on the market, I have no idea; MPW, Think and products 
  119. appear to be used.  Lately, CodeWarrior has come out of nowhere and grabbed 
  120. a large share of the market visibility because they have the fastest 
  121. compiler and they generate PowerPC code as well as 68K code.  Among 
  122. hobbyists, the Think products from Symantec are most popular because of the 
  123. low price, and steep educational discounts, and, of course, the easily 
  124. approachable interface! However, now that CodeWarrior is available at 
  125. $69-$99 educational price; anything can happen.
  126.  
  127. The Think C linker only strips dead code on a FILE level basis (and this 
  128. is when you turn on "Smart Linking") The MPW linker (of no specified IQ, 
  129. as someone so eloquently put it :-) strips dead code by the function, as 
  130. does CodeWarrior.  That may be part of the reason the Think C linker is 
  131. ten times faster than the MPW linker - but then how do you explain the 
  132. CodeWarrior linker, which links like the MPW linker, but at speeds 
  133. approaching Think C?
  134.  
  135. In the beginning, the Mac was programmed using Mc68000 assembly or 
  136. Pascal; this was reflected in the Old Inside Mac volumes which only gave 
  137. Pascal-style and assembly-style interfaces to the Mac toolbox.  These 
  138. days, Apple tells us to use C or even better C++ for developing new 
  139. applications, as that will speed up the transition to PowerPC and also 
  140. coming cross-platform efforts.  (Language Systems have a Pascal for 
  141. PowerPC product now, but I don't know about pricing or quality)
  142.  
  143. There are also at least two Fortran compilers, at least three SmallTalk 
  144. implementations (ObjectWorks, SmallTalk/V and SmallTalkAgents) and 
  145. others.  There are ways of stripping SmallTalk apps so they're smaller 
  146. and faster as standalone apps than in the environment.
  147.  
  148. There's also a world-class LISP/CLOS implementation from Apple called 
  149. Macintosh Common Lisp.  Recently, Apple announced that DigiTool has 
  150. licensed MCL with the intent (among other things) to provide a PowerMac 
  151. version and other updates.
  152.  
  153. Metrowerks have a Pascal and a C and C++ compiler for both 68k and Power 
  154. Macs; the package with the three of them is called "CodeWarrior." 
  155. CodeWarrior is conquering the marketplace rapidly, mostly due to the 
  156. excellent and generous online support.  See comp.sys.mac.programmer.  
  157. codewarrior for more information and CodeWarrior-related praise.
  158.  
  159. Zedcor has FutureBasic, which seems to be very popular.
  160.  
  161. CSI has MacForth, of which I only know the name and someone who says 
  162. it's pretty good.
  163.  
  164. There is another good Common Lisp implementation: Procyon Common Lisp.  
  165. I don't know if it is actively supported, but Procyon CL is also 
  166. available for DOS, OS/2 and Windows (as Allegro CL/PC) and actively 
  167. developed.
  168.  
  169. A new possible up-and-coming languge is Apple's Dylan, which is 
  170. something of a cross between BASIC, Pascal, and C.  C-based code can be 
  171. used directly from Dylan, but Dylan can't yet be used directly from C.  
  172. Apple's Dylan enviroment is as far beyond Metrowerks C++ as Metrowerks 
  173. C++ is beyond thick bundles of FORTRAN puch cards.
  174.  
  175. 1.3) Q: Where do I find a free/share/copyleftware C compiler for the Mac? 
  176. Is there a GCC for the mac? What about the FSF boycott of Apple products?
  177.  
  178. A: There is no really good solution for a "for-free" C development 
  179. system for the Mac.  GCC has been ported, but requires the MPW shell and 
  180. MPW assembler to run; these have to be bought from APDA.  There is a 
  181. standalone port of GCC 1.37 on nic.switch.ch:software/mac/src/think_c.  
  182.  
  183. gcc-1.37r14 V1.1 standalone is available for ftp at nic.switch.ch: 
  184. software/mac/src/think_c.
  185.  
  186. A not-entirely-stable port of GCC 2.3.3 to MPW is available for ftp at 
  187. atg.apple.com [anyone know the directory?].  A much more solid port of 
  188. GCC 1.37 is available for MPW as well.
  189.  
  190. Stan Shebs <shebs@cygnus.com>, the force behind all of the MPW GCC 
  191. ports, is working on a new port of GCC 2.5.8.
  192.  
  193. For those whose main interest is in developing only text based C/C++ 
  194. programs, using GCC under MacMiNT might be appropriate.  MacMiNT is a 
  195. UNIX like operating system ported from the Atari ST which supports many 
  196. freely available UNIX utilities like GCC, GDB, make, tcsh, byacc, perl, 
  197. and more.  MacMiNT stuff can be found at nic.switch.ch in 
  198. 'software/mac/src/macmint'.
  199.  
  200. The FSF/LPF boycott of Apple products is over, as of January 1995, which 
  201. means they will now incorporate changes made for Macintosh into their 
  202. main code base, if such changes are easily incorporated, and they 
  203. won't be any more antagonistic to Mac programmers than they would be 
  204. to any other micro-to-workstation-class programmers.
  205.  
  206. So what are you waiting for? Go out and port something from GNU! Send in 
  207. the changes!  We still lack decent free development tools!  Get Involved!
  208.  
  209. 1.4) Q: Are there any other free Mac development platforms? 
  210.  
  211. A: The best source for information on free compilers/interpreters, such 
  212. as they are is the Free Compilers FAQ which is written by Brian Connors 
  213. <connorbd@cleo.bc.edu>.  Watch for it in c.s.m.p.info.
  214.  
  215. 1.5) Q: What's the difference between the MPW, Think and CodeWarrior 
  216. environments?
  217.  
  218. A: The main difference is that Think and CodeWarrior are integrated 
  219. environments, while MPW provides you with a command-line shell for your 
  220. Mac and tools to use in it.  MPW also has a slightly higher systems 
  221. demand and a much slower linker.
  222.  
  223. The good thing about MPW is that you can write scripts and make files to 
  224. do anything you want in the way you want it.  Think doesn't have a 
  225. viable solution to do a build that requires more than one link 
  226. operation, or has more than one destination file.  CodeWarrior can be 
  227. AppleScripted to do this.
  228.  
  229. For the MPW environment, there are three source level debuggers; SADE, 
  230. SourceBug and Voodoo Monkey.  The latter is an experimental debugger 
  231. with support for threads debugging; the middle is bundled with MPW while 
  232. SADE has to be bought separately (but is fully scriptable in its own 
  233. scripting language)
  234.  
  235. The Think environments have their own integrated debuggers; the Think 
  236. Pascal one has a lot of useful features while the Think C/C++ one is a 
  237. little more basic (but is gaining in functionality with each release) 
  238. Stepping through source code and looking at variables is generally 
  239. faster and easier in Think than the MPW debuggers.
  240.  
  241. Metrowerks has their own debugger which works like the MPW debuggers; i e 
  242. it runs the application standalone and pokes at it from the outside, 
  243. while the Think debuggers run the application "wrapped" in a special 
  244. environment, making for some subtle interferences with your heap (which 
  245. you usually don't notice).  The Metrowerks Debugger is Thread 
  246. Manager-saavy.
  247.  
  248. CodeWarrior is by far the fastest compiler; it can compile to 68k code 
  249. on a Power Macintosh for really fast compiles.  Symantec C++ (a k a 
  250. "Think C++") is the most complete C++, containing a somewhat poor 
  251. implementation of templates and no other post-1990 extensions.  MPW has 
  252. the most powerful environment, which is inspired directly by Un*x.
  253.  
  254. Any commercial Mac developer should have CodeWarrior.  MPW is an option 
  255. which makes sense if you need to develop code for 68k OpenTransport.  
  256. CodeWarrior includes the non-compiler parts of MPW and MPW-hosted 
  257. Metrowerks compilers/linkers.
  258.  
  259. 1.6) Q: What is a good low-level debugger for the Mac? 
  260.  
  261. A: MacsBug is freely available for ftp from ftp.apple.com; log in as 
  262. user anonymous and give your FULL e-mail address as password.  MacsBug 
  263. is your basic monitor-type debugger that takes a few hundred Ks of 
  264. memory, and lets you break, step, disassemble, look at the stack etc of 
  265. most anything running on your Mac.  Since it's free (it's also on the 
  266. developer CDs) and provides most of the functionality you need, this is 
  267. a popular choice.  Macsbug is not native, though PowerPC-dissasembling 
  268. dcmds are available on the Developer CD.
  269.  
  270. TMON is another debugger which sports a more mac-like interface; it 
  271. provides windows and uses the mouse.  It can take as little or much 
  272. memory as you want by excluding or including certain areas of 
  273. functionality.  A nice touch is the 6502 disassembler that you can use 
  274. to de-bug the code the IOP processors run on the Mac IIfx and Quadra 
  275. 900/950.
  276.  
  277. Jasik Designs have a debugger called The Debugger which can do both low- 
  278. and high-level debugging, with or without source and for all types of 
  279. code, application, code resources, everything.  This is the debugger of 
  280. choice for many large developers because of its high power and many 
  281. features not found anywhere else.  However; newcomers beware! This is 
  282. the Lamborghini of debuggers; if you know how to drive it, it is the 
  283. fastest way from A to B; if you don't, you'll just end up in the ditch.  
  284. As a lady put it: "The man wouldn't know a user interface if it bit him 
  285. in the rear."  The Debugger is PowerMac native and supports PowerPC 
  286. disassembly.
  287.  
  288. 1.7) Q: Are there any visual developments environments for the 
  289. Mac (comparable to Visual C++)?
  290.  
  291. A: There is no Visual C++ as such.  However, there is a C++ parser/editor 
  292. called ObjectMaster which provides good browsing and editing capabilities 
  293. if you already have a C++ compiler.  A demo is available on the CodeWarrior 
  294. CD.  Think C++ comes with a browser built-in, and you can edit 
  295. dialogs/windows using plain old ResEdit, even for your custom view types.
  296.  
  297. Symantec C++ 7.0 also bundles a view editor/code generator called Visual 
  298. Architect; it is fairly complete and has a good level of integration 
  299. into the Think Project Manager.
  300.  
  301. AppMaker is a GUI builder/code generator.  Granted, it's not as nice as 
  302. VC++, but it's quite a product in any case.
  303.  
  304. MarksMan version 3.0 has totally revised TCL templates, and now 
  305. generates well-thought-out TCL code.  It can also generate ANSI C code 
  306. etc.
  307.  
  308. Also, Neuron Data has their UI tool called Open Interface, which is 
  309. better than VC++ and creates code portable across 35 platforms.  
  310. Unfortunately it's $2500 per developer per platform.  There's also two 
  311. other cross-platform products called XVT and Galaxy, the former has 
  312. gotten flak on UseNet while the latter reportedly is the premier 
  313. cross-platform application builder framework; with everything from 
  314. styled text to network support.
  315.  
  316. There is a fully visual, dynamic, object oriented data-flow-driven
  317. programming language for the Mac called Prograph CPX.  It features a
  318. full-featured class library, a powerful, user-extensible GUI Builder, full
  319. access to the entire Mac toolbox, a database engine, high-level interfaces
  320. to SQL, Oracle, etc.  But the coolest thing about Prograph is its
  321. interpretative debugger, fully integrated with the visual code editor,
  322. which lets you write your code _while it's running_.  Execution
  323. automatically rolls back to where changes you make have relevance.  A
  324. PowerMac-native compiler and a Windows version are expected in '95.  A
  325. complete demo version is available from <sales@prograph.com>.  Cost is 
  326. $695 ($395 for students).
  327.  
  328. SmalltalkAgents comes with a GUI builder, which lets you draw your
  329. interface, and then outputs the code for you.
  330.  
  331. If you'd rather do Common Lisp, Macintosh Common Lisp offers a Common 
  332. Lisp Object System with support for most Mac interface items; you can 
  333. edit code while it is running and build stand-alone applications.
  334.  
  335. However, all of these tools generate rather larger binaries with larger 
  336. system demands than a program written in C.  On the other hand; C++ 
  337. programs require more memory and disk space than programs written in 
  338. assembly.  It's a trade-off, and I believe this type of tools is the 
  339. wave of the near future.
  340.  
  341. 1.8) Q: What class libraries are there for the Mac? 
  342.  
  343. A: Apart from the libraries mentioned above, there are three contenders: 
  344. MacApp, TCL, and PowerPlant.  "Bedrock" will never be released as a 
  345. product, although parts of it surface in TCL 2.0 and other parts will be 
  346. the base for the OpenDoc Parts Framework.
  347.  
  348. MacApp is a heavy-duty class library that has tons of features and a 
  349. steep learning curve; it runs under MPW with Pascal or C++, and also 
  350. under Think Pascal 4.0 A major application written in MacApp is 
  351. PhotoShop.
  352.  
  353. TCL stands for Think Class Library and comes with Think Pascal, C or 
  354. C++.  It is a smaller library that still fills most peoples needs; since 
  355. Think C implements a subset of C++ (the most important OO concepts such 
  356. as virtual functions and inheritance) and the TCL is carefully written 
  357. not to take advantage of any C++ features not in Think C, you can use it 
  358. with Think C.  A major application written in TCL is Lotus 1-2-3.  (TCL 
  359. 1.1.3) Starting with Symantec C++ 7.0, Think Class Library 2.0 using 
  360. templates and "real" C++ objects is shipping.
  361.  
  362. PowerPlant is the Metrowerks CodeWarrior offering; it's written by the 
  363. guy who designed the Think Class Library, but it has a lot of 
  364. differences from the original TCL; for one, it's not a monolithic one 
  365. base class framework.  On the other hand, it has some catching up to do 
  366. before it reaches the level of MacApp.  It is gaining quite fast on TCL, 
  367. but isn't all there yet.
  368.  
  369. 1.9) Q: How should I debug and test my software? 
  370.  
  371. A: Get ahold of, and install, the extensions DoubleTrouble, 
  372. DisposeResource and EvenBetterBusError.  They will catch 80% of any 
  373. memory related bugs you may have, including many bugs that follow NULL 
  374. handles or pointers.  ** Note: there have been some reports of trouble 
  375. with these and PowerMacs.
  376.  
  377. A low-level debugger is required, and while you install it, install the 
  378. "leaks" dcmd which will help you catch memory leaks in your application.  
  379. All of these tools are available from <ftp.apple.com>.
  380.  
  381. 1.10) Q: Are there any good Mac programming magazines?
  382.  
  383. A: One Mac programming magazine I know of is MacTech Magazine (formerly 
  384. MacTutor).  It covers a variety of Mac programming topics on various 
  385. levels.  Operating independently from Apple, it has a lot of stuff for 
  386. the beginning Mac programmer, as well as occasional nuggets for the more 
  387. experienced of us.  <custservice@xplain.com>
  388.  
  389. Another VERY GOOD Magazine is _develop_ which is put out by Apple four 
  390. times a year; it comes with a CD containing code for all articles ever 
  391. published in _develop_, and a lot of documentation and system software 
  392. freebies as well.  $30/year in the US.  <dev.subs@applelink.apple.com>
  393.  
  394. Icognitive Systems is starting a new magazine called "MacOS 
  395. Development".  It's advertised as being for the "professional MacOS 
  396. Developer.'
  397.  
  398. 1.11) Q: What about protected memory? I'm sick and tired of re-booting 
  399. when my application crashes.
  400.  
  401. A: Write better software! 
  402.  
  403. Or install The Debugger from Jasik Designs, which can provide your 
  404. application with write-protection of critical parts of memory, if you have 
  405. a 68030-equipped Mac.
  406.  
  407. Making the Mac OS memory-protected is tricky, because applications expect 
  408. to be able to write to low memory, the system heap, temporary memory, 
  409. window lists, and even each other's heaps in some interapplication 
  410. communication solutions that date back to before AppleEvents and the PPC 
  411. Toolbox.
  412.  
  413. But fear not, Mac fans! Jonathan Kimmitt has written Patmos, the 
  414. "Protected address translation mode operating system".  It is an 
  415. application that brings the advantages of protected mode programs to 
  416. your Quadra class Macintosh by the simple expedient of taking over the 
  417. memory management unit of the 68040 in a very simple kernel (<100K in 
  418. size), we immediately gain compatibility with the BSD unix program 
  419. environment.  The advantages of this are as follows:
  420.  
  421. (a) You can run certain programs (such as /bin/sh) designed for MacBSD
  422. (b) You can compile almost all GNU software including C and C++ without.
  423. modifying the source code in any way
  424. (c) All programs run with a flat 32-meg address space, with no worries
  425. about 32K segments or the other mac paraphernalia.
  426. (d) The majority of program bugs can be caught cleanly without crashing
  427.  your mac
  428. (e) All your files are shared between Patmos and MacOS so you can edit 
  429. using your favourite mac editor, then immediately compile in Patmos 
  430. without having to reboot or copy files around.
  431.  
  432. The downside is that not all macs use the memory management unit in the 
  433. same way, or even have the same kind of MMU, so Patmos may not run on 
  434. your particular mac model.  However, since the kernel source code is 
  435. very small, the task of adapting it to a new environment is very simple, 
  436. and once achieved, all application programs running in user mode are 
  437. enabled to run without even recompiling.
  438.  
  439. Ftp from nic.switch.ch in the /software/mac/src/Patmos
  440.  
  441. 1.12) Q: I have this library written in (Think) Pascal that I want to use 
  442. from Think C/Symantec C, but I get link errors/don't know how to do it.  
  443. What should I do?
  444.  
  445. A: Start by writing a .h file describing the interface.  Remember to 
  446. declare the Pascal functions "pascal".  Build a library with Think Pascal 
  447. and convert it with oConv.
  448.  
  449. Do you get link errors on symbols defined in your Pascal lib? Check the 
  450. capitalisation used.
  451.  
  452. Do you get errors on symbols like LMUL and LDIV? Those functions are 
  453. defined in the Think Pascal library Runtime.lib or uRuntime.lib.  Include 
  454. uRuntime.lib and try again.
  455.  
  456. Do you get link errors on standard symbols like thePort? This is due to 
  457. bad capitalization in Symantec's libs.  Run oConv with .v checked.  This 
  458. will create a TEXT file with a .v extension.  Open that with a text 
  459. editor and correct the capitalization.  Run oConv again, with .v checked 
  460. this time too.
  461.  
  462. Do you still get errors on standard symbols? Are you using Think 
  463. C/Symantec C++ version 6 or higher? Then you must open the library (after 
  464. converting it) from Think C version 5, and remove the unit named 
  465. %_TOOLBOX.  (If I'm not mistaken, this is the toolbox init unit, which 
  466. you won't need anyway.)
  467.  
  468. 1.13) Q: CodeWarrior vs. Think/Symantec C++:  Which is better?
  469.  
  470. A: CodeWarrior, assuming you want to develop for PowerMacs.  CodeWarrior, 
  471. assuming you want to develop for 68k-based Macs.  Metrowerks has publicly 
  472. announced plans for a Mac-hosted x86 cross-compiler (codenamed 
  473. "Icebreaker"), so after next WWDC, you can develop for 486-based PCs.  
  474.  
  475. Note that this applies only to Symantec C++ 7 and below.  I haven't yet 
  476. seen 8.0.
  477.  
  478. 1.14) Q: Can CodeWarrior read Think project files (or, dare I suggest, 
  479. libraries)?
  480.  
  481. A: No.
  482.  
  483. 1.15) Q: Why not?
  484.  
  485. A: Because Metrowerks employs some people who formerly worked at Symantec, 
  486. and they're afraid of possible litigation from Symantec, since they may 
  487. not be able to prove that they didn't get Symantec's proprietary format 
  488. information from those ex-Symantec employees.
  489.  
  490. 1.16) Q: What are some good books on the subject of learning the Mac 
  491. Toolbox?
  492.  
  493. A: Any of Dan Parks Sydow's several books on the subject.  Recommended 
  494. also is Dave Mark's Mac Programming C Primer.  If you don't know C or 
  495. C++, some people recommend Dave Mark's Learn C on the Mac, others don't.  
  496. The problem with the book is that it doesn't teach much (or in fact 
  497. anything) about the art of programming from a Macintosh perspective.  
  498. You receive an introduction to the fundamentals of a particular Mac 
  499. programming enviroment and to some basic C or C++.  Much better is the 
  500. combination of the Symantec C++ manual and _Teach Yourself C++_ by Al 
  501. Stevens, an excellent OS-neutral introduction to all of ARM C++, including 
  502. templates and exceptions.  For ANSI standard C++ (which is not yet 
  503. available) you'll have to look elsewhere.
  504.  
  505. 1.17) Q:  Source code!  I want source code!
  506.  
  507. A: Celestin Company, Inc. sells the Apprentice 2 CD-ROM.  Apprentice 
  508. contains over 600 megabytes of programmer utilities and up-to-date 
  509. source code in CodeWarrior, Symantec, and MPW projects for C, C++, and 
  510. Pascal.  <ftp://ftp.teleport.com/vendors/cci/apprentice/apprentice.hqx>
  511. for an index and info.  <celestin@olympus.net>
  512.  
  513. *2* Memory
  514.  
  515. 2.1) Q: What is a handle? 
  516.  
  517. A: A handle is a pointer to a pointer to something.  However, it is more 
  518. than that; creating a handle by taking the address of one of your own 
  519. pointers does NOT create a Handle; the Memory Manager will only deal 
  520. properly with Handles that are created using NewHandle or something that 
  521. calls it (such as NewRgn or GetResource).
  522.  
  523. 2.2) Q: When do I have to lock a Handle? 
  524.  
  525. A: The contents of a Handle may move, and when it does, the pointer your 
  526. handle is pointing to is changed to point to the new address so your 
  527. handle is always valid.  The toolbox may call the memory manager to 
  528. allocate more memory pretty much anytime you call it (the toolbox) and 
  529. when memory is allocated, your handle may move in memory.  Don't 
  530. dereference a handle into a pointer (or take the address of a field in a 
  531. record a handle is double-pointing to) and then call the toolbox and 
  532. expect the pointer to still be valid.  The only way to ensure that the 
  533. pointer will still be valid is to call HLock on the handle to lock it.
  534.  
  535. Use HGetState and HSetState to save & restore the "locked" state of a 
  536. handle when you lock it.
  537.  
  538. 2.3) Q: How do I dispose of Handles? 
  539.  
  540. A: DisposeHandle (formerly called DisposHandle) once and ONLY once will 
  541. do the trick.  Trying to dispose of an already disposed Handle is an 
  542. error.  DoubleTrouble (see above) will catch such bugs when they do 
  543. occur.
  544.  
  545. 2.4) Q: What about resources? 
  546.  
  547. A: Calling GetResource returns NULL if the resource is not found or 
  548. there is not enough memory, else it returns a handle to the resource.  
  549. This handle may be moved or locked like any other handle, but DO NOT 
  550. call DisposeHandle to get rid of a resource handle - call 
  551. ReleaseResource.  DisposeResource (see above) will catch this kind of 
  552. bug.
  553.  
  554. Remember that AddResource makes a resource handle out of an ordinary 
  555. handle, and RmveResource or DetachResource makes an ordinary handle out 
  556. of a resource handle.  You cannot call AddResource with a resource 
  557. handle; you have to DetachResource it first.
  558.  
  559. Resource handles are automagically disposed when the resource file they 
  560. belong to is closed.
  561.  
  562. 2.5) Q: I'm trying to use a largish array in Think C, but get a "code 
  563. overflow" error.  This is valid C, why doesn't it work?
  564.  
  565. A: The ANSI standard does not guarantee that any structure larger than 
  566. 32767 bytes be correctly handled.  Because of historical constraints, 
  567. the Mac memory model is built around several small blocks of size 32K or 
  568. less; these are used both for code and global/static data.  If you want 
  569. to use more code or data, you have to turn on "far code" or "far data" - 
  570. you still will not get around the restriction of 32K code or data per 
  571. compiled file, though.
  572.  
  573. This is one area where CodeWarrior shines; it works around most such 
  574. limitations and it doesn't cost much in performance either!
  575.  
  576. As opposed to, say, DOS or Windows, however, you can allocate as much 
  577. memory as you want (and there is in the machine) and step through it 
  578. using ordinary pointers; it's just that global and static data space is 
  579. addressed off the A5 register using a 16bit displacement addressing mode 
  580. in the 68000 processor.
  581.  
  582. On the PowerPC, everything is 32bit from the start; that runtime model 
  583. is much more like UNIX because it's taken from IBMs AIX.  No limitations 
  584. there.
  585.  
  586. *3* User interaction and You
  587.  
  588. 3.1) Q: How do I read the modifier keys of the keyboard? 
  589.  
  590. A: Just call EventAvail and check the event.modifiers field. 
  591. Only works when you are in the foreground. You can also use 
  592. GetKeys(), or (as a last resort) check the lo-mem global KeyMap 
  593. directly. 
  594.  
  595. 3.2) Q: How do I move the mouse cursor to a specific position?
  596.  
  597. A: Wait! Don't do it! There has to be a better way!
  598.  
  599. If you feel you HAVE to do it (for a game or VERY special simulation 
  600. situation) you can use the Cursor Device Manager documented in the tech 
  601. notes on <ftp.apple.com>.  If that manager is not installed, as it's not 
  602. on older Macs, you can use the following code:
  603.  
  604. you need to have some low-memory globals defined.  they may be defined 
  605. in SysEqu.h.
  606.  
  607. #define MTemp 0x828
  608. #define RawMouse 0x82c
  609. #define CrsrNewCouple 0x8ce
  610.  
  611. note that CrsrNewCouple is actually a combination of two globals, just 
  612. to make our life slightly easier.
  613.  
  614. the code i use to move the mouse is:
  615.  
  616. *code*
  617. void
  618. MoveMouseTo ( Point where ) {
  619.  
  620.         HideCursor ( ) ;
  621.         * ( Point * ) RawMouse = where ;
  622.         * ( Point * ) MTemp = where ;
  623.         * ( short * ) CrsrNewCouple = -1 ;
  624.         ShowCursor ( ) ;
  625. }
  626. *end*
  627.  
  628. you need to hit a couple more global variables if you want this to work 
  629. properly in a multiple-monitor system, but i forget what they are 
  630. offhand.  poke through SysEqu.h, and you should be able to figure it out 
  631. without a problem.
  632.  
  633. On the PowerPC, these lo-mem globals may not be available for native 
  634. applications; however, all Power Macintoshes implement the Cursor Device 
  635. Manager.  All Macs made after March '93 (including Centris 650 and 610) 
  636. implement the Cursor Device Manager, in fact.
  637.  
  638. There is also a file on nada.kth.se:pub/hacks/mac-faq/MoveMouse.c which 
  639. shows how to use the Cursor Device Manager, written by an excellent 
  640. Apple engineer.  Grab!
  641.  
  642. 3.3) Q: My menus don't show up in the menu bar
  643.  
  644. A: If your menus are hiearchical, you'll have to install them manually; 
  645. GetNewMBar won't do it for you.  See also 15.2.
  646.  
  647. 3.4) Q: When the user selects my menus, I get strange results back; they 
  648. seem to have different menu IDs than my menus?
  649.  
  650. A: The Menu ID as used by the menu manager is NOT the same thing as the 
  651. MENU resource ID (used in the MBAR resource and with GetMenu()) When you 
  652. create a MENU, ResEdit sets the menu ID to the MENU resource ID, but if 
  653. you re-number the resource, you will have to open the menu in ResEdit 
  654. and change the menu ID using the "Edit MENU ID" menu item.
  655.  
  656. 3.5) Q: I use GetMenu() to find a menu in the menu bar, and then change 
  657. it, but it seems I have a memory leak OR my changes don't "punch 
  658. through"
  659.  
  660. A: GetMenu() is only intended if you don't already have the menu "in 
  661. memory." The call you should use almost all the time is GetMHandle() 
  662. which gets the handle to a menu in the current menu bar by its menu ID 
  663. (not resource id)
  664.  
  665. 3.6) Q: What about pre-emptive multitasking? 
  666.  
  667. A: To the user, the Mac multitasking method, which builds upon each 
  668. application calling WaitNextEvent, GetNextEvent or EventAvail every so 
  669. often and the Process Manager/MultiFinder switching applications only at 
  670. such calls, is at least as good as preemtive multitasking, because the 
  671. present system priotitizes user interface responsiveness over everything 
  672. else.  The only shortfall about this is formatting floppies, which locks 
  673. up the Mac CPU.  This is because the Mac floppy controller is really 
  674. stupid, and would happen even if the Mac multitasked preemptively.
  675.  
  676. There IS "real" pre-emptive multitasking available for use in Mac 
  677. applications; the expensive way is buying A/UX 3.0 which can have Mac 
  678. applications written as UNIX processes; the cheap way is installing the 
  679. Thread Manager which will allow you to create pre-emptive threads.  
  680. However, the restrictions on those threads are the same as those on Time 
  681. Manager tasks: don't call any function in an unloaded segment, and don't 
  682. call QuickDraw or any toolbox call which may move memory (which are most 
  683. ToolBox calls; paradoxally, BlockMove is safe :-) as are, surprisingly, 
  684. FSRead and FSWrite).
  685.  
  686. There are several problems with making the Mac OS preemptive; including 
  687. apps that draw outside their windows or directly to screen, user dragging 
  688. and other issues.  The system is being reimplemented for 8.0 to solve 
  689. these problems.
  690.  
  691. *4* Files
  692.  
  693. 4.1) Q: How do I tell fopen() to open a file the user has selected using 
  694. StandardGetFile?
  695.  
  696. A: The "standard" ANSI C file functions are less than well suited for 
  697. the Macintosh way of doing things.  However, if you are doing a port for 
  698. your own enjoyment and benefit (or maybe for in-house work) you can use 
  699. the following function: (see below about converting a wdRefNum into a 
  700. vRefNum/parID pair)
  701.  
  702. *code*
  703. FILE *
  704. fopen_mac ( short vRefNum , long parID , char * fileName , char * mode ) {
  705.  
  706. short oldVol ;
  707. short aVol ;
  708. long aDir , aProc ;
  709. FILE * ret = NULL ;
  710.  
  711.         if ( GetVol ( NULL , & oldVol ) ) {
  712.                 return NULL ;
  713.         }
  714.         if ( GetWDInfo ( oldVol , & aVol , & aDir , & aProc ) ) {
  715.                 return NULL  ;
  716.         }
  717.         if ( HSetVol ( NULL , vRefNum , parID ) ) {
  718.                 return NULL ;
  719.         }
  720.         ret = fopen ( fileName , mode ) ;
  721.         if ( HSetVol ( NULL, aVol , aDir ) ) {
  722.                 /* an error we can't currently handle */
  723.         }
  724.         if ( SetVol ( NULL, oldVol ) ) {
  725.                 /* an error we can't currently handle */
  726.         }
  727.         return ret ;
  728. }
  729. *end*
  730.  
  731. All of the above is necessary for one reason or another - if you are 
  732. interested, by all means look HSetVol up in Think Reference 2.0 or New 
  733. Inside Mac: Files.
  734.  
  735. In older versions of MPW; this wouldn't work since the MPW libraries 
  736. used to do a GetVol and explicitly use that value by itself.
  737.  
  738. 4.2) Q: When can I use the HOpen, HCreate etc file calls? Are they only 
  739. System 7 calls?
  740.  
  741. A: All the HXxx calls that take a vRefNum and parID as well as the file 
  742. name are implemented in glue that works on any system that has HFS 
  743. (meaning 3.2 and up with the HD20 INIT, and all systems from System 6 
  744. and up)
  745.  
  746. The glue is available in MPW 3.2 and up, and Think C 5.0 and up.  This 
  747. goes for all HXxx calls except HOpenDF; therefore, if you are interested 
  748. in System 6 compatibility, use HOpen instead and make sure you don't 
  749. allow file names beginning with a period.
  750.  
  751. 4.3) Q: Why do you say wdRefNum sometimes and vRefNum sometimes? 
  752. Why do you say parID sometimes and dirID sometimes? 
  753.  
  754. A: When the Mac first made an appearance in 1984, it identified files by 
  755. using a vRefNum (volume reference number meaning a floppy disk or later 
  756. hard disk) and a name.  Once HFS saw the light of day, folders within 
  757. folders became a reality, and you needed a dirID as well to point out 
  758. what folder you really meant on the volume.  However, older programs 
  759. that weren't being rewritten still knew nothing about directory IDs, so 
  760. Apple had SFGetFile make up "fake" vRefNums that didn't just specify a 
  761. volume, but also a parent folder.  These are called wdRefNums (for 
  762. working directory) and were a necessary evil invented in 1985.  You 
  763. should not create (or, indeed, use) wdRefNums yourself.
  764.  
  765. There is a system-wide table that maps wdRefNums onto vRefNum/parID 
  766. pairs.  There is a limit to the size of this table.  A dirID and a parID 
  767. is almost the same thing; you say "parID" when you mean the folder 
  768. something is in, while you say a "dirID" when you mean the folder 
  769. itself.  If you for instance have a folder called "Foo" with a folder 
  770. called "Bar" in it, the parID for "Bar" would be the dirID for "Foo."
  771.  
  772. 4.4) Q: How do I convert a wdRefNum as returned by SFGetFile 
  773. into a vRefNum/parID pair to use with the HXxx calls?
  774.  
  775. A: Use GetWDInfo, which is declared as: 
  776.  
  777. Pascal OSErr GetWDInfo(short wdRefNum, short *vRefNum, long *parID, 
  778.     OSType *procID);
  779.  
  780. The procID parameter must be non-NULL and point to an OSType variable, 
  781. but the value of that variable can and should be ignored.
  782.  
  783. It is recommended that, as soon as you get your hands on a wdRefNum, for 
  784. instance from SFGetFile, you directly convert it into a vRefNum/parID 
  785. pair and always use the latter to reference the folder.
  786.  
  787. 4.5) Q: How do I select a folder using SFGetFile? 
  788.  
  789. A: This requires a custom dialog with a filter proc.  It is too 
  790. complicated to show here, but not totally impossible to comprehend.  
  791. There is sample code on ftp.apple.com, in the directory dts/snippets, on 
  792. how to do this.
  793.  
  794. 4.6) Q: How do I get the full path of a file referenced by a vRefNum, 
  795. parID and name?
  796.  
  797. A: You don't. 
  798.  
  799. OK, I cheated you.  There is exactly ONE valid reason to get the full 
  800. path of a file (or folder, for that matter) and that is to display its 
  801. location to the user in, say, a settings dialog.  To actually save the 
  802. location of the file you should do this: (assuming the file is in an 
  803. FSSpec called theFile - you can use FSSpecs in your program even if you 
  804. don't run under System 7; just make your own MyFSMakeFSSpec that fills 
  805. in the FSSpec manually if it's not implemented)
  806.  
  807. *code*
  808. if ( ! aliasManagerAvailable ) { /* System 6 ? */
  809.         GetVolumeName ( theFile -> vRefNum , vName ) ;
  810.         GetVolumeModDate ( vRefNum , & date ) ;
  811.         Save ( vName , date , parID , fileName ) ;
  812. } else {
  813.         NewAlias ( NULL , theFile , & theAlias ) ;
  814.         Save ( theAlias ) ;
  815.         DisposeHandle ( ( Handle ) theAlias ) ;
  816. }
  817. *end*
  818.  
  819. If you are really concerned about these issues (of course you are!) you 
  820. should save BOTH of these methods when available, and load back whatever 
  821. is there that you can handle; since users may be using your application 
  822. in a mixed System 6/System 7 environment.
  823.  
  824. To get back to the file is left as an exercise for the reader. 
  825.  
  826. To open a file using fopen() or the Pascal equivalent, see above about 
  827. using and not using HSetVol.
  828.  
  829. 4.7) Q: What about actually getting the full path for a file? I promise 
  830. I will only use it to show the location of a file to the user!
  831.  
  832. A: Enter PBGetCatInfo, the Vegimatic of the Mac file system.  Any Mac 
  833. hacker of knowledge has taken this system call to his heart.  Note that 
  834. this sample code isn't all there, but should point you in the right 
  835. direction:
  836.  
  837. *code*
  838. OSErr
  839. GetFolderParent ( FSSpec * fss , FSSpec * parent ) {
  840.  
  841. CInfoPBRec rec ;
  842. short err ;
  843.  
  844.         * parent = * fss ;
  845.         rec . hFileInfo . ioNamePtr = parent -> name ;
  846.         rec . hFileInfo . ioVRefNum = parent -> vRefNum ;
  847.         rec . hFileInfo . ioDirID = parent -> parID ;
  848.         if ( parent -> name [ 0 ] ) {
  849.                 rec . hFileInfo . ioFDirIndex = 0 ;
  850.         } else {
  851.                 rec . hFileInfo . ioFDirIndex = -1 ;
  852.         }
  853.         rec . hFileInfo . ioFVersNum = 0 ;
  854.         err = PBGetCatInfoSync ( & rec ) ;
  855.         if ( ! ( rec . hFileInfo . ioFlAttrib & 0x10 ) ) { /* Not a folder */
  856.                 if ( ! err ) {
  857.                         err = dirNFErr ;
  858.                 }
  859.         } else {
  860.                 parent -> parID = rec . dirInfo . ioDrParID ;
  861.                 parent -> name [ 0 ] = 0 ;
  862.         }
  863.         return err ;
  864. }
  865. *end*
  866.  
  867. *code*
  868. OSErr
  869. GetFullPathHandle ( FSSpec * fss , Handle * h ) {
  870.  
  871. Handle  tempH = NULL ;
  872. short err ;
  873. FSSpec fs = * fss ;
  874.  
  875.         while ( fs . parID > 1 ) {
  876.                 tempH = NULL ;
  877.                 PtrToHand ( & fs . name [ 1 ] , & tempH , fs . name [ 0 ] ) ;
  878.                 PtrAndHand ( ( void * ) ":" , tempH , 1 ) ;
  879.                 HandAndHand ( * h , tempH ) ;
  880.                 SetHandleSize ( * h , 0L ) ;
  881.                 HandAndHand ( tempH , * h ) ;
  882.                 DisposeHandle ( tempH ) ;
  883.                 tempH = NULL ; 
  884.                 GetFolderParent ( & fs , & sSpec ) ;
  885.                 fs = sSpec ;
  886.         }
  887.         GetVolName ( fs . vRefNum , fs . name ) ;
  888.         PtrToHand ( & fs . name [ 1 ] , & tempH , fs . name [ 0 ] ) ;
  889.         PtrAndHand ( ( void * ) ":" , tempH , 1 ) ;
  890.         HandAndHand ( * h , tempH ) ;
  891.         SetHandleSize ( * h , 0L ) ;
  892.         HandAndHand ( tempH , * h ) ;
  893.         DisposeHandle ( tempH ) ;
  894.         tempH = NULL ;
  895.         if ( ! IsFolder ( fss ) ) {
  896.         SetHandleSize ( * h , GetHandleSize ( * h ) - 1 ) ; // Remove colon }
  897.         return 0 ;
  898. }
  899. *end*
  900.  
  901. 4.8) Q: So how do I get the names of the files in a directory? 
  902.  
  903. A: You use PBGetCatInfo again, but this time you set ioFDirIndex to 1 or 
  904. more (you need to know the dirID and vRefNum of the folder you're 
  905. interested in) You then call PBGetCatInfoSync for values of ioFDirIndex 
  906. from 1 and up, until you get an fnfErr.  Any other err means you are not 
  907. allowed to get info about THAT item, but you may be for the next.  Then 
  908. collect the names in the string you made ioNamePtr point to as you go 
  909. along.  Note that you need to fill in the ioDirID field for each 
  910. iteration through the loop, and preferably clear the ioFVersNum as well.
  911.  
  912. Note that the contents of a directory may very well change while you are 
  913. iterating over it; this is most likely on a file server that more than 
  914. one user uses, or under System 7 where you run Personal File Share.
  915.  
  916. 4.9) Q: How do I find the name of a folder for which I only know the 
  917. dirID and vRefNum?
  918.  
  919. A: You call (surprise!) PBGetCatInfo! Make ioNamePtr point to an empty 
  920. string (but NOT NULL) of length 63 (like, an Str63) and ioFDirIndex 
  921. negative (-1 is a given winner) - this makes PBGetCatInfo return 
  922. information about the vRefNum/dirID folder instead of the file/folder 
  923. specified by vRefNum, parID and name.
  924.  
  925. 4.10) Q: How do I make the Finder see a new file that I created? Or if I 
  926. changed the type of it; how do I display a new icon for it?
  927.  
  928. A: You call (surprise!) PBGetCatInfo followed by PBSetCatInfo for the 
  929. FOLDER the file is in.  Inbetween, you should set ioDrMdDat to the 
  930. current date&time.  Code:
  931.  
  932. *code*
  933. OSErr
  934. TouchFolder ( short vRefNum , long parID ) {
  935.  
  936. CInfoPBRec rec ;
  937. Str63 name ;
  938. short err ;
  939.  
  940.         rec . hFileInfo . ioNamePtr = name ;
  941.         name [ 0 ] = 0 ;
  942.         rec . hFileInfo . ioVRefNum = vRefNum ;
  943.         rec . hFileInfo . ioDirID = parID ;
  944.         rec . hFileInfo . ioFDirIndex = -1 ;
  945.         rec . hFileInfo . ioFVersNum = 0 ;
  946.         err = PBGetCatInfoSync ( & rec ) ;
  947.         if ( err ) {
  948.                 return err ;
  949.         }
  950.         GetDateTime ( & rec . dirInfo . ioDrMdDat ) ;
  951.         rec . hFileInfo . ioVRefNum = vRefNum ;
  952.         rec . hFileInfo . ioDirID = parID ;
  953.         rec . hFileInfo . ioFDirIndex = -1 ;
  954.         rec . hFileInfo . ioFVersNum = 0 ;
  955.         rec . hFileInfo . ioNamePtr [ 0 ] = 0 ;
  956.         err = PBSetCatInfoSync ( & rec ) ;
  957.         return err ;
  958. }
  959. *end*
  960.  
  961. 4.11) Q: Aren't we done with PBGetCatInfo soon? 
  962.  
  963. A: Well, it turns out that you can also find out whether an FSSpec is a 
  964. file or a folder by calling PBGetCatInfo and check bit 4 (0x10) of 
  965. ioFlAttr to see whether it is a folder.  You may prefer to call 
  966. ResolveAliasFile for this instead.
  967.  
  968. You can also check the script of the file's title using PBGetCatInfo and 
  969. check the ioFlFndrXInfo field if you want to work with other script 
  970. systems than the Roman system.
  971.  
  972. Another common use is to find out how many items are in a folder; the 
  973. modification date of something or the correct capitalization of its name 
  974. (since the Mac file system is case independent BUT preserves the case 
  975. the user uses)
  976.  
  977. 4.12) Q: How do I set what folder should initially be shown in the 
  978. SFGetFile boxes?
  979.  
  980. A: You stuff the dirID you want to show into the lo-mem global 
  981. CurDirStore, and the NEGATIVE of the vRefNum you want into the lo-mem 
  982. global SFSaveDisk.
  983.  
  984. If you are using CustomGetFile and return sfSelectionChanged from an 
  985. "init" message handler, you must remember to clear the script code, else 
  986. the selection will not change.
  987.  
  988. 4.13) Q: How do I find the folder my application started from? How do I 
  989. find the application file that's running?
  990.  
  991. A: Under System 7, you call GetProcessInformation using the 
  992. ProcessSerialNumber kCurrentProcess with a pointer to an existing FSSpec 
  993. in the parameter block.  This will give you your file, and, by using the 
  994. vRefNum and parID, the folder the application is in.
  995.  
  996. *code*
  997. OSErr   CurrentProcessLocation(FSSpec *applicationSpec)
  998. {
  999.         ProcessSerialNumber currentPSN;
  1000.         ProcessInfoRec info;
  1001.         
  1002.         currentPSN.highLongOfPSN = 0;
  1003.         currentPSN.lowLongOfPSN = kCurrentProcess;
  1004.         info.processInfoLength = sizeof(ProcessInfoRec);
  1005.         info.processName = NULL;
  1006.         info.processAppSpec = applicationSpec;
  1007.         return ( GetProcessInformation(¤tPSN, &info) );
  1008. }
  1009. *end*
  1010.  
  1011. Beware from writing to your applications resource or data forks; the 
  1012. former breaks on CDs/write protected floppies/file servers/virus 
  1013. checkers, the latter fails on PowerPC as well as in the above cases.
  1014.  
  1015. 4.14) Q: When can I use those nifty, easy to use FSSpec calls?
  1016.  
  1017. A: In Systems >= 7, in System 6 with QuickTime installed, in any system 
  1018. if you use the FSpCompat functions provided by MoreFiles [see below].
  1019.  
  1020. 4.15) Q: I hate dealing with the low-level file manager stuff;  why 
  1021. didn't Apple provide a complete high-level interface using FSSpecs?
  1022.  
  1023. A: Good question.  Apple, in the guise of Jim Luther of Mac Developer 
  1024. Technical Support, has written a library called MoreFiles, which not 
  1025. only provides a high-level interface to low-level file stuff, but 
  1026. provides FSSpec glue for Systems below 7.  MoreFiles is available on the 
  1027. Developer CD's (see above) and also at Appple's developer ftp site.
  1028.  
  1029. *5* Imaging with QuickDraw
  1030.  
  1031. 5.1) Q: Why is CopyBits so slow? 
  1032.  
  1033. A: It is not.  It just requires some hand-holding to get good results.  
  1034. The main rules are: Make sure the source and destination pixMaps are of 
  1035. the same depth.
  1036.  
  1037. Make sure the front color is black and the back color is white.
  1038.  
  1039. Use srcCopy and don't use a masking region, unless it's rectangular. 
  1040.  
  1041. Copy to an unclipped window (the frontmost window).  Make sure the 
  1042. ctSeed values of the source pixMap and dest pixMap match. 
  1043.  
  1044. Copying few and large pixMaps is faster than copying many and small 
  1045. ones.  Icon-sized sprites count as small ones.
  1046.  
  1047. Make sure your source bitmap or pixelMap has the same alignment, when 
  1048. adjusted for the source and destination rect expressed in global screen 
  1049. coordinates.  The necessary alignment is 32 bits (4 bytes), although 128 
  1050. bit (16 byte) alignment is probably even better on 68040 macs and won't 
  1051. hurt on other macs.
  1052.  
  1053. Example of global alignment: 
  1054.  
  1055. Your window is positioned at (42,100) (H,V) 
  1056.  
  1057. Your destination rectangle is (10,20)-(74,52) 
  1058.  
  1059. The alignment coefficient of the rectangle in global coordinates is 
  1060. (42+10)*bitDepth where bitDepth is one of 1,2,4,8,16 or 32.
  1061.  
  1062. Make sure your source pixmap rect has the same coeffecient modulo your 
  1063. alignment factor (in bits) For black&white macs, this is still true, 
  1064. although bitDepth is fix at 1.  Offscreen pixMaps can calculate with a 
  1065. "global posistion" of 0,0 and get correct results.
  1066.  
  1067. 5.2) Q: Why is CopyBits still too slow? 
  1068.  
  1069. A: Because there is always some overhead involved in calling QuickDraw; 
  1070. you have the trap dispatcher, clipping checks, and checking whether the 
  1071. CopyBits call is being recorded in a PICT handle (if you called 
  1072. OpenPicture)
  1073.  
  1074. If you can't live with this, look at 4.8 below, but PLEASE try and make 
  1075. CopyBits work, and retain the CopyBits code in your application, so 
  1076. users with special monitors (accellerator cards, PowerBook color 
  1077. screens, Radius Pivot screens) can still play your game.  (non-game 
  1078. applications don't need more speed than CopyBits can give at its max.  
  1079. Promise!)
  1080.  
  1081. 5.3) Q: What is the fastest way to set one pixel? 
  1082.  
  1083. A: On 68k Macs, NOT SetCPixel()! Assuming you have the correct ForeColor() 
  1084. set, you can set the pen size to (1,0) and call Line (0,1)
  1085.  
  1086. I have heard PaintRect is good for this but requires slightly more code.  
  1087. Using PaintRect eliminates a trap call.
  1088.  
  1089. 5.4) Q: Why do pictures I record suddenly draw as empty space or not 
  1090. draw at all?
  1091.  
  1092. A: When recording pictures, you have to set the clipping area to exactly 
  1093. the frame of the picture you are recording.  This is because it is 
  1094. initally set at -32768,32727 in both directions, and offsetting the 
  1095. picture even one pixel when drawing it will result in the region 
  1096. wrapping around and becoming empty.
  1097.  
  1098. When recording pictures, do this: 
  1099.  
  1100. *code*
  1101. PicHandle h = OpenPicture ( & theRect ) ;
  1102. ClipRect ( & theRect ) ;
  1103.         /* draw the picture */
  1104. ClosePicture ( ) ;
  1105. *end*
  1106.  
  1107. 5.5) Q: Where can I find the format of picture files and 
  1108. resources? 
  1109.  
  1110. A: The format of a picture resource version 1 is defined in a technical 
  1111. note.  This format is obsolete.
  1112.  
  1113. The format of a picture resource version 2 is defined in Old Inside Mac 
  1114. vol V, with addenda in Old Inside Mac vol VI.
  1115.  
  1116. Some things happen with QuickTime compressed pictures; try the Inside 
  1117. Mac: QuickTime book or turn to Inside Mac: Imaging with QuickDraw which 
  1118. is the definite reference on QuickDraw.
  1119.  
  1120. The format of a picture file is the same as that of a picture resource 
  1121. with 512 added 0 bytes in front.
  1122.  
  1123. 5.6) Q: GWorlds? 
  1124.  
  1125. A: What about them? They're great.  Look them up in IM: Imaging With 
  1126. QuickDraw.  Don't forget to SetGWorld back to what it was before calling 
  1127. WaitNextEvent.
  1128.  
  1129. 5.7) Q: How do I find the current depth of the screen? 
  1130.  
  1131. A: My question to you is: What screen? Many macs have more than one 
  1132. screen attached.  You can use GetDeviceList and walk the devices to find 
  1133. the screen you're looking for (use TestDeviceAttribute to see whether 
  1134. it's a screen) or you can call GetMaxDevice() to find the deepest device 
  1135. your window intersects.
  1136.  
  1137. Once you have the device handle, finding the depth is just a 
  1138. matter of looking at the gdPMap pixMapHandle, and dereference it 
  1139. to the pmSize field. Done. 
  1140.  
  1141. 5.8) Q: Why is it a bad idea to draw directly to screen? 
  1142.  
  1143. A: Because of several reasons: 
  1144.  
  1145. - You will be incompatible with future display hardware. 
  1146.  
  1147. - You will be incompatible with some present-day display 
  1148. hardware, such as Radius Pivots and PowerBook color screens. 
  1149.  
  1150. - You have to think about a lot of things; testing it all on 
  1151. your own machine is not possible and the chances of crashing are 
  1152. great. 
  1153.  
  1154. - You will be incompatible with future hardware where devices 
  1155. may live in some unaccessible I/O space. 
  1156.  
  1157. 5.9) Q: But I really need to do it. I can't make my animation 
  1158. into a QuickTime movie, and CopyBits is too slow, even when 
  1159. syncing to the screen retrace. 
  1160.  
  1161. A: You have to prepare yourself, and ask these questions: 
  1162.  
  1163. - Do I want to support all screens, or just 8-bit devices?
  1164.  
  1165. - Do I have a few weeks of free time to make it work? 
  1166.  
  1167. - Do I want to get nasty mail when I break on some hardware and 
  1168.    have to rev the application - even if I may not be able to get 
  1169.    ahold of the hardware that makes it break? 
  1170.  
  1171. If all you're doing is rendering an image pixel-by-pixel or 
  1172. line-by-line, maybe you can draw directly into an offscreen 
  1173. pixMap/GWorld and then CopyBits the entire GWorld to screen? 
  1174. That will be more compatible, especially if you use the 
  1175. keepLocal flag when creating the GWorld. 
  1176.  
  1177. 5.10) Q: Okay, so how do I get the base address of the screen? 
  1178.  
  1179. A: "The" screen? Which screen? There may be several. The base 
  1180. address may be on an accellerated screen card. There may be more 
  1181. than one screen covering the same desktop area. 
  1182.  
  1183. Due to unfortunate circumstances, there is a bug in 
  1184. GetPixBaseAddr() that causes it to return incorrect results for 
  1185. early versions of System 7. Instead, get the baseAddr directly 
  1186. from the gdPMap handle of the GDHandle for the screen you draw 
  1187. to. This address may need switching to 32bit mode to be valid. 
  1188.  
  1189. 5.11) Q: Quit stalling and give me code! 
  1190.  
  1191. A: Okay, but I'll let you sweat over Inside Mac to figure out 
  1192. what it does. All of it is important; believe me! To make this 
  1193. code run faster, a lot of the things it does can be done once 
  1194. before starting to draw. 
  1195.  
  1196. Make sure that you have a window that covers the area where you 
  1197. are drawing, so other windows will not be overdrawn. Also make 
  1198. sure that you do not do direct-to-screen-drawing while you are 
  1199. in the background. 
  1200.  
  1201. *code*
  1202. /* This is presently untested code */
  1203. /* Value is dependent on what depth the screen has */
  1204. /* This code doesn't work on non-color-quickdraw Macs (i e the MacClassic) */
  1205. /* "where" is in GLOBAL coordinates */
  1206. void
  1207. SetPixel ( Point where , unsigned long value ) {
  1208.  
  1209. Rect r ;
  1210. GDHandle theGD ;
  1211. char * ptr ;
  1212. long rowBytes ;
  1213. short bitsPerPixel ;
  1214. PixMapHandle pmh ;
  1215. Boolean oldMode ;
  1216.  
  1217.         r . left = where . h ;
  1218.         r . top = where . v ;
  1219.         r . right = r . left + 1 ;
  1220.         r . bottom = r . top + 1 ;
  1221.         theGD = GetMaxDevice ( & r ) ;
  1222.         if ( theGD ) {
  1223.                 where . v -= ( * theGD ) -> gdRect . left ;
  1224.                 where . h -= ( * theGD ) -> gdRect . top ;
  1225.                 pmh = ( * theGD ) -> gdPMap ;
  1226.                 rowBytes = ( ( * pmh ) -> rowBytes ) & 0x3fff ;
  1227.                 ptr = ( char * ) ( * pmh ) -> baseAddr ;
  1228.                 bitsPerPixel = ( * pmh ) -> pixelSize ;
  1229.                 oldMode = true32b ;
  1230.                 ptr += where . v * rowBytes ;
  1231.                 SwapMMUMode ( & oldMode ) ;
  1232.                 switch ( bitsPerPixel ) {
  1233.                 case 1 :
  1234.                         if ( value & 1 ) { 
  1235.                                 ptr [ where . h >> 3 ] |= ( 128 >> ( where . h & 7 ) ) ;
  1236.                         } else {
  1237.                                 ptr [ where . h >> 3 ] &= ~( 128 >> ( where . h & 7 ) ) ;
  1238.                         }
  1239.                         break ;
  1240.                 case 2 :
  1241.                         ptr [ where . h >> 2 ] &= ( 192 >> 2 * ( where . h & 3 ) ) ;
  1242.                         ptr [ where . h >> 2 ] |= ( value & 3 ) << 2 * ( 3 - ( where . h & 3 ) ) ;
  1243.                         break ;
  1244.                 case 4 :
  1245.                         ptr [ where . h >> 1 ] &= ( where . h & 1 ) ? 0xf : 0xf0 ;
  1246.                         ptr [ where . h >> 1 ] |= ( value & 15 ) << 4 * ( 1 - ( where . h & 1 ) ) ;
  1247.                         break ;
  1248.                 case 8 :
  1249.                         ptr [ where . h ] = value ;
  1250.                         break ;
  1251.                 case 16 :
  1252.                         ( ( unsigned short * ) ptr ) [ where . h ] = value ;
  1253.                         break ;
  1254.                 case 32 :
  1255.                         ( ( unsigned long * ) ptr ) [ where . h ] = value ;
  1256.                         break ;
  1257.                 default :
  1258.                         abort ( ) ; /* Should never get here */
  1259.                 }
  1260.                 SwapMMUMode ( & oldMode ) ;
  1261.         }
  1262. }
  1263. *end*
  1264.  
  1265. *6* Text
  1266.  
  1267. 6.1) Q: How do I get TextEdit to display more than 32k of text?
  1268.  
  1269. A: You don't.  Truly, it's not worth it.  There's a call-for-call 
  1270. TextEdit replacement called TE32k which does > 32k text, and is 
  1271. available from any recent Info-Mac mirror.  It doesn't do styled text, 
  1272. though.
  1273.  
  1274. 6.2) Q: How do I get TextEdit to display more than 32k of __styled__ 
  1275. text *and* embedded objects in the text (such as pictures)?
  1276.  
  1277. WASTE, available at ftp://ghost.dsi.unimi.it/pub2/papers/piovanel, is a 
  1278. vast improvement over TextEdit.  Version 1.0 does >32k styled text 
  1279. retains compatibility with the TextEdit style scrap (which is used to 
  1280. store styled text in files such as SimpleText's, as well as in the 
  1281. clipboard), includes source code and is freeware.  Really worth the 
  1282. download.  Version 1.1 adds embedded objects within the text, such as 
  1283. pictures, intelligent cut-and-paste, built-in Drag Manager support, 
  1284. built-in Undo support.  1.1 is currently in alpha, but seems to be very 
  1285. stable.
  1286.  
  1287. 6.3) Q: I'm too back-asswards to use WASTE 1.1.  How do I include 
  1288. pictures in text using TextEdit?
  1289.  
  1290. A: There's no really easy way (such as a TEAddPict() call), and it will 
  1291. be a nasty looking kludge if you do get it working, but if you can live 
  1292. with that, here's how to do it.  I do recommend that you take a look 
  1293. at Q 6.2, above.
  1294.  
  1295. Write an algorithm to get the position of a special marker character 
  1296. [Teach/SimpleText uses option-space] or text attribute that the user 
  1297. will insert wherever he wants a picture.  Pass this position to a 
  1298. function similar to the one below.
  1299.  
  1300. *code* 
  1301. /*
  1302.         TEDrawPicture
  1303.         Draw a picture within TextEdit's text.
  1304.         
  1305.         input:
  1306.                 pos - the position of the special character in the text where the user 
  1307.                                 wants a picture.
  1308.                 r       - size of picture
  1309.         
  1310.         output:
  1311.                 r       - frame in which picture was drawn
  1312. */
  1313.  
  1314. void TEDrawPicture(short pos,PicHandle pic,Rect &r,TEHandle theTE)
  1315. {
  1316.         Point   bottomLeft;  //I think TT/ST uses topleft
  1317.         
  1318.         bottomLeft=TEGetPoint(pos,theTE);
  1319.         
  1320.         r.right=bottomLeft.h+(r.right-r.left);
  1321.         r.top=bottomLeft.v-(r.bottom-r.top);
  1322.         r.left=bottomLeft.h;
  1323.         r.bottom=bottomLeft.v;
  1324.         
  1325.         DrawPicture(pic,&r);
  1326. }
  1327.  
  1328. *end*
  1329.  
  1330. I'll leave selection and hiliting as an exercise for the reader (don't 
  1331. ya love it when people say that?).
  1332.  
  1333. Thereotically, it should be possible to kludge up TextEdit to the point 
  1334. where it would treat pictures as if they were actually letters (rather big 
  1335. letters, but letters just the same).  That's what the width and word break 
  1336. hooks are for, after all.  However, this would be a lot of Work, and I've 
  1337. never seen it done.  One is lead to believe that it's less work to create 
  1338. an improved version of TextEdit from the ground up with picture support.  
  1339. WASTE 1.1, in fact, does this rather nicely.
  1340.  
  1341. 6.4) Q: I have all this money, and I want to get rid of it. How do I
  1342. edit more than 32k of styled text now?
  1343.  
  1344. A: There are at least three solutions.
  1345.  
  1346. 1) The Galaxy application framework comes with a styled text editting
  1347. engine which does more than 32k of text. It also happens to support
  1348. cross-platform application development. Pricing starts at $10000.
  1349. <galaxy@visix.com>
  1350.  
  1351. 2) DataPak is selling a cross-platform library called "PAIGE".  It is 
  1352. written to be customizable to any extent, and you can do _anything_ in 
  1353. it (want quicktime movies that play and flow with the text while 
  1354. editting? One page of code; there is also sample code.) 
  1355. Available for Mac, Windows & Never Trusted and Power Mac.  Pricing at 
  1356. $5000 ($25000 for source code) - it might be cheaper if you talk to 
  1357. them.  Customer support is reputed to be "lousy".
  1358.  
  1359. 3) Or you could always pay Marco P. to finish up WASTE 1.1 with it's 
  1360. embedded objects implementation (want quicktime movies that play and 
  1361. flow with the text?)
  1362.  
  1363.  
  1364. 6.5) Q: How do I convert from a string to a floating point type?
  1365.  
  1366. A: Once you've got an Str255, you want to call the routine 
  1367. StringToExtended to change the number into type extended80, which is the 
  1368. 80-bit floating point type.  The nice thing about StringToExtended is 
  1369. that it even works in funky foreign language scripts like Chinese.  To 
  1370. use the routine, you must pass it not only the Str255 that you want 
  1371. converted, but also the results of the StringToFormatRec routine and the 
  1372. GetIntlResourceTable routine.  The documentation is generally difficult, 
  1373. so I'll describe the parameters and give you a code example below.  
  1374. Here's what you pass to StringToExtended:
  1375.  
  1376. - source:
  1377. Obviously the string representation of the number.
  1378.  
  1379. - myFormatRec:
  1380. This is simply the format that you expect the number to be.  For 
  1381. example, if you wanted a positive integer with up to 3 decimal places, 
  1382. you would want the format to be "###".  (The "#" symbol means a non-zero 
  1383. filled digit, whereas a "0" would mean zero filled.) If you wanted an 
  1384. floating point exponential notation with up to 2 digit integer portion, 
  1385. exactly 2 digit decimal portion, and exactly 1 digit after the "E", your 
  1386. format would be "##.00E+0".  (Actually, in Canada, you folks might use a 
  1387. "," instead of a "." for the decimal point; if you do, then you would 
  1388. put the locally correct symbol in there.) In a format string, you can 
  1389. put the format for a positive value, a negative value, and 0 seperated 
  1390. by semicolons (e.g.  "##.00E+0;-##.00E+0;0.00E+0").
  1391.  
  1392. But myFormatRec is not the format string itself, but is an internal 
  1393. format that you get from calling StringToFormatRec.  This is so you can 
  1394. store the format returned to you by StringToFormatRec and use it on 
  1395. different international systems.  There is a nice editor for ResEdit for 
  1396. 'FMAT' resources that lets you type the format string and will call 
  1397. StringToFormatRec for you and create an 'FMAT' resource out of the 
  1398. result.  Then you can load the 'FMAT' at run time and pass it to 
  1399. myFormatRec.
  1400.  
  1401. - partsTable:
  1402. The number parts table from the 'itl4' resource.  If you are using 
  1403. System 7 or later, you call GetIntlResourceTable, asking it for the 
  1404. number parts table.  You don't need to worry about HLock'ing itlHandle 
  1405. because StringToExtended doesn't move memory; just don't do anything 
  1406. between your call to GetIntlResourceTable and the StringToFormatRec 
  1407. routine.  If you are using System 6, you need to perform the 
  1408. GetIntlResourceTable by hand.  It's a few lines of code; left as an 
  1409. exercise to the reader.
  1410.  
  1411. - x:
  1412. The extended number to put the thing into.
  1413.  
  1414. So, let's say you expect the user to enter a string containing up to 5 
  1415. digits in the integer with a thousand marker between the 3rd and fourth 
  1416. digit, exactly two digits after the decimal, put it in parenthesis if 
  1417. it's negative, and have it just be "0.00" if it's 0.  (I will use "." 
  1418. for the decimal and "," for the thousand marker.  Here's the C code 
  1419. (passing in the source string):
  1420.  
  1421. *code*
  1422. Handle itlHandle;               /* The 'itl4' resource handle */
  1423. long offset, length;            /* Offset-length of parts table */
  1424. NumFormatStringRec myFormatRec; /* Canonical format record */
  1425. extended80 x;                   /* The number to put it into */
  1426.  
  1427. GetIntlResourceTable (smCurrentScript, smNumberPartsTable,
  1428.                       &itlHandle, &offset, &length);
  1429. StringToFormatRec ("\p##,###.00;(##,###.00);0.00",
  1430.                    (NumberParts *)(*itlHandle + offset),
  1431.                    &myFormatRec);
  1432. StringToExtended (source, &myFormatRec,
  1433.                   (NumberParts *)(*itlHandle + offset),
  1434.                   &x);
  1435. *end*
  1436.  
  1437. If you saved a format record in a resource using the 'FMAT' editor 
  1438. (which is really the preferred way to do it), you would change the code 
  1439. to look like this:
  1440.  
  1441. *code*
  1442. Handle itlHandle;                 /* The 'itl4' resource handle */
  1443. long offset, length;              /* Offset-length of parts table */
  1444. NumFormatStringRec **myFormatRec; /* Canonical format resource */
  1445. extended80 x;                     /* The number to put it into */
  1446.  
  1447. myFormatRec = (NumFormatStringRec **)GetResource('FMAT', MY_FMAT);
  1448. GetIntlResourceTable (smCurrentScript, smNumberPartsTable,
  1449.                       &itlHandle, &offset, &length);
  1450. StringToExtended (source, *myFormatRec,
  1451.                   (NumberParts *)(*itlHandle + offset),
  1452.                   &x);
  1453. *end*
  1454.  
  1455. The StringToExtended routines will return a result that will tell you if 
  1456. there are any parsing errors.  Error checking is also left as an 
  1457. exercise to the reader.
  1458.  
  1459. Of course, the reverse of the process (using ExtendedToString) works 
  1460. very much the same way, passing the same sorts of parameters.
  1461.  
  1462. *7* Communications and Networking
  1463.  
  1464. 7.1) Q: How do I get at the serial ports? 
  1465.  
  1466. A: You call OpenDriver for the names "\p.AOut" and "\p.AIn" to get at 
  1467. the modem port, and "\p.BOut" and "\p.BIn" for the printer port.  The 
  1468. function RAMSDOpen was designed for the original Mac with 128 kB of 
  1469. memory and 64 kB of ROM, and has been extinct for several years.
  1470.  
  1471. However, many users use their serial ports for MIDI, LocalTalk, graphic 
  1472. tablets, or what have you and have installed an additional serial port 
  1473. card to get more ports.  What you SHOULD do as a good application is to 
  1474. use the Comm Toolbox Resource Manager to search for serial resources; 
  1475. this requires that the Comms Toolbox is present (true on earlier System 
  1476. 6 with an INIT, on later System 6 and System 7 always, as well as on 
  1477. A/UX) and that you have initialized the comms resource manager.  The 
  1478. exact code follows (adapted from Inside Mac Comms Toolbox):
  1479.  
  1480. *code*
  1481. #include "CommResources.h"
  1482. OSErr
  1483. FindPorts(
  1484.         Handle *portOutNames,
  1485.         Handle *portInNames,
  1486.         Handle *names,
  1487.         Handle *iconHandles)
  1488. {
  1489.         OSErr ret = noErr;
  1490.         short old = 0;
  1491.         CRMRec theCRMRec, *found;
  1492.         CRMSerialRecord *serial;
  1493.  
  1494.         * portOutNames = NewHandle ( 0L ) ;
  1495.         * portInNames = NewHandle ( 0L ) ;
  1496.         * names = NewHandle ( 0L ) ;
  1497.         * iconHandles = NewHandle ( 0L ) ;
  1498.         while ( ! ret ) {
  1499.                 theCRMRec . crmDeviceType = crmSerialDevice ;
  1500.                 theCRMRec . crmDeviceID = old ;
  1501.                 found = ( CRMRec * ) CRMSearch ( ( QElementPtr ) & theCRMRec ) ;
  1502.                 if ( found ) {
  1503.                         serial = ( CRMSerialRecord * ) found -> crmAttributes ;
  1504.                         old = found -> crmDeviceID ;
  1505.                         PtrAndHand ( & serial -> outputDriverName , * portOutNames ,
  1506.                                 sizeof ( serial -> outputDriverName ) ) ;
  1507.                         PtrAndHand ( & serial -> inputDriverName , * portInNames ,
  1508.                                 sizeof ( serial -> inputDriverName ) ) ;
  1509.                         PtrAndHand ( & serial -> name , * names , 
  1510.                                 sizeof ( serial -> name ) ) ;
  1511.                         PtrAndHand ( & serial -> deviceIcon , * iconHandles ,
  1512.                                 sizeof ( serial -> deviceIcon ) ) ;
  1513.                 } else {
  1514.                         break ;
  1515.                 }
  1516.         }
  1517.         return err ;
  1518. }
  1519. *end*
  1520.  
  1521. This will create four handles with the driver names, device names and 
  1522. driver icon handles for all of the available serial devices.  Then let 
  1523. the user choose with a pop-up menu or scrolling list, and save the 
  1524. choice in your settings file.
  1525.  
  1526. You can use OpenDriver, SetReset, SetHShake, SetSetBuf, SerGetBuf and 
  1527. the other Serial Manager functions on these drivers.  To write to the 
  1528. serial port, use FSWrite for synchronous writes that wait until all is 
  1529. written, or PBWrite asynchronously for queuing up data that is supposed 
  1530. to go out but you don't want to wait for it.  At least once each time 
  1531. through your event loop, you should call SerGetBuf on the in driver 
  1532. reference number you got from OpenDriver, and call FSRead for that many 
  1533. bytes - neither more nor less.
  1534.  
  1535. If you are REALLY interested in doing the right thing, you will use the 
  1536. Communications Toolbox Connection Manager instead; this will give you 
  1537. access to modems, direct lines, and networks of various kinds using the 
  1538. same API! Great for stuff like BBSes that may be on a network as well 
  1539. etc.  The Comms Toolbox also priovides modularized terminal emulation 
  1540. and file transfer tools, although the Apple-suplied VT102 tool is pretty 
  1541. lame, as is the VT102 mode of the VT320 tool.  And it seems as though 
  1542. it was designed by people who'd never used a Mac before... more in the 
  1543. Unix style, right down to the lack of documentation and "magicCookie."
  1544.  
  1545. 7.2) Q: Where is a Berkley sockets library for the Mac? 
  1546.  
  1547. A: There are some problems with that.  MacTCP, the Mac Toolbox 
  1548. implementation of TCP/IP, doesn't have an API that looks at all like 
  1549. Berkley sockets.  For instance, there is ONE paramater-block call to do 
  1550. a combined listen()/accept()/bind() - sort of.  I have heard that there 
  1551. may be a socket library available by ftp from MIT but haven't seen it 
  1552. myself.
  1553.  
  1554. There is also a pretty good C++ TCP implementation called GUSI which is 
  1555. easily handled, and it also is callable from C using the Berkley socket 
  1556. API.  Apart from TCP, it also handles "standard" Mac network protocols 
  1557. such as ADSP.  The big disadvantage is that it is currently only 
  1558. implemented for MPW.  The ftp site is nic.switch.ch, 
  1559. software/mac/src/mpw_c.
  1560.  
  1561. I can also recommend the Communications Toolbox; for the price of using 
  1562. an API that is a bigger pain in the ass than configuring Windoze to use 
  1563. a new peripheral device, you get the benefit of being able to use any 
  1564. kind of connection (TCP tools are available).
  1565.  
  1566. Instead of the Comm Toolbox, one might use Apple's much improved Open 
  1567. Transport architecture.  Preliminary docs are available for ftp at 
  1568. seeding.apple.com.  Apple's new networking products team seems to have 
  1569. it's head screwed on tight.  A refreshing change.
  1570.  
  1571. Novell and Wollogong offer commercial socket-like libraries. 
  1572.  
  1573. 7.3) Q: Where do I find MacTCP? 
  1574.  
  1575. A: You can buy the MacTCP developers kit from APDA.  It is also 
  1576. available on E T O, and if you want saner headers than those, try ftp to 
  1577. seeding.apple.com.  MacTCP (the control panel) is included with System 
  1578. 7.5 and above.
  1579.  
  1580. 7.4) Q: I'm trying to write to the serial port.  It works fine on the 
  1581. following Machines, Quadra700, IIFX, Powerbook 170, Quadra 840av, but 
  1582. freezes on the Duo 230 and 280c.
  1583.  
  1584. A: You need to call SerHShake.  Otherwise you get screwed on some 
  1585. machines without a hardware handshaking cable because the port default to 
  1586. hardware handshaking.
  1587.  
  1588. *8* IAC
  1589.  
  1590. 8.1) Q: What are AppleEvents? 
  1591.  
  1592. A: AppleEvents are a level-5 network protocol.  If you are not familiar 
  1593. with the ISO network stack, this means it's a way of structuring sessions 
  1594. between network entities (programs) that is not dependent on the 
  1595. underlying protocol (such as PPC or TCP/IP) Despite being a network 
  1596. protocol, they can be very useful on Macs that are not on a network.  In 
  1597. short, they provide applications with a comprehensive way to send 
  1598. arbitrary structured data to other applications (or themselves) which 
  1599. receive the events through their main event loop.
  1600.  
  1601. The AppleEvent Object Model is a way of looking at applications and the 
  1602. data they contain, and also a level-6 network protocol.  You _can_ send 
  1603. AppleEvent Object Model data through AppleEvents (and the standard 
  1604. AppleEvents defined in the AppleEvent Registry use it) but you don't have 
  1605. to - unless you want to talk with other applications, of course, then the 
  1606. AEOM is a lingua franca.
  1607.  
  1608. 8.2) Q: What are the four required AppleEvents? 
  1609.  
  1610. A: There are four events your application really must implement if you 
  1611. want to sell it: the kCoreEventClass class, kAEOpenApplication, 
  1612. kAEQuitApplication, kAEOpenDocuments and kAEPrintDocuments events IDs.  
  1613. When you support these events (or any AppleEvents) you will not get 
  1614. startup info through GetAppParams() anymore, unless you run under System 
  1615. 6 of course.  The kAEOpenApplication event will be sent to you when the 
  1616. user double-clicks your app and it's not started yet.  When receiving it, 
  1617. you can put up a new untitled window.
  1618.  
  1619. kAEOpenDocuments is sent when the user double-clicks your apps documents.  
  1620. Note that if the first AppleEvent you receive is a kAEOpenDocuments 
  1621. event, the user started your app by double-clicking its documents.
  1622.  
  1623. kAEPrintDocuments is sent when the user selects your documents and 
  1624. chooses "Print" in the Finder menu.  If this is the first AppleEvent you 
  1625. receive, you should print the documents and then quit the application 
  1626. again; if you received a kAEOpenApplication or kAEOpenDocuments event 
  1627. before this, you should just print the documents and close them when 
  1628. you're done.
  1629.  
  1630. kAEQuitApplication is sent to you when the user chooses "Shutdown" or 
  1631. "Restart" from the Apple Menu.  You should ask the user whether he wants 
  1632. to save any unsaved changed documents, and then quit unless the user 
  1633. presses Cancel.
  1634.  
  1635. Interestingly enough, you can use these four AppleEvents to send even to 
  1636. non-AE-aware applications, and the system will translate these events 
  1637. into fake menu selections for you.
  1638.  
  1639. A good way of shutting down the Finder is to send it a Quit AppleEvent.  
  1640. You should send a Quit AppleEvent to File Sharing Extension before you 
  1641. shut down the Finder, though; the FSE is found by looking for a process 
  1642. with the creator 'hhgg'.
  1643.  
  1644. 8.3) Q: Are there any limits or tradeoffs with AppleEvents? 
  1645.  
  1646. A: As always, more power means more responsibility. 
  1647.  
  1648. AppleEvents sent to applications on other Macs require authentification 
  1649. the first time they are sent.  If the remote Mac allows Guests to link to 
  1650. programs, the INIT AutoGuest 2.0 might help (or the code solution that 
  1651. comes with it and you can build into your application)
  1652.  
  1653. In the first version of the AppleEvent manager, there was a total 64K 
  1654. limit on the size of data and overhead.  This limit has been lifted with 
  1655. the version of the AppleEvent manager that comes with AppleScript.
  1656.  
  1657. AppleEvents require a lot of memory copying and handle resizing in their 
  1658. construction; this means that large AppleEvents may be slow in 
  1659. construction, especially when compared to a pure PPC Toolbox or 
  1660. ADSP/ASDSP link.
  1661.  
  1662. You should use your own application signature as event class for 
  1663. AppleEvents you make up, in order not to collide with anybody else.  
  1664. Other than that, you are free to make your own events for your own needs, 
  1665. though supporting the required events and at least a subset of the Core 
  1666. event suite will buy you a lot of functinality from within AppleScript.  
  1667. Especially important are the Get Current Selection and Set Current 
  1668. Selection events (which are really Get/Set Data on the contents of the 
  1669. current selection of the application)
  1670.  
  1671. The signature for your application SHOULD be registered with DTS to avoid 
  1672. conflicts; this is done through e-mail to DEVSUPPORT@AppleLink.Apple.Com 
  1673. and the form you use is located on the developer CDs and found on 
  1674. ftp.apple.com.
  1675.  
  1676. 8.4) Q: How do AppleEvents interface with AppleScript? 
  1677.  
  1678. A: AppleEvents are the meat and potatoes of AppleScript.  If you support 
  1679. the AppleEvent Object Model from within your application, users can 
  1680. control you through AppleScript.
  1681.  
  1682. The first thing you should do is get ahold of Inside Mac: 
  1683. Interapplication Communication, and a copy of the AppleEvents Registry.  
  1684. The former tells you all you ever need to know about AppleEvents, while 
  1685. the latter is paramount for implementing the right standard events.  If 
  1686. everybody use the standard events, dynamic data interchange between any 
  1687. applications will become sweet reality!
  1688.  
  1689. Then there is the 'aete' resource which lets you put names on the events 
  1690. you support, so that users can "Open Terminology" on your application 
  1691. from within the Apple Script Editor and use the proper AppleScript 
  1692. commands in their scripts.  The format of an aete resource is defined in 
  1693. Inside Macintosh: Interapplication Communication.
  1694.  
  1695. 8.5) Q: Can I compile and run scripts from within my application?
  1696.  
  1697. A: Yes, this is very simple.  There are toolbox calls for reading 
  1698. scripts, compiling scripts, and executing scripts.  (OSACompile, 
  1699. OSAExecute) These are all documented in Inside Mac: Interapplication 
  1700. Communication.
  1701.  
  1702. 8.6) Q: Is this a good way of getting a macro language almost 
  1703. for free? 
  1704.  
  1705. A: "Good" is an understatement.  Just let users write scripts, load them 
  1706. into menu items and go.  Total systems integration in under a week, 
  1707. including adding support for the AEOM to your application.
  1708.  
  1709. There is source code for an application called "MenuScripter" on the 
  1710. developer CD which shows you how to do an application with all of the 
  1711. menus being AppleScript scripts.
  1712.  
  1713. 8.7) Q: Why do I get error -903 (noPortErr) when I try to send an Apple 
  1714. Event?
  1715.  
  1716. A: Make sure the isHighLevelEventAware flag in your application's SIZE 
  1717. resource is set.  The AE Manager won't allow you to send events if you're 
  1718. not able to receive them.
  1719.  
  1720. *9* Standalone Code and Linking
  1721.  
  1722. 9.1) Q: How do I do code resources/extensions/external functions, much 
  1723. like HyperCard XCMDs only for my app/extension?
  1724.  
  1725. A: Here is what you need to do:
  1726.  
  1727. Define a storage location for the plug-ins.  such as, for an application 
  1728. called Foo, a folder called "Foo Pouch/ PlugIns/ Modules/ Tools/ Etc", 
  1729. which your installer creates, and which you search for in the same 
  1730. folder as your application, the preferences folder, and the System 
  1731. Folder (for System 6 (no preferences)) the name of the pouch folder 
  1732. should be in a 'STR ' or 'STR#' resource for easy internationalization.
  1733.  
  1734. Next, define a resource type to hold your plug-in exectuable code.  You 
  1735. should allow any resID number, since some development systems have 
  1736. restrictions on which id numbers can be used for multi-segment code 
  1737. resources.
  1738.  
  1739. Decide whether you will allow multiple code resources per file.  For 
  1740. example, Photoshop lets you bundle an import resource, an export 
  1741. resource, and a filter into the same file, each is its own resource 
  1742. type.  It uses the resource name to tell the user, so each has its own 
  1743. name.
  1744.  
  1745. Decide on the user interface to plug-ins.  Commonly, at program 
  1746. start-up, you scan the pouch and collect all the files of the correct 
  1747. types.  Then you scan for appropriate code resources, then put the names 
  1748. of the resources in the menus.  You can also use the file names, or run 
  1749. the code resources and ask them for the correct name.
  1750.  
  1751. Decide on the calling convention.  MPW likes to pass parameters as 
  1752. longs, and pascal development systems usually can't generate C 
  1753. interfaces, so your best bet is to have the entry point of your code 
  1754. resource be something like:
  1755.  
  1756. extern pascal long PlugIn(long selector, CallbackPtr callback,
  1757.         long param1, long param2, long param3, long refcon);
  1758.  
  1759. where params 1 through 3 will have specific meanings depending upon
  1760. which function selector is asking to be performed.
  1761.  
  1762. CallbackPtr is something like this:
  1763. typedef struct CallbackRec{
  1764.         DrawFunc        erase;
  1765.         DrawFunc        paint;
  1766. }CallbackRec, *CallbackPtr;
  1767.  
  1768. where DrawFunc is something like:
  1769. typedef pascal void (*DrawFunc)(Rect *);
  1770.  
  1771. This is the place where you define services that your application will 
  1772. perform when asked to by the code resource of the plug-in.
  1773.  
  1774. You'll need to define a bunch of selectors for what you want the plug-in
  1775. to do.
  1776.  
  1777. You should definately give the plug-in an Init selector, and a dispose 
  1778. selector, and have Init return an error or a refcon, which will be 
  1779. passed back to the plug-in on each call, so the plug-in can have some 
  1780. persistent storage.  You should definately set the CurResFile to the 
  1781. plug-in's file while it is running, so it can easily get at any 
  1782. resources it needs.
  1783.  
  1784. The Init selector should pass the interface version in param1 and the 
  1785. program version in param2, so that the plug-in can cope with different 
  1786. versions of your program.
  1787.  
  1788. The actual call to the plug-in looks like:
  1789.  
  1790. *code*
  1791.     h = GetResource('PLUG', 1);
  1792.     HLock(h);
  1793.     xh = StripAddress(h);
  1794.     ((PlugInFunc) *xh)(kInit, callbacks, kInterfaceVer1, kProgVer1, 0, 0);
  1795.     HUnlock(h);
  1796. *end*
  1797.  
  1798. The StripAddress is important; if your app is running in 24bit mode, the 
  1799. resource handle may contain tag bits and you don't want strange things 
  1800. to happen if the code resource switches into 32bit mode (which QuickDraw 
  1801. may do, incidentally)
  1802.  
  1803. Exactly how you structure your calling conventions is up to you; there 
  1804. is no accepted standard (except for HyperCard XCMDs, but that is 
  1805. probably overkill for you).
  1806.  
  1807. *10* Compatibility
  1808.  
  1809. 10.1) Q: I see all these people call Gestalt without first 
  1810. checking whether it's implemented. Isn't that bad? 
  1811.  
  1812. A: No; Gestalt and a few other traps (the HXxx file manager 
  1813. traps, and FindFolder) are implemented using glue so they do the 
  1814. right thing even if the trap is not implemented. 
  1815.  
  1816. If you want to get rid of the glue, you can #define 
  1817. SystemSevenOrLater (and, using Think C/C++, re-pre-compile 
  1818. MacHeaders) However, then you will be responsible for checking 
  1819. for these features before you use them. 
  1820.  
  1821. 10.2) Q: What more functions are implemented in glue? 
  1822.  
  1823. A: Wake Up and Smell the Glue!
  1824.  
  1825. How often have you wished you could use that cool new ToolBox 
  1826. call, but didn't want to make your application System 7 
  1827. dependent? Well, it might be that you *could* in fact have used 
  1828. the call. Several traps are implemented in glue, that is, much 
  1829. of their functionality is linked into your application and thus 
  1830. available even if you are running under an old System. 
  1831.  
  1832. This list applies to MPW 3.2 and should also be valid for the 
  1833. current version of Think C. If you find any inaccuracies, please 
  1834. report them to me. (neeri@iis.ee.ethz.ch) 
  1835.  
  1836. FSOpen: Tries first OpenDF, then Open. 
  1837.  
  1838. HOpenResFile: Full functionality emulated if trap not available 
  1839.  
  1840. HCreateResFile: Full functionality emulated if trap not 
  1841. available 
  1842.  
  1843. FindFolder: Under System 6, understands the following values for 
  1844. folderType and returns the System Folder for all of them: 
  1845.  
  1846. kAppleMenuFolderType 
  1847.  
  1848. kControlPanelFolderType 
  1849.  
  1850. kExtensionFolderType 
  1851.  
  1852. kPreferencesFolderType 
  1853.  
  1854. kPrintMonitorDocsFolderType 
  1855.  
  1856. kStartupFolderType 
  1857.  
  1858. kSystemFolderType 
  1859.  
  1860. kTemporaryFolderType 
  1861.  
  1862. SysEnvirons: Full functionality emulated if trap not available 
  1863.  
  1864. NewGestalt: Returns an error if not implemented 
  1865.  
  1866. ReplaceGestalt: Returns an error if not implemented 
  1867.  
  1868. Gestalt: The following selectors are always implemented: 
  1869.  
  1870. vers    mach    sysv    proc    fpu     
  1871.  
  1872. qd      kbd     atlk    ram     lram    
  1873.  
  1874. 10.3) Q: I have to support System 6, don't I? 
  1875.  
  1876. A: It would be foolish to lock yourself out of the many benefits 
  1877. the System 7 API provides for software that you start to write 
  1878. now. Some of the System 6 and older things (likely SFGetFile and 
  1879. wdRefNums among others) will be phased out of the interfaces and 
  1880. lose support; especially on future platforms. 
  1881.  
  1882. The installed base of System 7 is larger than that of System 6; 
  1883. this is not surprising because Apple has been shipping System 7 
  1884. for several years with all new machines, including the LCII, 
  1885. Classic II, Performas and Color Classic. Another argument is 
  1886. that newer computer owners (having System 7) are much more 
  1887. likely to buy new software than old computer owners who have 
  1888. systems that already do what they want them to. 
  1889.  
  1890. The added work to support both System 6 and System 7 is 
  1891. significant; if you have the time and money you may want to do 
  1892. it, but only supporting System 6 and not System 7 is doomed to 
  1893. fail in the market of today. 
  1894.  
  1895. Some may call this position subjective; I call it business sense 
  1896. based on market demographics. A rule of thumb may be that if you 
  1897. target color machines only, you can just as well demand System 7 
  1898. as well. 
  1899.  
  1900. 10.4) Q: Why does my application work on an SE with accellerator 
  1901. (or a Mac II or Quadra), but not on one without? 
  1902.  
  1903. A: Assuming you're not calling Color QuickDraw (which is not 
  1904. available on accellerated SEs), you most probably have an 
  1905. odd-aligned word access somewhere. 
  1906.  
  1907. The 68000 does not allow words or longwords to be read from odd 
  1908. addresses, while the 68020 and up relaxes this restriction (it 
  1909. still is slower than aligned-word access though) 
  1910.  
  1911. This may or may not crash depending on your compiler: 
  1912.  
  1913. *code*
  1914. struct foo {
  1915.         char c1 ;
  1916.         char c2 ;
  1917.         char c3 ;
  1918.         char c4 ;
  1919.         char c5 ;
  1920. } bar ;
  1921.  
  1922.         long * x = ( long * ) & bar . c2 ;
  1923.         * x = 0x12345678 ; /* X is odd if compiler doesn't pad */
  1924.  
  1925. This WILL crash on an SE/Plus/Classic/PB100:
  1926.  
  1927. char foo [ 10 ] ;
  1928.  
  1929.         long * x = ( long * ) & foo [ 1 ] ;
  1930.         * x = 0x12345678 ;
  1931.  
  1932. *end*
  1933.  
  1934. 10.5) Q: Why does my application work on a IIci and a pre-1995 PowerMac 
  1935. but not on a Quadra?
  1936.  
  1937. A: Two reasons: 
  1938.  
  1939. 1) The Quadras 900 and 950 have special processors that handle the serial 
  1940. ports; if you write directly to the serial chips, you will crash (this 
  1941. goes for the IIfx as well)
  1942.  
  1943. 2) The Quadras have 68040 processors, as have the Centrises.  These 
  1944. processors have separate instruction and data caches (like the 68030) but 
  1945. they are larger (4K each) and unlike the 68030 which is write-through 
  1946. data cached, the 68040 is copy-back data cached.  This means that changes 
  1947. you make to "your code" aren't really changed all the time, since the 
  1948. changes may still be in the data cache and not written to memory when the 
  1949. CPU reads that part of memory into its I-cache.  Even worse; that part 
  1950. might already have been read into the I-cache before you change it in the 
  1951. D-cache, meaning that writing out the D-cache will still not be enough.  
  1952. You need to flush both the caches when writing self-modifying code.
  1953.  
  1954. Self-modifying code includes code that builds its own jump tables and 
  1955. code that decrypts itself and code that "stubs" MDEFs or WDEFs to jump 
  1956. back into the application code.
  1957.  
  1958. You flush the cache using FlushDataCache() which is implemented if 
  1959. Gestalt says you have a 68020 or better processor (or if the _HwDispatch 
  1960. trap is implemented)
  1961.  
  1962. The current PowerMac 68k emulator doesn't have the self-modifying cache 
  1963. problem, but a future faster version will.
  1964.  
  1965. 10.6) Q: Why does my application work on my Quadra but not on my 
  1966. accellerated SE?
  1967.  
  1968. A: You're probably calling Color QuickDraw without first checking if it's 
  1969. available.  The following machines do not have color QuickDraw in ROM nor 
  1970. RAM:
  1971.  
  1972. Mac Plus, Mac SE, Mac Classic, Mac Luggable, PowerBook 100, Outbound
  1973.  
  1974. 10.7) Q: I do check for color quickdraw, but crash nevertheless. 
  1975.  
  1976. A: _Gestalt lies under some versions of System 7; it says that non-color 
  1977. machines HAVE color QuickDraw when you test using the 
  1978. gestaltQuickdrawFeatures selector.
  1979.  
  1980. Instead, check the gestaltQuickdrawVersion selector, if it returns >= 
  1981. gestalt8BitQuickdraw then you can safely use gestaltQuickdrawFeatures, 
  1982. else you only have b/w QuickDraw.
  1983.  
  1984. *11* Optional System Software
  1985.  
  1986.   *11.1* QuickTime
  1987.  
  1988. 11.1.1) Q: I want to write a Amiga QuickTime player and need the 
  1989. CODEC format details. 
  1990.  
  1991. A: Although the structure of QuickTime movies is well documented in 
  1992. Inside Mac: QuickTime, the inner workings of the Apple compression 
  1993. modules is a trade secret that Apple will only license to you at great 
  1994. cost.  Perhaps it's time for a freeware, cross-platform QuickTime codec?
  1995.  
  1996. *12* Third-Party Solutions
  1997.  
  1998. 12.1) Q: What are some royalty-free databases available for the 
  1999. Macintosh?
  2000.  
  2001. A: These are commercial with no run-time licenses:
  2002.  
  2003. - Prograph CPX comes with a database that can do indexes and tables.  
  2004. <sales@prograph.com>
  2005.  
  2006. - C-Index Pro is an engine that comes with source, does tables and indexes 
  2007. in one compound file.  <triosystems@applelink.apple.com>
  2008.  
  2009. - dtF is a relational database library.  <DTF.AMERICA@applelink.apple.com>
  2010.  
  2011. NeoAccess is an object-oriented database, where you can store objects and 
  2012. retrieve by field value; it handles inheritance as well.  Comes as a 
  2013. demo on the CodeWarrior CD with an unlockable archive of the real thing.
  2014.  
  2015. 12.2) Q: I need a robust Client/Server database library.  What do I do?
  2016.  
  2017. A: Get the Macintosh Client/Server Database Development Summary, by Liam 
  2018. Breck.  It covers software applicable to Macintosh (and cross-platform) 
  2019. client/server database development in three categories:
  2020.  
  2021.   + Client application development tools
  2022.   + Data access layers
  2023.   + Database servers
  2024.  
  2025. The eight page (20 Kbytes ASCII text) document includes explanations of the
  2026. three categories and describes over 30 products. Its sources are vendors'
  2027. product literature, industry periodicals, and discussions with users and
  2028. vendors' tech support staff. It is purely informational and contains no
  2029. propaganda, as the author is a neutral party.
  2030.  
  2031. To receive a copy electronically, email a request to: 
  2032. <maccsdb@external.umass.edu>.  Tell 'em the Mac Public Domain 
  2033. Programming FAQ sent you!
  2034.  
  2035. *13* Dessert
  2036.  
  2037. 13.1) Q: Dessert? 
  2038.  
  2039. A: Honey Hill Farms Cookie Jar Frozen Yoghurt or Haagen-Dazs Raspberry & 
  2040. Cream Ice Cream.
  2041.  
  2042. Hokey-Pokey icecream with chocolate sauce and (for those who like their 
  2043. brain food firmer) Almond and Double Chocolate CookieTime cookies!?
  2044.  
  2045. *14* Contributors
  2046.  
  2047. [let me know if I've forgotten you]
  2048.  
  2049. Denis Birnie
  2050. Scott Bronson <urge@mcl.mcl.ucsb.edu>
  2051. Tim Converse <converse@cs.uchicago.edu>
  2052. Julian Harris
  2053. Bruce Hoult <Bruce@hoult.actrix.gen.nz>
  2054. Peter Jensen <pjensen@netcom.com>
  2055. Jonathan Kimmitt <jrrk@camcon.co.uk>
  2056. Matthias Neeracher <neeri@iis.ee.ethz.ch>
  2057. David P. Oster <oster@netcom.com>
  2058. Pete Resnick <resnick@uiuc.edu>
  2059. eric slosser <slosser@apple.com>
  2060. Chris Thomas <thunderone@delphi.com>
  2061. Jon W"atte <h+@nada.kth.se>
  2062. Rick Zaccone <zaccone@bucknell.edu>
  2063.  
  2064.  
  2065.  
  2066.  
  2067. -- 
  2068.  -- Jon W{tte, h+@nada.kth.se, Mac Software Engineer Deluxe --
  2069.   "Psychotherapist" - "Phycho-The-Rapist"
  2070.    Pure coincidence? You decide!
  2071.