home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-020 < prev    next >
Text File  |  2010-09-21  |  104KB  |  2,728 lines

  1. Received-Date: Wed, 27 Apr 1994 17:01:29 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-020
  4. To: csmp-digest@ens.fr
  5. Date: Wed, 27 Apr 94 17:01:22 MET DST
  6. X-Mailer: ELM [version 2.3 PL11]
  7. Errors-To: listman@ens.fr
  8. Reply-To: pottier@clipper.ens.fr
  9. X-Sequence: 22
  10.  
  11. C.S.M.P. Digest             Wed, 27 Apr 94       Volume 3 : Issue 20
  12.  
  13. Today's Topics:
  14.  
  15.         Can background app Paste?
  16.         Determing selected-chosen printer
  17.         Drawing text vertically...
  18.         HELP! Sending apple events
  19.         How can I LOCK in a code segment ?
  20.         INIT vs. Background Only App.
  21.         Info on Graphics Animation Programming?
  22.         Launching an application from a program...
  23.         Looking for a Windows-Mac portable GUI toolkit or builder
  24.         PowerPC Anti-Aliased Text
  25.         SubLaunching applications and DA's
  26.         System 7 Menu on right side of menubar
  27.         free vs. DisposPtr??
  28.  
  29.  
  30.  
  31. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  32. (pottier@clipper.ens.fr).
  33.  
  34. The digest is a collection of article threads from the internet newsgroup
  35. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  36. regularly and want an archive of the discussions.  If you don't know what a
  37. newsgroup is, you probably don't have access to it.  Ask your systems
  38. administrator(s) for details.  If you don't have access to news, you may
  39. still be able to post messages to the group by using a mail server like
  40. anon.penet.fi (mail help@anon.penet.fi for more information).
  41.  
  42. Each issue of the digest contains one or more sets of articles (called
  43. threads), with each set corresponding to a 'discussion' of a particular
  44. subject.  The articles are not edited; all articles included in this digest
  45. are in their original posted form (as received by our news server at
  46. nef.ens.fr).  Article threads are not added to the digest until the last
  47. article added to the thread is at least two weeks old (this is to ensure that
  48. the thread is dead before adding it to the digest).  Article threads that
  49. consist of only one message are generally not included in the digest.
  50.  
  51. The digest is officially distributed by two means, by email and ftp.
  52.  
  53. If you want to receive the digest by mail, send email to listserv@ens.fr
  54. with no subject and one of the following commands as body:
  55.     help                        Sends you a summary of commands
  56.     subscribe csmp-digest Your Name    Adds you to the mailing list
  57.     signoff csmp-digest            Removes you from the list
  58. Once you have subscribed, you will automatically receive each new
  59. issue as it is created.
  60.  
  61. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  62. Questions related to the ftp site should be directed to
  63. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  64. digest are available there.
  65.  
  66. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  67.  
  68.  
  69. -------------------------------------------------------
  70.  
  71. >From west@augsburg.edu (James West)
  72. Subject: Can background app Paste?
  73. Date: 12 Apr 1994 19:46:30 GMT
  74. Organization: Augsburg College
  75.  
  76. Can any kind soul tell me if it is possible to have a background only
  77. application paste to the clipboard? 
  78.  
  79. The application is triggered by appleevents and I would like to have it
  80. place an image on the scrap before it returns. This works fine if I bring
  81. it to the front, but in the background it either completes without pasting
  82. anything, or crashes me into macsbug. 
  83.  
  84. I have looked at a lot of stuff but have not yet found anything that
  85. explicitly tells me that this can't be done with a background app. 
  86.  
  87. Perhaps a resumeevent posting to the event queue...
  88.  
  89. Any help would be greatly appreciated. 
  90. -- 
  91.  
  92. James West                             ***** I like Cacti... ****
  93. Augsburg College Graphic Center
  94. 731 21st Ave S
  95. Mpls. MN 55454        
  96. west@augsburg.edu                      ********  OUTCH!! ********
  97.  
  98. +++++++++++++++++++++++++++
  99.  
  100. >From Dave Falkenburg <falken@apple.com>
  101. Date: Wed, 13 Apr 1994 17:19:53 GMT
  102. Organization: Apple Computer, Inc.
  103.  
  104. In article <west-120494144037@141.224.192.172> James West,
  105. west@augsburg.edu writes:
  106. >Can any kind soul tell me if it is possible to have a background only
  107. >application paste to the clipboard? 
  108.  
  109. Nope. You don't want to know why...
  110.  
  111. A future rev of the scrap manager MAY provide a way to do this, but the
  112. current limitations on the scrap manager prevent it from working when
  113. called from the background.
  114.  
  115. -Dave Falkenburg
  116. -Apple Computer, Inc.
  117.  
  118. ---------------------------
  119.  
  120. >From DAVISM@kcgl1.eng.ohio-state.edu (Mike Davis, Chief of Operations -- KCGL)
  121. Subject: Determing selected-chosen printer
  122. Date: 5 Apr 1994 17:01:39 GMT
  123. Organization: The Ohio State University
  124.  
  125.  
  126.     I have checked a number of texts and also examined the STR resources
  127. for System, Chooser and a printer driver...  Where is the information stored
  128. as to which printer has been selected under the Chooser?  I know the name of
  129. the Printing Manager Resource File (PMRF) is stored in the System file in
  130. STR resource -8192, but I couldn't find anything which resembled the name of
  131. the actual chosen printer.
  132.  
  133.                             Thanks,
  134.                              Mike
  135. --
  136.  Internet: davism@KCGL1.eng.ohio-state.edu |
  137.             -or- DAVISM+@osu.edu           |   These Thoughts, They Be Mine
  138.    BITNET: DAVISM+@OHSTMAIL.BITNET         |
  139.  
  140. +++++++++++++++++++++++++++
  141.  
  142. >From Ben Rubinstein <benr@cogapp.demon.co.uk>
  143. Date: Tue, 5 Apr 1994 18:40:45 GMT
  144. Organization: Cognitive Applications, Brighton, England
  145.  
  146. In article <2ns5hj$fj8@charm.magnus.acs.ohio-state.edu> Mike Davis,
  147. DAVISM@kcgl1.eng.ohio-state.edu writes:
  148. >Where is the information stored as to which printer has been selected
  149. under
  150. >the Chooser?  I know the name of the Printing Manager Resource File
  151. (PMRF)
  152. >is stored in the System file in STR resource -8192...
  153.  
  154.  'STR ' resource ID -8192 in System has name of currently selected driver.
  155. 'PAPA' resource -8192 in the driver has name of current printer (pascal
  156. string at front
  157.     of resource).
  158.  
  159. I have an old XFCn to return the name of the current printer which works
  160. at least in our environment (networked LaserWriters) - can't guarantee
  161. how it will go with stylewriters, et al.  It has the following perhaps
  162. slightly worrying comment at the top:     "We cheat by just doing "PrOpen",
  163. hoping that this will ensure the current driver is open as a res file,
  164. and then looking for Papa (point is to avoid worrying about where the
  165. driver is in system 6/7)"
  166.  
  167. In fact, it's very short - so here it is:
  168. - --
  169. #define    PRNAMETYPE    'PAPA'
  170. #define    PRNAMEID    -8192
  171.  
  172.     PrOpen();
  173.     if (PrError() != noErr) { ....return error stuff...    }
  174.  
  175.     if (hRsrc = GetResource(PRNAMETYPE, PRNAMEID)) {
  176.         HLock(hRsrc);
  177.         paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) *(hRsrc));
  178.         HUnlock(hRsrc);
  179.         ReleaseResource(hRsrc);
  180.     } else {
  181.          ....return error stuff...
  182.     }
  183.  
  184.     PrClose();
  185. - ---
  186.  
  187. As I say, I make no warranties about it, but it's never given me
  188. trouble...
  189. Ben
  190.  
  191. +++++++++++++++++++++++++++
  192.  
  193. >From mgr@aggroup.aggroup.com (Mike Russell)
  194. Date: Tue, 05 Apr 1994 11:58:17 -0800
  195. Organization: the ag group, inc.
  196.  
  197. In article <2ns5hj$fj8@charm.magnus.acs.ohio-state.edu>,
  198. DAVISM@kcgl1.eng.ohio-state.edu (Mike Davis, Chief of Operations -- KCGL)
  199. wrote:
  200.  
  201. >     I have checked a number of texts and also examined the STR resources
  202. > for System, Chooser and a printer driver...  Where is the information stored
  203. > as to which printer has been selected under the Chooser?  I know the name of
  204.  
  205. It's in the PMRF in PAPA resource -8192 for LaserWriter and LaserWriter 8.
  206. This info is for use by the driver and is not stricly part of the
  207. interface.
  208.  
  209. +++++++++++++++++++++++++++
  210.  
  211. >From chewey@aol.com (Chewey)
  212. Date: 6 Apr 1994 09:46:04 -0400
  213. Organization: America Online, Inc. (1-800-827-6364)
  214.  
  215. For System 7.x the System resource file contains an'alis' resource (ID -8192)
  216. to the currently selected output device.  You can get this resource handle and
  217. use it in a call to ResolveAlias().  You'll get an FSSpec record to the actual
  218. output driver.
  219.  
  220. Hope this helps,
  221.  
  222. -Chewey
  223. - --------------
  224. Matthew E. Axsom
  225. Mac Software Engineer
  226. Mac/PC Connection, Inc.
  227. All opinions are mine, and not those of Mac/PC Connection, Inc. (bla, bla,
  228. bla).
  229.  
  230. +++++++++++++++++++++++++++
  231.  
  232. >From Manuel Veloso <veloso@netcom.com>
  233. Date: Wed, 6 Apr 1994 23:23:51 GMT
  234. Organization: Ibex Productions
  235.  
  236. In article <2ns5hj$fj8@charm.magnus.acs.ohio-state.edu> Mike Davis,
  237. DAVISM@kcgl1.eng.ohio-state.edu writes:
  238. >the Printing Manager Resource File (PMRF) is stored in the System file in
  239. >STR resource -8192, but I couldn't find anything which resembled the name of
  240. >the actual chosen printer.
  241.  
  242. Along with the rest of the info in the previous post, be warned that there's
  243. an alias to the currently selected printer driver resident in the system
  244. file (I think it's 'alis' 0). I'm not sure if it's still there, but it was
  245. in 7.0 (the last time I looked).
  246.  
  247. +++++++++++++++++++++++++++
  248.  
  249. >From dowdy@apple.com (Tom Dowdy)
  250. Date: Wed, 13 Apr 1994 23:45:09 GMT
  251. Organization: Apple Computer, Inc.
  252.  
  253. In article <netnewsCnv2Br.87L@netcom.com>, Manuel Veloso
  254. <veloso@netcom.com> wrote:
  255.  
  256. > In article <2ns5hj$fj8@charm.magnus.acs.ohio-state.edu> Mike Davis,
  257. > DAVISM@kcgl1.eng.ohio-state.edu writes:
  258. > >the Printing Manager Resource File (PMRF) is stored in the System file in
  259. > >STR resource -8192, but I couldn't find anything which resembled the name of
  260. > >the actual chosen printer.
  261. > Along with the rest of the info in the previous post, be warned that there's
  262. > an alias to the currently selected printer driver resident in the system
  263. > file (I think it's 'alis' 0). I'm not sure if it's still there, but it was
  264. > in 7.0 (the last time I looked).
  265.  
  266. Be warned that all of the above is undocumented and subject to change.
  267. If you rely on this information your application will break.  
  268.  
  269. But you may say, when will this breaking happen?  QuickDraw GX -- I
  270. *promise* that these methods of hacking around will *not* work.
  271.  
  272. -- 
  273.  Tom Dowdy                  Internet: dowdy@apple.COM
  274.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  275.  1 Infinite Loop            AppleLink: DOWDY1
  276.  Cupertino, CA 95014       
  277.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  278.  
  279. ---------------------------
  280.  
  281. >From pcw@access1.digex.net (Peter Wayner)
  282. Subject: Drawing text vertically...
  283. Date: 5 Apr 1994 15:31:01 -0400
  284. Organization: Express Access Online Communications, Greenbelt, MD USA
  285.  
  286. I would like to draw text vertically. Does anyone have
  287. any code samples for how to do this? I'm presuming
  288. that I'll have to copy it and swap the x and y's.
  289. But does anyone have a definite "good" way to do it? 
  290.  
  291. Thanks a BNDL...
  292.  
  293. Peter Wayner
  294.  
  295.  
  296.  
  297. +++++++++++++++++++++++++++
  298.  
  299. >From ewies@athena.mit.edu (Evan Wies)
  300. Date: 10 Apr 1994 20:35:28 GMT
  301. Organization: Massachvsetts Institvte of Technology
  302.  
  303. In article <pcw.765574161@access1>
  304. pcw@access1.digex.net (Peter Wayner) writes:
  305.  
  306. > I would like to draw text vertically. Does anyone have
  307. > any code samples for how to do this? I'm presuming
  308. > that I'll have to copy it and swap the x and y's.
  309. > But does anyone have a definite "good" way to do it? 
  310. > Thanks a BNDL...
  311. > Peter Wayner
  312.  
  313. When you say "draw text vertically" do you mean like this:
  314. D
  315. E
  316. A
  317. T
  318. H
  319.  
  320. or do you mean that you want to display a string that is rotated 90
  321. degrees?
  322.  
  323. I have done the latter... I made a rotated-font with Fontographer and
  324. then wrote a routine that would display it. It doesn't look very pretty
  325. because fonts weren't designed to be displayed in that orientation; the
  326. spacing is irregular.  It fit my needs though...
  327.  
  328. I can give you the source and make a font for you, if that's what you
  329. need...
  330.  
  331. -Evan Wies
  332.  
  333. +++++++++++++++++++++++++++
  334.  
  335. >From dowdy@apple.com (Tom Dowdy)
  336. Date: Mon, 11 Apr 1994 17:56:37 GMT
  337. Organization: Apple Computer, Inc.
  338.  
  339. In article <pcw.765574161@access1>, pcw@access1.digex.net (Peter Wayner)
  340. wrote:
  341.  
  342. > I would like to draw text vertically. Does anyone have
  343. > any code samples for how to do this? I'm presuming
  344. > that I'll have to copy it and swap the x and y's.
  345. > But does anyone have a definite "good" way to do it? 
  346.  
  347. There are Snippets on the various developer CDs that show
  348. how to perform 90 degree rotation of bitmaps, which is
  349. basically what you need to do in order to draw rotated
  350. text.
  351.  
  352.  - OR -
  353.  
  354. Using QuickDraw GX:
  355.  myShape = GXNewText(3, "Hi!", nil);
  356.  GXRotateShape(myShape, ff(90), 0, 0);
  357.  GXDrawShape(myShape);
  358.  GXDisposeShape(myShape);
  359.  
  360. -- 
  361.  Tom Dowdy                  Internet: dowdy@apple.COM
  362.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  363.  1 Infinite Loop            AppleLink: DOWDY1
  364.  Cupertino, CA 95014       
  365.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  366.  
  367. +++++++++++++++++++++++++++
  368.  
  369. >From opstad@apple.com (David Opstad)
  370. Date: 11 Apr 1994 16:12:36 -0700
  371. Organization: Apple Computer Inc, Cupertino, CA
  372.  
  373. In article <dowdy-110494105244@17.202.72.12>,
  374. Tom Dowdy <dowdy@apple.com> wrote:
  375. >
  376. >Using QuickDraw GX:
  377. > myShape = GXNewText(3, "Hi!", nil);
  378. > GXRotateShape(myShape, ff(90), 0, 0);
  379. > GXDrawShape(myShape);
  380. > GXDisposeShape(myShape);
  381.  
  382. Actually, Tom left out the other kind of vertical text. If you want the
  383. letters themselves to remain upright after the shape is rotated, add the
  384. following line before the GXDrawShape call:
  385.  
  386. GXSetShapeTextAttributes(myShape, GXGetShapeTextAttributes(myShape)
  387.   | gxVerticalText);
  388.  
  389. Dave Opstad
  390. GX Line Layout Weenie
  391.  
  392. +++++++++++++++++++++++++++
  393.  
  394. >From Philippe.Casgrain@univ-rennes1.fr (Philippe Casgrain)
  395. Date: Tue, 12 Apr 1994 15:47:31 +0100
  396. Organization: Universite de Rennes-1, Fac. de medecine dentaire
  397.  
  398.     For all the good folks that want to draw rotated text and do not have
  399. QuickDraw GX, may I suggest:
  400.  
  401. -r    34176 Oct  3 1992 ./mac/sc/snippets/imaging/graphics/rotatestring.hqx
  402.  
  403. on ftp.apple.com. It contains a (small) library and THINK Pascal/C source
  404. code. It worked great for me, the first time I tried it.
  405.  
  406. Philippe
  407.  
  408. -- 
  409. Philippe.Casgrain@univ-rennes1.fr
  410.     Mac Hacker Lite
  411.  
  412. +++++++++++++++++++++++++++
  413.  
  414. >From roderis@CSOS.ORST.EDU (Stephen Roderick)
  415. Date: 12 Apr 1994 15:30:00 GMT
  416. Organization: CS Outreach Services, Oregon State University, Corvallis, OR, USA
  417.  
  418. In article <dowdy-110494105244@17.202.72.12>,
  419. Tom Dowdy <dowdy@apple.com> wrote:
  420. >In article <pcw.765574161@access1>, pcw@access1.digex.net (Peter Wayner)
  421. >wrote:
  422. >
  423. >> I would like to draw text vertically. Does anyone have
  424. >> any code samples for how to do this? I'm presuming
  425. >
  426. >There are Snippets on the various developer CDs that show
  427. >how to perform 90 degree rotation of bitmaps, which is
  428. >basically what you need to do in order to draw rotated
  429. >text.
  430. >
  431. >-- 
  432. > Tom Dowdy                  Internet: dowdy@apple.COM
  433. > Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  434. > 1 Infinite Loop            AppleLink: DOWDY1
  435.  
  436. The Apple snippet is buggy. I have a working version which I can 
  437. send to anyone who wants it.
  438.  
  439. -- 
  440. - ---------------------------------------------------------
  441. Stephen Roderick
  442. roderis@kira.csos.orst.edu
  443. - ---------------------------------------------------------
  444.  
  445. +++++++++++++++++++++++++++
  446.  
  447. >From dowdy@apple.com (Tom Dowdy)
  448. Date: Tue, 12 Apr 1994 02:46:37 GMT
  449. Organization: Apple Computer, Inc.
  450.  
  451. In article <2oclh5$10a@apple.com>, opstad@apple.com (David Opstad) wrote:
  452.  
  453. > In article <dowdy-110494105244@17.202.72.12>,
  454. > Tom Dowdy <dowdy@apple.com> wrote:
  455. > >
  456. > >Using QuickDraw GX:
  457. > > myShape = GXNewText(3, "Hi!", nil);
  458. > > GXRotateShape(myShape, ff(90), 0, 0);
  459. > > GXDrawShape(myShape);
  460. > > GXDisposeShape(myShape);
  461. > Actually, Tom left out the other kind of vertical text. If you want the
  462. > letters themselves to remain upright after the shape is rotated, add the
  463. > following line before the GXDrawShape call:
  464. > GXSetShapeTextAttributes(myShape, GXGetShapeTextAttributes(myShape)
  465. >   | gxVerticalText);
  466.  
  467. Of course, but this isn't the kind of "rotated text" folks are always
  468. asking for. :-)
  469.  
  470. Dave also forgot to point out that this shape attribute will also
  471. work properly with languages that are normally vertical -- allowing
  472. you to mix roman and kanji text (as an example) and have the
  473. proper sections of the text adjust properly.
  474.  
  475. > Dave Opstad
  476. > GX Line Layout Weenie
  477.  
  478. And Dave is *really* supposed to be relaxing on his sabatical right
  479. now :-)
  480.  
  481. -- 
  482.  Tom Dowdy                  Internet: dowdy@apple.COM
  483.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  484.  1 Infinite Loop            AppleLink: DOWDY1
  485.  Cupertino, CA 95014       
  486.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  487.  
  488. ---------------------------
  489.  
  490. >From ericg@cs.uoregon.edu (Mystery Man)
  491. Subject: HELP! Sending apple events
  492. Date: 12 Apr 1994 17:57:10 -0700
  493. Organization: University of Oregon Computer and Information Sciences Dept.
  494.  
  495. I need some help with getting the proper information for the AEAddressDesc 
  496. field in the AECreateAppleEvent procedure.  
  497.  
  498. What I would like to be able to do it select another application on another
  499. macintosh hooked up to the local network or an application on the MAC that my 
  500. program is running on.
  501.  
  502. >From what I understand, the PPCBrowser function will allow me to do this.
  503.  
  504. For some reason, I can't seem to give it the correct parameters.
  505.  
  506. Here is what I have tried:
  507.  
  508. (Everything compiles just fine, but myErr = -50 when I run this code)
  509.  
  510. I am certain that I am including all of the proper header files, etc..
  511.  
  512. I am running THINK C 6.01 on a IIsi.
  513.  
  514. void FindTheApplication( void )
  515. {
  516.     OSErr      myErr;
  517.     Str255     theNullString = "\p";
  518.     Str255    questionString = "\pPlease select the application";
  519.     
  520.     myErr = PPCBrowser( questionString,
  521.                 theNullString,
  522.                 FALSE,
  523.                 &(theTargetID.location),
  524.                 theLocation,
  525.                 nil,
  526.                 "\p" );
  527.                 
  528.     fprintf( cp, "The Error %d\n", myErr );
  529.  
  530. }
  531.  
  532. I would appreciate any and all help.  With this and the contortions I need to
  533. then go through to get this information into an AEAddressDesc type.
  534.  
  535. thanx..!
  536.  
  537.  
  538. ===Eric Gorr================ericg@cs.uoregon.edu===========aka MystryMan===
  539. _____ 
  540. |\ /| * Invincibility is in oneself, vulnerability is in the opponent
  541. | O | * Therefore the considerations of the intelligent always include both
  542. |/_\|   benefit and harm (Sun Tzu)
  543.  
  544. #include <standard.disclamer>
  545. =====Insults, like violence, are the last resort of the incompetent...=====
  546.  
  547.  
  548. +++++++++++++++++++++++++++
  549.  
  550. >From cassidy@esd55.enet.dec.com (Charlie Cassidy)
  551. Date: 13 Apr 1994 18:37:34 GMT
  552. Organization: Digital Equipment Corporation
  553.  
  554.  
  555. In article <2ofg16$c08@comix.cs.uoregon.edu>, ericg@cs.uoregon.edu (Mystery Man) writes:
  556. |>
  557. |>void FindTheApplication( void )
  558. |>{
  559. |>    OSErr      myErr;
  560. |>    Str255     theNullString = "\p";
  561. |>    Str255    questionString = "\pPlease select the application";
  562. |>    
  563. |>    myErr = PPCBrowser( questionString,
  564. |>                theNullString,
  565. |>                FALSE,
  566. |>                &(theTargetID.location),
  567. |>                theLocation,
  568. |>                nil,
  569. |>                "\p" );
  570. |>                
  571. |>    fprintf( cp, "The Error %d\n", myErr );
  572. |>
  573. |>}
  574. |>
  575. Eric,
  576.   The problem looks to be the theLocation parameter.  Pass the address
  577. &theLocation (unless of course it is already a pointer).
  578.  
  579. Here is a code snippet that illustrates the process from PPCBrowser to SendAE.
  580. It is translated from Pascal code that I pieced together from AboutThatMac.
  581.  
  582.  
  583. #include <EPPC.h>
  584. #include <PPCToolbox.h>
  585. #include <AppleEvents.h>
  586.  
  587. // define kMyAEClass and kMyAEID here
  588.  
  589. void main()
  590. {
  591.  
  592.       AppleEvent    theAE, theReply;
  593.     AEDescList    myAEDescList ;
  594.     AEAddressDesc    targetAddress ;
  595.     TargetID    toTargetID ;
  596.     PortInfoRec    myPortInfo ;
  597.     OSType         theParam;
  598.       Str255         gPrompt = "\pFoo";
  599.       Str255         gAppStr = "\pBar";
  600.       OSErr         theResult;
  601.   theResult = PPCBrowser(gPrompt, gAppStr, 0, &toTargetID.location, &myPortInfo,
  602.                nil, "\p");
  603.   toTargetID.name = myPortInfo.name;
  604.  
  605. // I cheated and hardcoded the size of toTargetID
  606.  
  607.   theResult = AECreateDesc(typeTargetID,  &toTargetID, 252,
  608.             &targetAddress);
  609.   theResult = AECreateAppleEvent(kMyAEClass, kMyAEID, &targetAddress,
  610.             kAutoGenerateReturnID, kAnyTransactionID,&theAE);
  611.   theResult = AECreateList(NULL, 0, 0, &myAEDescList);
  612.  
  613. // use AEPutPtr here to add parameters to the AEDescList  
  614.  
  615.   theResult = AEPutParamDesc(&theAE, keyDirectObject, &myAEDescList);
  616.   theResult = AEDisposeDesc(&myAEDescList);
  617. // another cheat, hardcoding the timeout value
  618.   theResult = AESend(&theAE, &theReply, kAEWaitReply + kAENeverInteract,
  619.            kAENormalPriority, 240, NULL, NULL);
  620.   theResult = AEDisposeDesc(&theAE);
  621.   theResult = AEDisposeDesc(&targetAddress);
  622. }
  623.  
  624.  
  625.  
  626. /* End. */
  627.  
  628. -- 
  629. =============================================================================
  630. "Good things can happen, and frequently do, to people as brainy and footsy
  631. as you." - Dr. Seuss
  632. =============================================================================
  633. Charlie Cassidy                        Internet: cassidy@elwood.enet.dec.com
  634. Digital Equipment Corporation          Amateur Radio: charlie@n1hlr.ampr.org
  635. SSD Engineering - SHR1-3/H28
  636. 333 South Street                       This posting reflects the opinion of 
  637. Shrewsbury, MA 01545                   the author, not Digital Equipment Corp
  638. =============================================================================
  639.  
  640. ---------------------------
  641.  
  642. >From louis@asterix.drev.dnd.ca (Louis Demers)
  643. Subject: How can I LOCK in a code segment ?
  644. Date: 7 Apr 1994 16:48:41 -0400
  645. Organization: Defence Research Establishment Valcartier
  646.  
  647. Hi,
  648.  
  649.     We are developping an application with MacApp 3.0.1,
  650. MPW C++. Part of the code uses functions pointers that
  651. are initialized at the beginning of the Application. Later
  652. when we use those function pointers, we crash because
  653. the code segment containing the function's code has been
  654. moved and the pointers are not pointing to the new location.
  655.  
  656.     What we would like to do is lock the proper code segment
  657. at the beginning so that our function pointers remain valid.
  658.  
  659.     This brings us to the more general consideration:
  660.  
  661.     " How can function pointers (in C) be reliably used in
  662.       an environment where code can be relocated without
  663.       notice ? "
  664.  
  665.       Thanks in advance...
  666.  
  667.  
  668.                 Louis
  669.  
  670. PS: The code really needs function pointers, we can't realistically
  671.     change the way this part of the code is written.
  672. -- 
  673. | Louis Demers              | DREV, Defence Research Establishment,Valcartier |
  674. | louis@asterix.drev.dnd.ca | POBox 8800, Courcelette,Quebec, CANADA, G0A 1R0 |
  675. |            (131.132.48.2) | Office: (418) 844-4424       fax (418) 844-4511 |
  676. +---------------------------+-------------------------------------------------+
  677.  
  678. +++++++++++++++++++++++++++
  679.  
  680. >From Willie Rauchwerger <willie-rauchwerger@uokhsc.edu>
  681. Date: 7 Apr 1994 22:43:25 GMT
  682. Organization: OU Health Sciences Center
  683.  
  684. In article <2o1rj9$4gb@asterix.drev.dnd.ca> Louis Demers,
  685. louis@asterix.drev.dnd.ca writes:
  686. >    " How can function pointers (in C) be reliably used in
  687. >      an environment where code can be relocated without
  688. >      notice ? "
  689.  
  690.  
  691. I would check your implementation of Function pointers. If I recall
  692. right (Check New Inside Macintosh: Memory or was that Volume 6),
  693. function pointers should remain valid throughout the execution time of
  694. your software.
  695.  
  696. If the segment is unloaded, I believe the jump table for the application
  697. correctly loads the segment so that your function pointer is valid.
  698.  
  699. I don't know if this is a correct explanation, but its behavior (ie you
  700. won't crash if a function pointer to a function in an unloaded segment) is
  701. true.
  702.  
  703. If this were not the case, people who have custom dialog filters, apple
  704. event handlers, etc. would crash like big dogs all over the place. And 
  705. that just doesn't happen.
  706.  
  707. - -----------------------------------------------------------------
  708. Willie Rauchwerger         AppleLink: Willie
  709. Telemedicine Software Guy  Internet:  willie-rauchwerger@uokhsc.edu
  710. OU Health Sciences Center
  711.  
  712. +++++++++++++++++++++++++++
  713.  
  714. >From pottier@dmi.ens.fr (Francois Pottier)
  715. Date: 8 Apr 1994 09:28:36 GMT
  716. Organization: Ecole Normale Superieure, PARIS, France
  717.  
  718. In article <2o22ad$r3l@romulus.ucs.uoknor.edu>, Willie Rauchwerger <willie-rauchwerger@uokhsc.edu> writes:
  719. |> In article <2o1rj9$4gb@asterix.drev.dnd.ca> Louis Demers,
  720. |> louis@asterix.drev.dnd.ca writes:
  721. |> >    " How can function pointers (in C) be reliably used in
  722. |> >      an environment where code can be relocated without
  723. |> >      notice ? "
  724. |> 
  725. |> 
  726. |> I would check your implementation of Function pointers. If I recall
  727. |> right (Check New Inside Macintosh: Memory or was that Volume 6),
  728. |> function pointers should remain valid throughout the execution time of
  729. |> your software.
  730.  
  731.  
  732. Well, you have two kinds of function pointers: pointers to functions
  733. that are actually inside your program and known to the compiler, and
  734. pointers to functions that have been loaded from code resources.
  735.  
  736. In the first case, when you use a pointer to a function inside your code,
  737. the compiler actually generates a reference to its *jump table entry*.
  738. The jump table entry contains a jump to the right address if the function
  739. is inside a loaded segment. Otherwise it contains a _LoadSeg instruction,
  740. which loads the segment first. So you needn't worry about loaded and
  741. unloaded segments.
  742.  
  743. In the second case, your code loads a stand-alone code resource. It is
  744. up to you to make sure that the resource doesn't move, otherwise your
  745. function pointer will become stale. But it's very easy: just after
  746. loading the resource, call HLock on it - it won't move any more, and
  747. you can use it.
  748.  
  749. Two small catches: beware of heap fragmentation. Having a locked resource
  750. right in the middle of your heap is a Bad Thing. Try to load resources
  751. early in the program flow.
  752. Also, if your program starts in 24-bit mode and switches to 32-bit mode
  753. later on, be sure to call StripAddress on your function pointers.
  754.  
  755. I guess that's it. If I made any mistakes, corrections are welcome.
  756.  
  757.  
  758. -- 
  759. Francois Pottier
  760. pottier@dmi.ens.fr
  761.  
  762. +++++++++++++++++++++++++++
  763.  
  764. >From c.reading@csi.compuserve.com (Charlie Reading)
  765. Date: 8 Apr 94 13:16:58 GMT
  766. Organization: CompuServe Incorporated
  767.  
  768. In article <2o1rj9$4gb@asterix.drev.dnd.ca> Louis Demers,
  769. louis@asterix.drev.dnd.ca writes:
  770. >    " How can function pointers (in C) be reliably used in
  771. >      an environment where code can be relocated without
  772. >      notice ? "
  773.  
  774. First of all, you have to make sure the function you are passing a
  775. pointer to is
  776. represented in the jump table (the jump table is non-relocatable, so the
  777. initial
  778. address never moves).  This can be accomplished by making it part of
  779. another
  780. segment (targets for inter-segment calls always show up in the jump
  781. table) or use
  782. a compiler switch which generates A5 relative addresses for function
  783. addresses).
  784. Appendix A in the MPW C++ Reference seems to indicate A5-relative
  785. addressing is
  786. the default, but if you are using "-b" or "-b2" it turns it around to
  787. PC-relative
  788. addressing.  If this is the case, use "-b3" instead.
  789.  
  790. Alternately, just what are you passing a pointer to?  Is it a "real" C
  791. function or
  792. is it a method?  If you are actually passing a pointer to a method to
  793. something that
  794. requires a pointer to a function it will probably blow big chunks (due to
  795. differences
  796. in calling conventions).
  797.  
  798. --
  799. Charlie Reading
  800. CompuServe Incorporated
  801. c.reading@csi.compuserve.com
  802. Any opinions expressed are not necessarily those of my employer.
  803.  
  804. +++++++++++++++++++++++++++
  805.  
  806. >From Ron_Hunsinger@bmug.org (Ron Hunsinger)
  807. Date: Sun, 10 Apr 94 21:15:48 PST
  808. Organization: Berkeley Macintosh Users Group
  809.  
  810. louis@asterix.drev.dnd.ca (Louis Demers) writes:
  811.  
  812. >We are developping an application with MacApp 3.0.1,
  813. >MPW C++. Part of the code uses functions pointers that
  814. >are initialized at the beginning of the Application. Later
  815. >when we use those function pointers, we crash because
  816. >the code segment containing the function's code has been
  817. >moved and the pointers are not pointing to the new location.
  818. >
  819. >What we would like to do is lock the proper code segment
  820. >at the beginning so that our function pointers remain valid.
  821. >
  822. >This brings us to the more general consideration:
  823. >
  824. >" How can function pointers (in C) be reliably used in
  825. >  an environment where code can be relocated without
  826. >  notice ? "
  827.  
  828. To answer your second question first: When you take the address of a
  829. procedure, the compiler can either take the address of the current
  830. position of the procedure in memory, or the address of the jump table
  831. entry for the procedure.  If the place where you are taking the address
  832. is in a different code segment than the procedure (an inter-segment
  833. reference), the compiler has no choice but to do the latter (take the
  834. address of the jump table entry).  If they are in the same segment
  835. (an intra-segment reference) the compiler can do it either way.
  836.  
  837. If there is any chance that the code segment might move, you need to
  838. make sure that you get the address of the jump table entry.  This
  839. entry will remain valid even if the segment moves, and even if the
  840. segment has been unloaded and removed from memory.
  841.  
  842. BTW: Code segments do not "move without notice".  You have to specifically
  843. unload them.  Although, in the case of MacApp, it may seem that way, 
  844. because MacApp will automatically unload all code segments that have
  845. not been marked resident each time through the event loop.  (In MacApp
  846. terminology, "resident" means "don't automatically unload".)
  847.  
  848. The only way you can be having problems is that:
  849.  
  850.   a) You are making an intra-segment reference, and
  851.   b) You are permitting the compiler to take the address of the
  852.      current position of the procedure (using a PC-relative address), and
  853.   c) Between the time you take the address, and the time you use it, the
  854.      segment is being unloaded (allowing it to move).
  855.  
  856. You can fix the problem by changing any of these three conditions:
  857.  
  858.   a) Force an inter-segment reference, by putting the initialization
  859.      routine that takes the address of the procedure into a different
  860.      code segment than the procedure itself (use #pragma segment), or
  861.   b) Tell the compiler to always use jump table addresses (set the -b3
  862.      compiler option, or do not set either -b or -b2), or
  863.   c) Never unload this code segment
  864.      c1) Put the target routine in one of the segments that MacApp is
  865.          already making resident (#pragma segment ARes), or
  866.      c2) Mark the segment resident at run time (call SetResidentSegment).
  867.  
  868. Method (a) is best - your initialization code should be in its own segment
  869. that will be unloaded after initialization anyway.  It is also the most
  870. portable.  All of the other methods have the disadvantage that they keep
  871. the initialization code in memory for the lifetime of the program, which
  872. is a waste of memory.
  873.  
  874. Method (b) could make the jump table bigger, as well as possibly confusing 
  875. MacApp, which assumes that intra-segment references are PC-relative.  I
  876. think this only matters in the debugger, and maybe not even there.  The
  877. larger jump table is the real problem - a MacApp program of any size can
  878. easily generate a jump table over 32K, which is bad news unless you set
  879. -model far.
  880.  
  881. Method (c2) would use a routine like:
  882.  
  883.   void MakeProcAddressSafe (void *fct) {
  884.       if (!GetSegNumber ((ProcPtr)fct)) {
  885.           // GetSegNumber will return zero if fct does not point into
  886.           // the jump table.  This is precisely the circumstance where
  887.           // we have to make sure the segment is resident.
  888.           SetResidentSegment (GetSegFromPC (fct), true); }
  889.       };
  890.  
  891. which you would call with something like:
  892.  
  893.    aProcAddress = SomeProcedure;
  894.    MakeProcAddressSafe (aProcAddress);
  895.  
  896. -Ron Hunsinger
  897.  
  898. +++++++++++++++++++++++++++
  899.  
  900. >From jwbaxter@olympus.net (John W. Baxter)
  901. Date: Tue, 12 Apr 1994 00:22:02 -0700
  902. Organization: Internet for the Olympic Peninsula
  903.  
  904. In article <001393BF.fc@bmug.org>, Ron_Hunsinger@bmug.org (Ron Hunsinger)
  905. wrote:
  906.  
  907. > louis@asterix.drev.dnd.ca (Louis Demers) writes:
  908. > >We are developping an application with MacApp 3.0.1,
  909. > >MPW C++. Part of the code uses functions pointers that
  910. > >are initialized at the beginning of the Application. Later
  911. > >when we use those function pointers, we crash because
  912. > >the code segment containing the function's code has been
  913. > >moved and the pointers are not pointing to the new location.
  914. > >
  915. > >What we would like to do is lock the proper code segment
  916. > >at the beginning so that our function pointers remain valid.
  917.  
  918. ...
  919.  
  920. > Method (c2) would use a routine like:
  921. >   void MakeProcAddressSafe (void *fct) {
  922. >       if (!GetSegNumber ((ProcPtr)fct)) {
  923. >           // GetSegNumber will return zero if fct does not point into
  924. >           // the jump table.  This is precisely the circumstance where
  925. >           // we have to make sure the segment is resident.
  926. >           SetResidentSegment (GetSegFromPC (fct), true); }
  927. >       };
  928. > which you would call with something like:
  929. >    aProcAddress = SomeProcedure;
  930. >    MakeProcAddressSafe (aProcAddress);
  931.  
  932.  
  933. Or...include the segment is a res! resource, and let InitUMemory () mark it
  934. resident for you.  That's how MacApp's own resident segments are so marked,
  935. and the expected method for application segments.
  936.  
  937. -- 
  938. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  939.    jwbaxter@pt.olympus.net
  940.  
  941. ---------------------------
  942.  
  943. >From John Hamilton Slye <jsbr+@andrew.cmu.edu>
  944. Subject: INIT vs. Background Only App.
  945. Date: Thu,  7 Apr 1994 23:49:45 -0400
  946. Organization: Junior, Electrical and Computer Engineering, Carnegie Mellon, Pittsburgh, PA
  947.  
  948.  
  949. I am writing a program which involves AppleTalk and I was eventually
  950. going to make it an INIT - would it be bad if I made it a
  951. background-only application that would be put in the Startup Items
  952. folder? Would that violate any programming guidelines?
  953.  
  954. I don't know much about writing INITs - if anyone can point me to a good
  955. step-by-step "how to write an INIT" guide somewhere I'd appreciate it.
  956.  
  957. It seems to me that it would be easier just to make my program a
  958. background-only application - though this would mean it could only run
  959. on machines with MultiFinder.
  960.  
  961. Any help on this would be much appreciated...thanks...
  962.  
  963.  
  964.  
  965.  
  966. =========================================================================
  967. J. Hamilton Slye (jsbr@andrew.cmu.edu) 1071 Morewood Ave., Pgh, Pa. 15213
  968.  
  969. "I know there are people in the world who do not love their fellow human
  970. beings...and I HATE people like that!"     -  Tom Lehrer
  971. =========================================================================
  972.  
  973.  
  974. +++++++++++++++++++++++++++
  975.  
  976. >From Scott_Gruby@hmc.edu (Scott Gruby)
  977. Date: 8 Apr 1994 04:18:05 GMT
  978. Organization: Harvey Mudd College, Claremont CA
  979.  
  980. In article <EhdBFNu00iV8ACoVE2@andrew.cmu.edu>, John Hamilton Slye
  981. <jsbr+@andrew.cmu.edu> wrote:
  982.  
  983. > I am writing a program which involves AppleTalk and I was eventually
  984. > going to make it an INIT - would it be bad if I made it a
  985. > background-only application that would be put in the Startup Items
  986. > folder? Would that violate any programming guidelines?
  987. > I don't know much about writing INITs - if anyone can point me to a good
  988. > step-by-step "how to write an INIT" guide somewhere I'd appreciate it.
  989. > It seems to me that it would be easier just to make my program a
  990. > background-only application - though this would mean it could only run
  991. > on machines with MultiFinder.
  992. > Any help on this would be much appreciated...thanks...
  993. > =========================================================================
  994. > J. Hamilton Slye (jsbr@andrew.cmu.edu) 1071 Morewood Ave., Pgh, Pa. 15213
  995. > "I know there are people in the world who do not love their fellow human
  996. > beings...and I HATE people like that!"     -  Tom Lehrer
  997. > =========================================================================
  998.  
  999. My personal opinion is that background-only applications (BOA) will cause
  1000. less problems in the future, i.e. no INIT conflicts (or at least there
  1001. shouldn't be any). It also looks like they are easier to write than INITs
  1002. (I say looks because I have never written an INIT, only a BOA). Here's a
  1003. neat thing you can do to BOAs and that is set the file type to 'appe' and
  1004. put it in the extensions folder. It loads immediately after the Finder
  1005. loads, but you can stick in some startup code that puts a startup icon.
  1006.  
  1007. As for supporting only machines that run MutliFinder, that is almost
  1008. becoming a non-problem. As programs get more and more complicated, running
  1009. anything on a machine not running Sys 7 is getting harder and harder.
  1010.  
  1011. There's some example BOA code on ftp.apple.com and also a tech note
  1012. explaining about BOAs. 
  1013.  
  1014. Good luck!
  1015.  
  1016. -- 
  1017. Scott Allen Gruby                         (Scott_Gruby@hmc.edu)
  1018. Macintosh Student System Manager
  1019. Academic Computing, Harvey Mudd College
  1020. Claremont, CA
  1021.          Finger ripem_public@eagle.st.hmc.edu for public key
  1022.  
  1023. +++++++++++++++++++++++++++
  1024.  
  1025. >From Aaron Wohl <aw0g+@andrew.cmu.edu>
  1026. Date: Fri,  8 Apr 1994 12:22:00 -0400
  1027. Organization: Systems Group 97, Carnegie Mellon, Pittsburgh, PA
  1028.  
  1029. I have written both inits and background only applications.   The
  1030. sources are available via anonymous ftp from akutaktak.andrew.cmu.edu
  1031. [128.2.35.1] in the /aw0g directory.
  1032.  
  1033. Softkiss is a driver/cdev/init to reprogram the SCC hardware to do
  1034. syncronous HDLC to control a ham radio.  Mailcheck is cdev/driver/init
  1035. to check your unix mail using UDP.
  1036.  
  1037. Finger server is faceless background task to implement the finger server
  1038. protocol for the macintosh.
  1039.  
  1040. A device driver installed by an init gives you a way for programs to
  1041. talk to your code once it is installed (they do a device driver call).  
  1042.  A faceless background task would be communicated over the network
  1043. (appletalk or UDP) if you needed to communicate with it.
  1044.  
  1045. Device drivers are harder to debug, run in the system heap (usually) and
  1046. if they leak memory usually leak system heap wich is worse than leaking
  1047. application heap.  Device drivers are an apropriate place for code that
  1048. needs to patch system calls.  Patches installed in applications only
  1049. affect that application and are switch with the application by
  1050. multifinder.
  1051. Aaron Wohl / ham callsign N3LIW / 412-731-3691 / 412-268-5032
  1052.  
  1053. +++++++++++++++++++++++++++
  1054.  
  1055. >From orch@aol.com (Orch)
  1056. Date: 12 Apr 1994 22:54:02 -0400
  1057. Organization: America Online, Inc. (1-800-827-6364)
  1058.  
  1059. A few years ago when System 7 was released at the Developers Conference,  Apple
  1060. was trying to convince developer to avoid writting INITs when ever possible,
  1061. and instead write background applications.
  1062.  
  1063.  
  1064. ---------------------------
  1065.  
  1066. >From awalters@leland.stanford.edu (Andrew J Walters)
  1067. Subject: Info on Graphics Animation Programming?
  1068. Date: 8 Apr 94 21:33:51 GMT
  1069. Organization: Stanford
  1070.  
  1071. I've been working on a board game where I want to move pieces around on
  1072. the
  1073. board.  I'm currently using simple offscreen quickdraw, but it is slow
  1074. and
  1075. not very smooth.  Where is a good source of information on animation
  1076. programming.
  1077.  
  1078.                     Thanks,
  1079.                     Andrew J Walters
  1080.  
  1081. +++++++++++++++++++++++++++
  1082.  
  1083. >From dwareing@apanix.apana.org.au (David Wareing)
  1084. Date: 11 Apr 94 10:59:24 GMT
  1085. Organization: Apanix Public Access Unix, +61 8 373 5485 (5 lines)
  1086.  
  1087. awalters@leland.stanford.edu (Andrew J Walters) writes:
  1088.  
  1089. >I've been working on a board game where I want to move pieces around on
  1090. >the
  1091. >board.  I'm currently using simple offscreen quickdraw, but it is slow
  1092. >and
  1093. >not very smooth.  Where is a good source of information on animation
  1094. >programming.
  1095.  
  1096. I could go into a whole list of arcane references for direct-to-screen
  1097. drawing, VBL tasks etc, but for your needs, I strongly suspect that
  1098. QuickDraw will do the job for you without you having to get your hands
  1099. *too* dirty.
  1100.  
  1101. Unless your board-games has a *lot* of moving sprites, or the sprites are
  1102. unusually large, it can more than likely be done well (very well actually)
  1103. with QuickDraw. These points and more, pop up all the time, but they are
  1104. always good to remember. They will speed up your animation like crazy:
  1105.  
  1106. *  Use GWorlds. Nice. Easy. No mucking around with bits.
  1107.  
  1108. *  Create your GWorlds with a call to NewGWorld. Pass it a screen depth of
  1109.    '0'. This will create an offscreen PixMap that is longword aligned to the
  1110.    screen. Pass the rect in global coords. Mucho speed increases here.
  1111.  
  1112. *  This is obvious, but move the least number of pixels as possible. Don't 
  1113.    always CopyBits unions of rects if not necessary. For example, don't 
  1114.    get the unionrect if the old and new sprite rects are not touching. 
  1115.    Some playing around and timing tests are needed here.
  1116.  
  1117. *  If you don't need special masking effects such as dissolves for your
  1118.    sprites, but you still have irregularly-shaped sprites (i.e. sprites
  1119.    that aren't rectangles), then *don't* use masks at all. Use the CopyBits
  1120.    transfer mode 'transparent' instead to cleanly compose sprites on top
  1121.    of backgrounds and other sprites. In my experience, CopyBits with 
  1122.    transparent, is faster than CopyBits with a maskRgn, and both are *much*
  1123.    faster than using CopyMask or CopyDeepMask. If you do need special
  1124.    masking effects (and remember, you can duplicate most effects offscreen
  1125.    by manipulating the pixmaps anyway), only use CopyBits, with a maskRgn.
  1126.  
  1127. *  Make sure that the source and destination pixmaps involved in a CopyBits
  1128.    have identical ColorTables. Otherwise, poor ole CopyBits has extra work
  1129.    to do. Old sagely advice says to "set the ctSeed field in the color
  1130.    tables of the source and destination to be the same..". Now I don't know
  1131.    if you really need to do this (haven't bothered to check personally,
  1132.    and Alex Metcalf says he noticed no noticeable speed improvements), when
  1133.    you have not changed the color tables at all. Left as an exerci... :)
  1134.  
  1135. *  Ensure that src and dest rects are the same size, else CopyBits has 
  1136.    expensive stretching to do.
  1137.  
  1138. *  Unless you want "masking" effects, only use a transfer mode of SrcCopy.
  1139.  
  1140. *  This one will upset some folks. Take over the machine. Rule the roost.
  1141.    At least for games. Games (and most other forms of animation) on the mac
  1142.    are a different breed of app altogether. Do *not* call WNE, not unless
  1143.    you want pathetic performance. If you must, call GNE or handle events
  1144.    some other way that is less expensive. What about that modem you've got
  1145.    buzzing away in the bgnd? Tough. A game is a game, and if its of the
  1146.    arcade variety, then you need all the speed you can get, without having
  1147.    to pander to other tasks. The game Deliverance sort of puts the lie to 
  1148.    this, as it handles bgnd tasks very well, while still maintaining very
  1149.    decent animation rates. But that's a one-off :)
  1150.  
  1151. *  Optimise your code a little more. I don't use SetRect, as I opt for 
  1152.    setting my rects by hand. Probably doesn't add much to the overall speed
  1153.    at the end of the day, but it makes me feel nice and snug to know that
  1154.    one less trap has been disposed of.
  1155.  
  1156. *  Don't colorise (or colorize if you are on the other side of the pond). 
  1157.    This means that you should make sure that the fg colour is black and the
  1158.    bg colour is white. Else, CopyBits has extra work to do again.
  1159.  
  1160.  
  1161. Most of these points (and many more) are described in detail in a very
  1162. handy tech note (get it at ftp.apple.com) called QD 21 "Time Space and
  1163. CopyBits" by Forrest Tanaka. Well worth the money :)
  1164.  
  1165. I use the book "Programming QuickDraw" by Surovell et al. Covers Sys 7,
  1166. all versions of QD to date, and despite its lousy index, meandering spirit
  1167. and occasionally buggy or incomplete examples, is a good buy, and covers a
  1168. lot of handy topics. (It also misses a few too...).
  1169.  
  1170. Develop has a whole range of articles and example code/apps. Don't know
  1171. the US price, but its easily the development bargain of the decade. 
  1172.   
  1173. Finally, there are several packages out there in ftp.land just waiting to
  1174. be picked up and used. SAT (Sprite Animation Toolkit) by Ingemar Ragnemalm
  1175. is a CopyBits replacement (and then some!), which would be highly suitable
  1176. for games development. Fast with good documentation and lots of examples.
  1177. Pascal and C from memory. 
  1178.  
  1179. Cellusoft Animation (or somesuch thing) is a shareware thingy available at
  1180. your friendly ftp site from Tony Small. This is bascially a CopyBits
  1181. animation tutorial, complete with working code, executables and docs.
  1182.  
  1183. SpriteWorld by Tony Myles is a comprehensive sprite animation package,
  1184. competing with SAT. Comes with code, executables, docs.
  1185.  
  1186. Happy blitting, and remember: CopyBits is certainly up to the job of many
  1187. games. It can handle your average boardgame with ease, and Pacman type
  1188. affairs shouldn't be a problem either.
  1189.  
  1190. --
  1191. David Wareing
  1192. Adelaide, South Australia
  1193. Mac Games & Multimedia Development        dwareing@apanix.apana.org.au
  1194. - --------------------------------------------------------------------
  1195.  
  1196. +++++++++++++++++++++++++++
  1197.  
  1198. >From al@crucible.powertools.com (Al Evans)
  1199. Date: 13 Apr 94 18:06:31 GMT
  1200. Organization: PowerTools, Austin, Texas
  1201.  
  1202. In article <dwareing.766061964@apanix.apana.org.au> dwareing@apanix.apana.org.au (David Wareing) writes:
  1203.  
  1204. >awalters@leland.stanford.edu (Andrew J Walters) writes:
  1205.  
  1206. >>I've been working on a board game where I want to move pieces around on
  1207. >>the
  1208. >>board.  I'm currently using simple offscreen quickdraw, but it is slow
  1209. >>and
  1210. >>not very smooth.  Where is a good source of information on animation
  1211. >>programming.
  1212.  
  1213. >   Old sagely advice says to "set the ctSeed field in the color
  1214. >   tables of the source and destination to be the same..". Now I don't know
  1215. >   if you really need to do this (haven't bothered to check personally,
  1216. >   and Alex Metcalf says he noticed no noticeable speed improvements), when
  1217. >   you have not changed the color tables at all. Left as an exerci... :)
  1218.  
  1219. As long as you're using the system color table for both source and
  1220. destination, which you are if you haven't changed it, there is no 
  1221. speed difference.
  1222.  
  1223. >Finally, there are several packages out there in ftp.land just waiting to
  1224. >be picked up and used. 
  1225.  
  1226. [SAT, Cellusoft Animation, SpriteWorld...]
  1227.  
  1228. You also might want to take a look at my own Graphic Elements, available
  1229. from mac.archive.umich.edu and mirror sites as:
  1230.  
  1231. /mac/misc/demo/graphicelementsdemo.sit.hqx
  1232.  
  1233. It offers performance comparable to that of SAT or SpriteWorld, with
  1234. a more "object-oriented" programming interface. It also has a few
  1235. "special features" -- for example, using horizontal and vertical
  1236. mirroring, you could get all four possible orientations of a game
  1237. piece out of the same graphic, which might be handy in a board game.
  1238.  
  1239.                     --Al Evans--
  1240. -- 
  1241. Al Evans            |   Graphic Elements: A new standard for 
  1242.                 |   high-performance interactive Macintosh graphics.
  1243. al@crucible.powertools.com  |   Available from mac.archive.umich.edu
  1244.                 |   /mac/misc/demo/graphicelementsdemo.sit.hqx
  1245.  
  1246. ---------------------------
  1247.  
  1248. >From Wilson Swee <ws8n+@andrew.cmu.edu>
  1249. Subject: Launching an application from a program...
  1250. Date: Tue, 12 Apr 1994 02:24:24 -0400
  1251. Organization: Senior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  1252.  
  1253. Is it possible to launch an application from a program already running?
  1254. If so, what is a good way of handling it?
  1255.  
  1256. Wilson
  1257.  
  1258.  
  1259. +++++++++++++++++++++++++++
  1260.  
  1261. >From greer@utdallas.edu (Dale M. Greer)
  1262. Date: 12 Apr 1994 14:20:54 GMT
  1263. Organization: The University of Texas at Dallas
  1264.  
  1265. Wilson Swee (ws8n+@andrew.cmu.edu) wrote:
  1266. > Is it possible to launch an application from a program already running?
  1267. > If so, what is a good way of handling it?
  1268.  
  1269. > Wilson
  1270.  
  1271. Yes, and there is a very good example of this called AE Interaction
  1272. Sample of ftp.apple.com.  I don't remember the filepath for this, but
  1273. I think is was in the snippets directory under interapp.comm.  If 
  1274. you don't have access to ftp.apple.com, I could e-mail some stuff
  1275. to you.  The whole Sample is about 160K, but the FindAndLaunchApp
  1276. code is pretty small.
  1277.  
  1278. --
  1279.  
  1280. Dale Greer, greer@utdallas.edu
  1281. "You can't just wake up and kiss the mirror and say 'I'm so purdy,
  1282.  I think I'll run for Governor.'" - Texas Gov. Ann Richards
  1283.  
  1284. +++++++++++++++++++++++++++
  1285.  
  1286. >From tchan@irus.rri.uwo.ca (Thomas KC Chan)
  1287. Date: 13 Apr 1994 16:58:13 GMT
  1288. Organization: Robarts Research Institute, UWO, London, Ontario
  1289.  
  1290. And if you have the Think C on-line reference, there are enough
  1291. examples in implementing it;  the examples should be similar to those
  1292. given in "Inside MACintosh..." manuals.
  1293.  
  1294.  
  1295. Thomas Chan                       e-mail: tchan@irus.rri.uwo.ca
  1296.  
  1297. +++++++++++++++++++++++++++
  1298.  
  1299. >From nickt@tigger.demon.co.uk (nick thompson)
  1300. Date: Wed, 13 Apr 1994 21:14:42 GMT
  1301. Organization: Demon Internet
  1302.  
  1303. Someone asked for some app launching code.  Here are tow handy routines
  1304. - one for seeing if an app is running and one for launching an app.
  1305.  
  1306. You can use it like this:
  1307.  
  1308.     // if we are running we want the PSN and stuff,
  1309.     // otherwise we need to launch it and get the information
  1310.     
  1311.     if(!IsAppRunning( 'APPL',
  1312.                       'SiCk',
  1313.                       &targetPSN, 
  1314.                       &targetPIRec, 
  1315.                       targetName ) ) {
  1316.                       
  1317.         err = LaunchApp( 'SiCk' ) ;
  1318.   }
  1319.  
  1320. Nick
  1321.  
  1322.  
  1323. - -------------
  1324.  
  1325.  
  1326.  
  1327. // check to see using the process manager whether our 
  1328. // target app is running
  1329.  
  1330. Boolean IsAppRunning( OSType targetType,
  1331.                       OSType targetSignature,
  1332.                       ProcessSerialNumber *targetPSN, 
  1333.                       ProcessInfoRec *targetPIRec, 
  1334.                       StringPtr targetName )
  1335. {
  1336.     
  1337.     // we want to return the PSN if there is one
  1338.     // we want to return the Proc Info Rec if there is one
  1339.     // we will return true if we found our App
  1340.     // false if it wasn't running.
  1341.     
  1342.     // we need to loop through all the running processes and 
  1343.     // find one that looks like our background task.
  1344.     
  1345.     // This is all standard stuff - see IM Process Manager, page 2-6
  1346.     
  1347.     targetPSN->highLongOfPSN = 0 ;
  1348.     targetPSN->lowLongOfPSN = kNoProcess ;
  1349.     
  1350.     // set up the info record, for the call to get process info
  1351.     targetPIRec->processInfoLength = sizeof( ProcessInfoRec ) ;
  1352.     targetPIRec->processName = targetName ;    // the name will be put in
  1353. here
  1354.     targetPIRec->processAppSpec = nil ;        // we do not care about the
  1355. location of the app
  1356.     
  1357.     // right, loop through the running processes
  1358.     while( GetNextProcess( targetPSN ) == noErr ) {
  1359.     
  1360.         if( GetProcessInformation( targetPSN, targetPIRec ) == noErr ) {
  1361.             
  1362.             if( targetPIRec->processType == targetType 
  1363.                 && targetPIRec->processSignature == targetSignature )
  1364.                 
  1365.                 return true ;
  1366.         }
  1367.     }
  1368.     return false ;
  1369. }
  1370.  
  1371.  
  1372. // search in the desktop database for the app so that we can launch it
  1373. OSErr LaunchApp( OSType targetSignature)
  1374. {
  1375.     DTPBRec                theDatabase ;
  1376.     LaunchParamBlockRec    theLPB ;
  1377.     FSSpec                targetFSSpec ;
  1378.     OSErr                err ;
  1379.     
  1380.     theDatabase.ioCompletion = 0L ;
  1381.     theDatabase.ioNamePtr = 0L ;
  1382.     theDatabase.ioVRefNum = -1 ;    // restrict search to boot volume only
  1383.     
  1384.     if(( err = PBDTGetPath( &theDatabase )) != noErr )
  1385.         return err ;
  1386.         
  1387.     theDatabase.ioIndex = 0 ;
  1388.     theDatabase.ioFileCreator = targetSignature ;
  1389.     theDatabase.ioNamePtr = (StringPtr)targetFSSpec.name  ;
  1390.     
  1391.     if(( err = PBDTGetAPPL( &theDatabase, false )) != noErr)
  1392.         return err ;
  1393.         
  1394.     targetFSSpec.vRefNum     = theDatabase.ioVRefNum ;
  1395.     targetFSSpec.parID         = theDatabase.ioAPPLParID ;
  1396.     
  1397.     theLPB.launchBlockID     = extendedBlock ;
  1398.     theLPB.launchEPBLength     = extendedBlockLen ;
  1399.     theLPB.launchFileFlags     = 0 ;
  1400.     theLPB.launchControlFlags = launchContinue + launchNoFileFlags +
  1401. launchUseMinimum ;
  1402.     theLPB.launchAppSpec     = &targetFSSpec ;
  1403.     theLPB.launchAppParameters = 0L ;
  1404.     
  1405.     return( LaunchApplication( &theLPB ) ) ;
  1406. }
  1407.  
  1408. ---------------------------
  1409.  
  1410. >From craig@gpu.utcc.utoronto.ca (Craig Hubley)
  1411. Subject: Looking for a Windows-Mac portable GUI toolkit or builder
  1412. Date: Wed, 30 Mar 1994 11:45:16 GMT
  1413. Organization: UTCC Public Access
  1414.  
  1415. Would like to find a tool or toolkit that allows Windows and Mac
  1416. GUIs to be controlled from the same source code.  I am aware of
  1417. some tools (e.g. C++/Views, CommonView, XVT, etc.) but have not
  1418. heard from anyone who has used the latest versions to actually
  1419. build source-code-compatible systems.  Also I have heard that the
  1420. latest Borland C++ has classes that cover the difference completely.
  1421. Can anyone back this up ?  
  1422.  
  1423. Would be interested in particular in Smalltalk based tools.
  1424.  
  1425. Also in the running for a good portable flatfile database toolkit.
  1426.  
  1427. Important criteria for both are source code compatibility across
  1428. Windows and Mac, royalty free distribution of runtimes (product 
  1429. is for mass market), and ideally an object oriented binding in
  1430. C++ or Smalltalk.  I can live with C but will be talking to it
  1431. from C++ or Smalltalk in that case.
  1432.  
  1433. Thanks for any help you can offer
  1434.  
  1435. -- 
  1436.   Craig Hubley -- Consultants in object-oriented technology, languages,  --
  1437.   Craig Hubley & Associates -- user interface design, user productivity  --
  1438.   craig@utcc.Utoronto.CA    -- and financially responsive methodologies  --
  1439.   Seventy Eaton Avenue, Toronto, Ontario, Canada M4J 2Z5 -- 416-969-2826 --
  1440.  
  1441. +++++++++++++++++++++++++++
  1442.  
  1443. >From scharf@lrs.e-technik.uni-erlangen.de (Ron Scharf)
  1444. Date: Thu, 31 Mar 1994 13:24:16 +0200
  1445. Organization: LRS, University of Erlangen, Germany
  1446.  
  1447. craig@gpu.utcc.utoronto.ca (Craig Hubley) writes:
  1448.  
  1449. >Would like to find a tool or toolkit that allows Windows and Mac
  1450. >GUIs to be controlled from the same source code.  I am aware of
  1451. >some tools (e.g. C++/Views, CommonView, XVT, etc.) but have not
  1452. >heard from anyone who has used the latest versions to actually
  1453. >build source-code-compatible systems.
  1454.  
  1455. You might check Neuron Data's "Open Interface"; it's a GUI builder that
  1456. does not only allow system-independent interface creation (on Mac, Windows,
  1457. OpenLook, Motif and OS/2 Presentation Manager), but also allows you to
  1458. change the "look and feel" of your application at runtime to any of the
  1459. above listed - on any machine. So one can e. g. run an application on a Mac
  1460. and change - if he likes (?!) - the user interface to resemble that under
  1461. Windows. (Just telling what I've seen; no comments whether this will make
  1462. sense or not ;-). I've seen a demo where they used the same C source generated
  1463. by Open Interface to build GUIs for Macs, Windows and SUN OpenLook. Pretty
  1464. impressive. As far as I know, there are runtime libraries involved which you
  1465. have to buy; so you can't give an application away free of charge (although a
  1466. distribution license shall be rather cheap, as I've been told).
  1467. You can reach Neuron Data in the US at 156 University Ave., Palo Alto, CA 94301,
  1468. Phone 415-321-4488 Fax 415-321-3728.
  1469.  
  1470. Hopethishelps
  1471.     Ron
  1472.  
  1473. P.S. I'm in no way affiliated to Neuron Data or the like... Just saw a demo
  1474. of this (along with their expert system shell "Nexpert Object") some weeks ago.
  1475.  
  1476.  
  1477. -- 
  1478. Ron Scharf  --  scharf@lrs.e-technik.uni-erlangen.de  --  ron.scharf@msn.rmi.de
  1479. Institute of Computer Aided Circuit Design -- University of Erlangen -- Germany
  1480.        * PET2001 * SX-64 * Amiga1000 * Mac SE/30 * Newton MessagePad *
  1481.    "...this is not a love song, this isn't fantasy land..." - Rush, "Cold Fire"
  1482.  
  1483. +++++++++++++++++++++++++++
  1484.  
  1485. >From mxmora@unix.sri.com (Matt Mora)
  1486. Date: 31 Mar 1994 10:35:26 -0800
  1487. Organization: SRI International, Menlo Park, CA
  1488.  
  1489. In article <scharf.765112226@faulrs> scharf@lrs.e-technik.uni-erlangen.de (Ron Scharf) writes:
  1490.  
  1491. >above listed - on any machine. So one can e. g. run an application on a Mac
  1492. >and change - if he likes (?!) - the user interface to resemble that under
  1493. >Windows. (Just telling what I've seen; no comments whether this will make
  1494.  
  1495. You can do that for motif and windows but not mac. The mac interface is only
  1496. available on the mac.
  1497.  
  1498. >sense or not ;-). I've seen a demo where they used the same C source generated
  1499. >by Open Interface to build GUIs for Macs, Windows and SUN OpenLook. Pretty
  1500. >impressive. As far as I know, there are runtime libraries involved which you
  1501. >have to buy; so you can't give an application away free of charge (although a
  1502. >distribution license shall be rather cheap, as I've been told).
  1503.  
  1504.  
  1505. Actually, there are no runtime fees. So you can give it away to whomever.
  1506. As a developer you need to buy a developer "seat" which includes all the
  1507. things you need to create programs that run on your platform. You can also
  1508. buy "porting" kits for the platforms you want to deploy your program to.
  1509. Neuron recommends that you actually but a dev seat for each platform because
  1510. they price the porting kits almost as high as the development seats.
  1511.  
  1512.  
  1513. Xavier
  1514.  
  1515.  
  1516.  
  1517. -- 
  1518. ___________________________________________________________
  1519. Matthew Xavier Mora                       Matt_Mora@sri.com
  1520. SRI International                       mxmora@unix.sri.com
  1521. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  1522.  
  1523. +++++++++++++++++++++++++++
  1524.  
  1525. >From edandavi@well.sf.ca.us (Ed Allen and Avi Rappoport)
  1526. Date: 2 Apr 1994 23:55:33 GMT
  1527. Organization: The Whole Earth 'Lectronic Link, Sausalito, CA
  1528.  
  1529.  
  1530. I know a company that has actually used XVT for a shipping product.  Please
  1531. email me (attn: Avi) and I'll send you their name & phone number.
  1532.  
  1533. Avi Rappoport
  1534. - ------------
  1535. Using my own account, looking for a job (project management).
  1536.  
  1537. +++++++++++++++++++++++++++
  1538.  
  1539. >From ari@world.std.com (Ari I Halberstadt)
  1540. Date: Tue, 12 Apr 1994 16:09:35 GMT
  1541. Organization: The World Public Access UNIX, Brookline, MA
  1542.  
  1543. In article <scharf.765112226@faulrs>,
  1544. Ron Scharf <scharf@lrs.e-technik.uni-erlangen.de> wrote:
  1545. >craig@gpu.utcc.utoronto.ca (Craig Hubley) writes:
  1546. >
  1547. >>Would like to find a tool or toolkit that allows Windows and Mac
  1548. >>GUIs to be controlled from the same source code.  I am aware of
  1549. >>some tools (e.g. C++/Views, CommonView, XVT, etc.) but have not
  1550. >>heard from anyone who has used the latest versions to actually
  1551. >>build source-code-compatible systems.
  1552. >
  1553. >You might check Neuron Data's "Open Interface"; it's a GUI builder that
  1554.  
  1555. Try the book
  1556.  
  1557. Petrucci, Steve, "Cross-Platform Power Tools", Random House, 1993.
  1558. ISBN 0-679-79147-7. US$45.00.
  1559.  
  1560. The book describes many of the issues involved in developing a cross-
  1561. platform solution. A CD-ROM that contains a cross-platform library,
  1562. called "XPLIB", for Windows 3.1, Win32, and Macintosh is included. I
  1563. don't have a CD-ROM player, so I haven't been able to use XPLIB yet,
  1564. though you can swap the CD for floppies by writing to Random House
  1565. (I'd rather save my money and get a CD-ROM player). Licensing of XPLIB
  1566. for use in products is not really covered in the book, so I think
  1567. you'd have to contact the author to arrange for commercial use. Still,
  1568. $45 is pretty cheap for a cross-platform system. I also think it's a
  1569. good way for people who know Macintosh to get their feet wet in
  1570. Windows (and vice-versa).
  1571. -- 
  1572. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  1573. "These beetles were long considered to be very rare because very few
  1574. entomologists look for beetles in the mountains, in winter, at night,
  1575. during snow storms." -- Purves W. K., et al, "Life: The Science of
  1576.  
  1577. ---------------------------
  1578.  
  1579. >From Chris Hanson <chanson@mtlookitthat.chi.il.us>
  1580. Subject: PowerPC Anti-Aliased Text
  1581. Date: Sun, 10 Apr 94 12:22:02 -0600
  1582. Organization: Green Dragon Creations, Inc.
  1583.  
  1584.  
  1585. Here's an idea:
  1586.  
  1587. Now that PowerPC is out, many users have more processing power than they 
  1588. know what to do with.  (<= No flames please...)  Ergo we must find 
  1589. creative ways to burn all those cycles.  In reading Stewart Brand's "The 
  1590. Media Lab", I discovered the MIT research on anti-aliased text and how 
  1591. it's much easier to read etc.
  1592.  
  1593. SO... How hard would it be to implement a PowerPC extension that 
  1594. maintains an offscreen GWorld and patches QuickDraw's text-drawing 
  1595. routines?  It would  render the text at 2x or 4x actual size and then 
  1596. copy it to its intended destination at regular size with ditherCopy.  I 
  1597. figure a PowerPC should have enough CPU horsepower so this wouldn't 
  1598. noticeably degrade performance -- right?
  1599.  
  1600. Where would be the best place to patch this in?
  1601.  
  1602. TTFN,
  1603. Chris
  1604.  
  1605. +++++++++++++++++++++++++++
  1606.  
  1607. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  1608. Date: 10 Apr 1994 19:34:20 GMT
  1609. Organization: The Royal Institute of Technology
  1610.  
  1611. In <94041012220221834@mtlookitthat.chi.il.us> Chris Hanson <chanson@mtlookitthat.chi.il.us> writes:
  1612.  
  1613. >Where would be the best place to patch this in?
  1614.  
  1615. Tail-patch OpenPort and OpenCPort to install their own text drawing
  1616. procs, which set the port to the offscreen port, fall throught to
  1617. the normal StdText, and then set the port back, CopyBits, and update
  1618. the pen location.
  1619. -- 
  1620.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  1621.  "Don't stick a Fork in your Eye."
  1622.  
  1623. +++++++++++++++++++++++++++
  1624.  
  1625. >From gdl@stlawrence.maths (Greg Landweber)
  1626. Date: 11 Apr 1994 00:22:11 GMT
  1627. Organization: (none)
  1628.  
  1629. In article <94041012220221834@mtlookitthat.chi.il.us> Chris Hanson <chanson@mtlookitthat.chi.il.us> writes:
  1630.    Now that PowerPC is out, many users have more processing power than they 
  1631.    know what to do with.  (<= No flames please...)  Ergo we must find 
  1632.    creative ways to burn all those cycles.  In reading Stewart Brand's "The 
  1633.    Media Lab", I discovered the MIT research on anti-aliased text and how 
  1634.    it's much easier to read etc.
  1635.  
  1636. Take a look at the latest version of Greg's Browser (just released to
  1637. sumex and umich).  It has an option to use anti-aliased text for its
  1638. main window font.  It's done in 680x0 code (and it isn't too slow if
  1639. you have a 68040), but it will be the first part that I port to
  1640. PowerPC native code (as soon as Metrowerks releases Code Warrior
  1641. DR/3 which I am told will generate the type of resources that I need).
  1642.  
  1643.    SO... How hard would it be to implement a PowerPC extension that 
  1644.    maintains an offscreen GWorld and patches QuickDraw's text-drawing 
  1645.    routines?  It would  render the text at 2x or 4x actual size and then 
  1646.    copy it to its intended destination at regular size with ditherCopy.  I 
  1647.    figure a PowerPC should have enough CPU horsepower so this wouldn't 
  1648.    noticeably degrade performance -- right?
  1649.  
  1650. I considered doing this a few months ago (when I first tried the
  1651. anti-aliasing code for Greg's Browser).  Unfortunately, this would be too
  1652. slow on a 680x0 Mac, and I'm not planning on buying a PowerMac until
  1653. I'm back in the USA in the fall.  It won't be hard to get the
  1654. anti-aliasing code wo1rking, but I'm not about to start debugging trap
  1655. patches without a machine to test on...
  1656.  
  1657. There was an article in Develop a while back explaining how to do
  1658. anti-aliasing.  If you want it to go at a good speed, you should write
  1659. your own ditherCopy-substitute, and I believe there was a follow-up
  1660. article in Develop describing that as well.
  1661.  
  1662.    Where would be the best place to patch this in?
  1663.  
  1664. Somewhere around the StdText routine.
  1665.  
  1666. -- Greg "Buttons"/"Browser" Landweber
  1667.    gdl@maths.ox.ac.uk
  1668.  
  1669. +++++++++++++++++++++++++++
  1670.  
  1671. >From cwiltgen@mcs.com (Charles Wiltgen)
  1672. Date: Sun, 10 Apr 1994 21:20:09 -0600
  1673. Organization: Waterman Design, Inc. (opinions are my own)
  1674.  
  1675. In article <94041012220221834@mtlookitthat.chi.il.us>, Chris Hanson
  1676. <chanson@mtlookitthat.chi.il.us> wrote:
  1677.  
  1678. > Here's an idea:
  1679.  
  1680. And a *great* one it is.
  1681.  
  1682. > Now that PowerPC is out, many users have more processing power than they 
  1683. > know what to do with.  (<= No flames please...)  Ergo we must find 
  1684. > creative ways to burn all those cycles.  In reading Stewart Brand's "The 
  1685. > Media Lab", I discovered the MIT research on anti-aliased text and how 
  1686. > it's much easier to read etc.
  1687.  
  1688. Absolutely.  Hopefully QuickDrawGX lets you do this more easily.
  1689.  
  1690. I was thinking that there may be some cases where you wouldn't want to
  1691. antialiased text, so a box with both application and font exceptions would
  1692. be nice.  Then you can specify that test in ThinkC shouldn't be
  1693. antialiased, and that you never want Chicago and Geneva (for example)
  1694. antialiased.
  1695.  
  1696. -- 
  1697. Charles Wiltgen    "Love is a snowmobile racing across the tundra and
  1698. cwiltgen@mcs.com    then suddenly it flips over, pinning you underneath.
  1699. (INTP)              At night, the ice weasels come." - Nietzsche (Groening)
  1700.  
  1701. +++++++++++++++++++++++++++
  1702.  
  1703. >From d88-jwa@hemul.nada.kth.se (Jon Wdtte)
  1704. Date: 11 Apr 1994 09:26:41 GMT
  1705. Organization: The Royal Institute of Technology
  1706.  
  1707. >> Media Lab", I discovered the MIT research on anti-aliased text and how 
  1708. >> it's much easier to read etc.
  1709.  
  1710. >Absolutely.  Hopefully QuickDrawGX lets you do this more easily.
  1711.  
  1712. Nope; QuickDraw GX is presently a one-color-only system.
  1713. No anti-aliasing yet :-(
  1714.  
  1715. -- 
  1716.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  1717.    This signature is kept shorter than 4 lines in the interests of UseNet
  1718.    S/N ratio.
  1719.  
  1720. +++++++++++++++++++++++++++
  1721.  
  1722. >From grstate@shade (Gavriel State)
  1723. Date: Tue, 12 Apr 1994 22:10:58 GMT
  1724. Organization: University of Waterloo
  1725.  
  1726. Chris Hanson (chanson@mtlookitthat.chi.il.us) wrote:
  1727.  
  1728. : Here's an idea:
  1729.  
  1730. : SO... How hard would it be to implement a PowerPC extension that 
  1731. : maintains an offscreen GWorld and patches QuickDraw's text-drawing 
  1732. : routines?  It would  render the text at 2x or 4x actual size and then 
  1733. : copy it to its intended destination at regular size with ditherCopy.  I 
  1734. : figure a PowerPC should have enough CPU horsepower so this wouldn't 
  1735. : noticeably degrade performance -- right?
  1736.  
  1737. Rather than doing it this way, it would be better to maintain a cached 
  1738. anti-aliased version of each font in a seperate GWorld.  This will make 
  1739. the actual drawing of any piece of text much faster since you won't be 
  1740. forced to do a ditherCopy every time you draw some text - instead you can 
  1741. use srcOr.  It'll be more work since you'll have to worry about the 
  1742. font metrics, etc, but if done correctly this doesn't have to be for 
  1743. PMacs only.  I think it would be plenty fast enough for '040 Macs....
  1744.  
  1745. You'd probably want to have some scheme to decide which fonts to cache
  1746. and when - otherwise you'll end up eating gobs and gobs of memory caching
  1747. fonts....but hey - the PowerMacs come with 8 Megs, so what does a few 
  1748. hundred K of cached fonts matter, right? ;-)  
  1749.  
  1750.  
  1751. --
  1752.   Gavriel State | 3B Systems Design Engineering/Economics | Univ. of Waterloo
  1753. Email: grstate@zeus.uwaterloo.ca|       "You can't 'not be' on a boat!"
  1754. - ------------------------------|       "I've often not been on boats."
  1755. (905) 669-5652 (in Toronto)     |"No, what you've been is often not on boats."
  1756. (519) 886-5765 (in Waterloo)    |    Rosencrantz and Guildenstern are Dead
  1757.  
  1758. +++++++++++++++++++++++++++
  1759.  
  1760. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1761. Date: Tue, 12 Apr 1994 21:49:47 GMT
  1762. Organization: Apple Computer
  1763.  
  1764. Chris Hanson, chanson@mtlookitthat.chi.il.us writes:
  1765. > SO... How hard would it be to implement a PowerPC extension that 
  1766. > maintains an offscreen GWorld and patches QuickDraw's text-drawing 
  1767. > routines?
  1768.  
  1769. It might be easier just to use a grayscale font. These are supported by Color
  1770. QuickDraw but there used to be bugs in rendering them in some circumstances.
  1771. (Don't know if these have ever been fixed.)
  1772.  
  1773. I've built some anti-aliased fonts (and you can play around with it in
  1774. PhotoShop or ColorIt.) In my opinion antialiased text works well at very
  1775. small sizes, say <9pt, because it is actually decipherable unlike b/w text;
  1776. and at large sizes, say >=24pt because it's prettier. In intermediate sizes
  1777. it just looks blurry and gives you a headache.
  1778.  
  1779. I think a lot of this could be improved if the hinting process knew about the
  1780. anti-aliasing, but that would require a lot of work inside the TrueType (or
  1781. ATM) renderer.
  1782.  
  1783. --Jens Alfke
  1784.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1785.             .apple.com              Rebel girl you are the queen of my world
  1786.  
  1787. +++++++++++++++++++++++++++
  1788.  
  1789. >From sho@bohr.physics.purdue.edu (Sho Kuwamoto)
  1790. Date: 13 Apr 94 15:43:58 GMT
  1791. Organization: Purdue University Physics Department
  1792.  
  1793. In article <Co62yB.IEB@watserv2.uwaterloo.ca> grstate@zeus.uwaterloo.ca writes:
  1794. >Rather than doing it this way, it would be better to maintain a cached 
  1795. >anti-aliased version of each font in a seperate GWorld.  This will make 
  1796. >the actual drawing of any piece of text much faster since you won't be 
  1797. >forced to do a ditherCopy every time you draw some text - instead you can 
  1798. >use srcOr.
  1799.  
  1800. This becomes a less practical solution if you want to do
  1801. sub-pixel level positioning.
  1802.  
  1803. -Sho
  1804. --
  1805. sho@physics.purdue.edu <<-- finger this account to find out what I'm
  1806.                             having for lunch!
  1807.  
  1808. <A HREF="http://physics.purdue.edu/~sho/homepage.html>Sho Kuwamoto</A>.
  1809.  
  1810. +++++++++++++++++++++++++++
  1811.  
  1812. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1813. Date: 14 Apr 94 13:10:15 +1200
  1814. Organization: University of Waikato, Hamilton, New Zealand
  1815.  
  1816. In article <1994Apr12.214947.10961@gallant.apple.com>, Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  1817. >
  1818. > I've built some anti-aliased fonts (and you can play around with it in
  1819. > PhotoShop or ColorIt.) In my opinion antialiased text works well at very
  1820. > small sizes, say <9pt, because it is actually decipherable unlike b/w text;
  1821. > and at large sizes, say >=24pt because it's prettier. In intermediate sizes
  1822. > it just looks blurry and gives you a headache.
  1823. >
  1824. > I think a lot of this could be improved if the hinting process knew about the
  1825. > anti-aliasing, but that would require a lot of work inside the TrueType (or
  1826. > ATM) renderer.
  1827.  
  1828. In my partially-informed opinion, it's pointless to do both hinting and
  1829. anti-aliasing. Hinting is there to aid readability by removing irregularities
  1830. in the rendering of the text. Anti-aliasing is just there to smooth over the
  1831. irregularities; I don't believe it actually improves readability any.
  1832.  
  1833. Refutations (with evidence) welcomed...!
  1834.  
  1835. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1836. Info & Tech Services Division              fax: +64-7-838-4066
  1837. University of Waikato            electric mail: ldo@waikato.ac.nz
  1838. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1839.  
  1840. +++++++++++++++++++++++++++
  1841.  
  1842. >From dowdy@apple.com (Tom Dowdy)
  1843. Date: Thu, 14 Apr 1994 01:59:39 GMT
  1844. Organization: Apple Computer, Inc.
  1845.  
  1846. In article <1994Apr14.131015.27573@waikato.ac.nz>, ldo@waikato.ac.nz
  1847. (Lawrence D'Oliveiro, Waikato University) wrote:
  1848.  
  1849. > In article <1994Apr12.214947.10961@gallant.apple.com>, Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  1850. > >
  1851. > > I've built some anti-aliased fonts (and you can play around with it in
  1852. > > PhotoShop or ColorIt.) In my opinion antialiased text works well at very
  1853. > > small sizes, say <9pt, because it is actually decipherable unlike b/w text;
  1854. > > and at large sizes, say >=24pt because it's prettier. In intermediate sizes
  1855. > > it just looks blurry and gives you a headache.
  1856. > >
  1857. > > I think a lot of this could be improved if the hinting process knew about the
  1858. > > anti-aliasing, but that would require a lot of work inside the TrueType (or
  1859. > > ATM) renderer.
  1860. > In my partially-informed opinion, it's pointless to do both hinting and
  1861. > anti-aliasing. Hinting is there to aid readability by removing irregularities
  1862. > in the rendering of the text. 
  1863.  
  1864. Well, there are *some* things that are better done at a lower level.
  1865. One of the problems with the scale-to-4X and downsample to the
  1866. original size is that the font at 4X may actually look quite a bit
  1867. different than it normally does at (say), 12 point.  
  1868.  
  1869. There are better things that you can do if you know that the 4X scale
  1870. is "just pretend" and the only piece to know this is the scaler.
  1871.  
  1872. > Anti-aliasing is just there to smooth over the
  1873. > irregularities; I don't believe it actually improves readability any.
  1874. > Refutations (with evidence) welcomed...!
  1875.  
  1876. I'm sure you'll get lots of "does *too* work!" without evidence.
  1877. I've yet to see any real studies that show that anti-aliasing
  1878. improves readability.
  1879.  
  1880. *Lots* of people think that it looks better, and will claim things
  1881. such as "with systems that I've seen I can read text down to 4 point"...
  1882. I think probably the only practical use is in preparing slides,
  1883. where the results will be projected very large -- and that's the
  1884. difficult case, because you need to antialias against
  1885. the background area, which is typically a ramp-fill or something.
  1886.  
  1887. -- 
  1888.  Tom Dowdy                  Internet: dowdy@apple.COM
  1889.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  1890.  1 Infinite Loop            AppleLink: DOWDY1
  1891.  Cupertino, CA 95014       
  1892.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  1893.  
  1894. +++++++++++++++++++++++++++
  1895.  
  1896. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1897. Date: Thu, 14 Apr 1994 22:50:19 GMT
  1898. Organization: Apple Computer
  1899.  
  1900. Lawrence D'Oliveiro, ldo@waikato.ac.nz writes:
  1901. > In my partially-informed opinion, it's pointless to do both hinting and
  1902. > anti-aliasing. Hinting is there to aid readability by removing
  1903. irregularities
  1904. > in the rendering of the text. Anti-aliasing is just there to smooth over the
  1905. > irregularities; I don't believe it actually improves readability any.
  1906.  
  1907. (a) Antialiasing greatly improves readability at small sizes. Proof: I can
  1908. read 4pt type if it's antialiased, but can't if it isn't. I do NOT believe it
  1909. improves readability at normal text (>=10pt) sizes.
  1910.  
  1911. (b) One of the problems with antialiasing by drawing the text at a larger
  1912. size and then shrinking it down is that the hinter lines features up with the
  1913. finer grid, but not necessarily with the final shrunk grid. This means that
  1914. edges and corners usually don't line up with exact pixels and you get gray
  1915. edges or little gray blobs sticking out. You can see this even with large
  1916. antialiased text. This is exactly the kind of problem that hinting is
  1917. designed to help with; the problem is that the hinting is using the finer
  1918. grid and not the coarser one. I believe that if the hinter used the coarse
  1919. grid but rendered to the finer one, the results would be a lot nicer. It
  1920. _might_ be possible to fix the instructions on a TrueType font to make it do
  1921. this...
  1922.  
  1923. --Jens Alfke (former type weenie)
  1924.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1925.             .apple.com              Rebel girl you are the queen of my world
  1926.  
  1927. +++++++++++++++++++++++++++
  1928.  
  1929. >From hall_j@sat.mot.com (Joseph Hall)
  1930. Date: Wed, 13 Apr 1994 02:41:47 GMT
  1931. Organization: Motorola Inc., Satellite Communications
  1932.  
  1933. Seems it was gdl@stlawrence.maths (Greg Landweber) who said:
  1934. >There was an article in Develop a while back explaining how to do
  1935. >anti-aliasing.  If you want it to go at a good speed, you should write
  1936. >your own ditherCopy-substitute, and I believe there was a follow-up
  1937. >article in Develop describing that as well.
  1938.  
  1939. Hmm.  I assume the article uses spatial filtering, but that isn't an 
  1940. optimal method for antialiasing objects in general.  You really need 
  1941. to have antialiasing built into the TrueType scan converter, and
  1942. then implement a transparency plane for color fonts.  Now, *that* would
  1943. be a patch you could be proud of!
  1944.  
  1945. -- 
  1946. Joseph Nathan Hall | Joseph's Law of Interface Design: Never give your users
  1947. Software Architect | a choice between the easy way and the right way.
  1948. Gorca Systems Inc. |                 joseph@joebloe.maple-shade.nj.us (home)
  1949. (on assignment)    | (602) 732-2549 (work)  Joseph_Hall-SC052C@email.mot.com
  1950.  
  1951. ---------------------------
  1952.  
  1953. >From Chris Roberts <ctr@pyrite.som.cwru.edu>
  1954. Subject: SubLaunching applications and DA's
  1955. Date: 8 Apr 1994 16:42:39 GMT
  1956. Organization: Case Western Reserve University
  1957.  
  1958. OK, one more time...   
  1959. I'm having a serious problem with some code I'm writing..  It is intended
  1960. to sublaunch applications...
  1961.  
  1962. Whenever I launch an application (via launch()) or a deskaccessory (via
  1963. OpenDeskAcc)
  1964. The application or DA doesn't launch...  
  1965.  
  1966. Instead, it waits until I switch applications, or quit...
  1967.  
  1968. I don't quite get what's wrong because I know I have made calls to
  1969. WaitNextEvent
  1970. after the call to launch or OpenDeskAcc..
  1971.  
  1972. Could there be something wrong with the way I'm calling WaitNextEvent?
  1973.  
  1974. I'm calling it like:
  1975.  
  1976. WaitNextEvent(everyEvent, &theEvent, 0xFFFFFFFF, NIL);
  1977.  
  1978. Is there something I should be doing differently?
  1979.  
  1980. Thanks, 
  1981.    Chris
  1982.  
  1983. +++++++++++++++++++++++++++
  1984.  
  1985. >From platypus@cirrus.som.cwru.edu (Gary Kacmarcik)
  1986. Date: 08 Apr 1994 18:44:04 GMT
  1987. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  1988.  
  1989.  
  1990. In article <2o41hv$7l0@usenet.INS.CWRU.Edu> Chris Roberts <ctr@pyrite.som.cwru.edu> writes:
  1991. >
  1992. > OK, one more time...   
  1993. > I'm having a serious problem with some code I'm writing..  It is intended
  1994. > to sublaunch applications...
  1995. >
  1996. > Whenever I launch an application (via launch()) or a deskaccessory (via
  1997. > OpenDeskAcc)
  1998. > The application or DA doesn't launch...  
  1999.  
  2000. it sounds like you're using the old interfaces.  have you tried using the
  2001. LaunchApplication and LaunchDeskAccessory routines described in 
  2002. IM: Processes?
  2003.  
  2004. these routines are working just dandy for me.
  2005.  
  2006. -gary j kacmarcik
  2007. platypus@cirrus.som.cwru.edu
  2008.  
  2009. +++++++++++++++++++++++++++
  2010.  
  2011. >From lrucker@parcplace.com (Lee Ann Rucker)
  2012. Date: 9 Apr 1994 00:08:30 GMT
  2013. Organization: ParcPlace
  2014.  
  2015. In article <PLATYPUS.94Apr8144404@cirrus.som.cwru.edu>,
  2016. platypus@cirrus.som.cwru.edu (Gary Kacmarcik) wrote:
  2017.  
  2018. > it sounds like you're using the old interfaces.  have you tried using the
  2019. > LaunchApplication and LaunchDeskAccessory routines described in 
  2020. > IM: Processes?
  2021. > these routines are working just dandy for me.
  2022.  
  2023. I'm using them in an MPW tool to run applications, but I'd like to be able
  2024. to specify a file for the app to open.  IM:Processes says that the
  2025. AppParameters struct can be used for sending an AppleEvent, but doesn't
  2026. explain how to set it up.  Could anyone provide sample code to do this?
  2027.  
  2028. Thanks
  2029.  
  2030. +++++++++++++++++++++++++++
  2031.  
  2032. >From platypus@cirrus.som.cwru.edu (Gary Kacmarcik)
  2033. Date: 09 Apr 1994 14:24:18 GMT
  2034. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  2035.  
  2036. In article <lrucker-080494160935@leeann-mac.parcplace.com> lrucker@parcplace.com (Lee Ann Rucker) writes:
  2037. >
  2038. > I'm using them in an MPW tool to run applications, but I'd like to be able
  2039. > to specify a file for the app to open.  IM:Processes says that the
  2040. > AppParameters struct can be used for sending an AppleEvent, but doesn't
  2041. > explain how to set it up.  Could anyone provide sample code to do this?
  2042.  
  2043. i haven't tried using the AppParameters struct.
  2044.  
  2045. why isn't it acceptable to send an 'odoc' event after the app is opened?
  2046.  
  2047.  
  2048. -gary j kacmarcik
  2049. platypus@cirrus.som.cwru.edu
  2050.  
  2051. +++++++++++++++++++++++++++
  2052.  
  2053. >From lrucker@parcplace.com (Lee Ann Rucker)
  2054. Date: 10 Apr 1994 19:35:57 GMT
  2055. Organization: ParcPlace
  2056.  
  2057. In article <PLATYPUS.94Apr9102418@cirrus.som.cwru.edu>,
  2058. platypus@cirrus.som.cwru.edu (Gary Kacmarcik) wrote:
  2059. | In article <lrucker-080494160935@leeann-mac.parcplace.com>
  2060. lrucker@parcplace.com (Lee Ann Rucker) writes:
  2061. | >
  2062. | > I'm using them in an MPW tool to run applications, but I'd like to be
  2063. able
  2064. | > to specify a file for the app to open.  IM:Processes says that the
  2065. | > AppParameters struct can be used for sending an AppleEvent, but doesn't
  2066. | > explain how to set it up.  Could anyone provide sample code to do this?
  2067. | i haven't tried using the AppParameters struct.
  2068. | why isn't it acceptable to send an 'odoc' event after the app is opened?
  2069. | -gary j kacmarcik
  2070. | platypus@cirrus.som.cwru.edu
  2071.  
  2072. Hadn't thought of that.  I'm not the one who wants to do it, actually - we
  2073. have customers who say "I can open an app with parameters with your Windows
  2074. product, how would I do the same thing on the Mac?"
  2075.  
  2076. I'm still curious about AppParameters, though.
  2077.  
  2078. +++++++++++++++++++++++++++
  2079.  
  2080. >From Deirdre Maloy <Deeny3@aol.com>
  2081. Date: Mon, 11 Apr 1994 20:26:38 GMT
  2082. Organization: Metro Information Services, Raleigh NC
  2083.  
  2084. The sample code is given in one of the CD-roms in the bowels somewhere.
  2085. I've modified it somewhat, but it's been working for over a year, so I
  2086. know it's solid.
  2087.  
  2088. extern    FInfo                    appFInfo;
  2089.  
  2090. extern    launchRecord            myLaunchInfo[MAX_SUBLAUNCHES];        //    info on where
  2091. app is located
  2092. extern    short                currentLaunch;
  2093.  
  2094. extern    Str255                myFile;
  2095.  
  2096. extern    AEDesc                myAddress,docDesc,launchDesc;
  2097. extern    AEDescList            theList;
  2098. extern    AliasHandle            withThis;
  2099. extern    AppleEvent            myAEvent;
  2100.  
  2101.  
  2102. void        addOpDocEvt(void)
  2103. {
  2104.         OSErr                myErr;
  2105.         ProcessSerialNumber    myPSN;
  2106.         
  2107.     GetCurrentProcess(&myPSN);
  2108.      myErr = AECreateDesc(typeProcessSerialNumber, (Ptr)&myPSN,
  2109. sizeof(ProcessSerialNumber), &myAddress);
  2110.  
  2111.     AECreateAppleEvent(kCoreEventClass,kAEOpenDocuments, &myAddress, -1, 0,
  2112. &myAEvent);
  2113.     
  2114.     AECreateList(0L, 0, FALSE, &theList);
  2115.     
  2116.     NewAlias(0L,&myLaunchInfo[currentLaunch].docName,&withThis);
  2117.     HLock((Handle)withThis);
  2118.  
  2119. AECreateDesc(typeAlias,(Ptr)*withThis,GetHandleSize((Handle)withThis),&
  2120. ocDesc);
  2121.     HUnlock((Handle)withThis);
  2122.     
  2123.     AEPutDesc(&theList,0,&docDesc);
  2124.     AEPutParamDesc(&myAEvent,keyDirectObject,&theList);
  2125.     
  2126.     AECoerceDesc(&myAEvent,typeAppParameters,&launchDesc);
  2127.     HLock((Handle)myAEvent.dataHandle);
  2128.     
  2129.     myLaunchInfo[currentLaunch].launchBlock.launchAppParameters =
  2130. (AppParametersPtr)*(launchDesc.dataHandle);
  2131.  
  2132. }
  2133.  
  2134.  
  2135.  
  2136. In article <lrucker-100494113729@leeann-mac.parcplace.com> Lee Ann
  2137. Rucker, lrucker@parcplace.com writes:
  2138. >| In article <lrucker-080494160935@leeann-mac.parcplace.com>
  2139. >lrucker@parcplace.com (Lee Ann Rucker) writes:
  2140. >| >
  2141. >| > I'm using them in an MPW tool to run applications, but I'd like to be
  2142. >able
  2143. >| > to specify a file for the app to open.  IM:Processes says that the
  2144. >| > AppParameters struct can be used for sending an AppleEvent, but
  2145. doesn't
  2146. >| > explain how to set it up.  Could anyone provide sample code to do
  2147. this?
  2148.  
  2149. +++++++++++++++++++++++++++
  2150.  
  2151. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  2152. Date: Wed, 13 Apr 1994 18:56:15 GMT
  2153. Organization: Apple Computer
  2154.  
  2155. Gary Kacmarcik, platypus@cirrus.som.cwru.edu writes:
  2156. > why isn't it acceptable to send an 'odoc' event after the app is opened?
  2157.  
  2158. Because then the app will get an 'oapp' followed by an 'odoc'. For most
  2159. document type apps this will cause a spurious untitled window to open; for
  2160. things like drop-boxes they may just quit immediately upon getting the 'oapp'.
  2161.  
  2162. Lee Ann, you might want to look at my SignatureToApp library, available on
  2163. the developer CD (or the 'develop' CD too, I think.) It's a C library that
  2164. lets you launch applications with documents. It includes a simple MPW tool
  2165. for launching apps; I don't remember if the tool accepts documents or not,
  2166. but it shouldn't be hard to extend it to do so.
  2167.  
  2168. --Jens Alfke
  2169.   jens_alfke@powertalk              Rebel girl, rebel girl,
  2170.             .apple.com              Rebel girl you are the queen of my world
  2171.  
  2172. ---------------------------
  2173.  
  2174. >From rjc@terminator.rs.itd.umich.edu (Robert John Churchill)
  2175. Subject: System 7 Menu on right side of menubar
  2176. Date: 4 Apr 1994 19:13:13 -0400
  2177. Organization: University of Michigan
  2178.  
  2179. I'm interested in putting up a menu on the right side of the
  2180. menubar, much like the Balloon help and Application menus.
  2181. Who knows how to do this?  (I saw this information posted a
  2182. while ago but didn't retain it.)  Thanks!
  2183.  
  2184. Robert
  2185. rjc@umich.edu
  2186.  
  2187.  
  2188. +++++++++++++++++++++++++++
  2189.  
  2190. >From gurgle@netcom.com (Pete Gontier)
  2191. Date: Wed, 6 Apr 1994 18:42:39 GMT
  2192. Organization: cellular
  2193.  
  2194. rjc@terminator.rs.itd.umich.edu (Robert John Churchill) writes:
  2195.  
  2196. >I'm interested in putting up a menu on the right side of the menubar,
  2197. >much like the Balloon help and Application menus. Who knows how to do
  2198. >this? (I saw this information posted a while ago but didn't retain it.)
  2199. >Thanks!
  2200.  
  2201. Eventually I will be releasing an API to do this. It's a lot less
  2202. trivial to do safely than you might think. There's a way to put an
  2203. icon suite in a menu title, and there's an ID range to use, and if you
  2204. really want your menu to behave like one of the system menus, you have
  2205. to insert your menu at the right time. All three of these things are
  2206. separate issues and all three rely on undocumented info. And that's why
  2207. I'll be releasing an API. Look for it soon in a theater near you.
  2208. -- 
  2209.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  2210.  
  2211. +++++++++++++++++++++++++++
  2212.  
  2213. >From Alexander M. Rosenberg <alexr@apple.com>
  2214. Date: Thu, 7 Apr 1994 01:28:38 GMT
  2215. Organization: Hackers Anonymous
  2216.  
  2217. In article <gurgleCnupB4.GEw@netcom.com> Pete Gontier, gurgle@netcom.com
  2218. writes:
  2219. > rjc@terminator.rs.itd.umich.edu (Robert John Churchill) writes:
  2220. > >I'm interested in putting up a menu on the right side of the menubar,
  2221. > >much like the Balloon help and Application menus. Who knows how to do
  2222. > >this? (I saw this information posted a while ago but didn't retain it.)
  2223. > >Thanks!
  2224. > Eventually I will be releasing an API to do this. It's a lot less
  2225. > trivial to do safely than you might think. There's a way to put an
  2226. > icon suite in a menu title, and there's an ID range to use, and if you
  2227. > really want your menu to behave like one of the system menus, you have
  2228. > to insert your menu at the right time. All three of these things are
  2229. > separate issues and all three rely on undocumented info. And that's why
  2230. > I'll be releasing an API. Look for it soon in a theater near you.
  2231.  
  2232. This menu ID range is reserved for use by Apple Computer, per page I-109 of
  2233. Inside Macintosh, Volume 1 and on page 1-47 of Inside Macintosh: More
  2234. Macintosh Toolbox. Both places specifically say "do not use."
  2235.  
  2236. So, how will your "API" serve to somehow magically make using undocumented
  2237. (and "do not use") things acceptable?
  2238. - -------------------------------------------------------------------------
  2239. -  Alexander M. Rosenberg  - INTERNET: alexr@apple.com      - Yoyodyne    -
  2240. -  330 Waverley St., Apt B - UUCP:ucbvax!apple!alexr        - Propulsion  -
  2241. -  Palo Alto, CA 94301     -                                - Systems     -
  2242. -  (415) 329-8463          - Nobody is my employer so       - :-)         -
  2243. -                          - nobody cares what I say.       -             -
  2244.  
  2245. +++++++++++++++++++++++++++
  2246.  
  2247. >From jbrowne@zaphod.ncsa.uiuc.edu (Jim Browne)
  2248. Date: 7 Apr 94 19:33:28 GMT
  2249. Organization: University of Illinois at Urbana
  2250.  
  2251. Alexander M. Rosenberg <alexr@apple.com> writes:
  2252.  
  2253. >So, how will your "API" serve to somehow magically make using undocumented
  2254. >(and "do not use") things acceptable?
  2255.  
  2256. I imagine the API will have checks of the system software version, etc. so it
  2257. can put up a big honkin' "This may not work with your system software, we
  2258. we're puds and used undocumented features.  Apple told us not to, but we
  2259. did it anyway." dialog if the proper hooks aren't available.
  2260.  
  2261. *or*
  2262.  
  2263. They could just get Microsoft to use it in all of their products.  Then Apple
  2264. engineers will do triple back flips to keep it working in the future.
  2265.  
  2266. (I wish people doing these undocumented whatevers would include a statement
  2267.  at the bottom of their posts stating "This will break in the future." so
  2268.  Apple people wouldn't have to spend thier time reminding us.)
  2269.  
  2270. -- 
  2271. Jim Browne                                             | jbrowne@ncsa.uiuc.edu |
  2272. Head NCSA Mac Telnet Hacker, SDG System Administrator  | (217) 244-7798        |
  2273. <a href="http://www.ncsa.uiuc.edu/SDG/People/jbrowne/jbrowne.html">Click me</a>
  2274.  "People can buy HANDGUNS easier." - S. Anichini, on accquiring IMSA yearbooks.
  2275.  
  2276. +++++++++++++++++++++++++++
  2277.  
  2278. >From gurgle@netcom.com (Pete Gontier)
  2279. Date: Fri, 8 Apr 1994 07:24:17 GMT
  2280. Organization: cellular
  2281.  
  2282. Alexander M. Rosenberg <alexr@apple.com> writes:
  2283.  
  2284. >This menu ID range is reserved for use by Apple Computer, per page
  2285. >I-109 of Inside Macintosh, Volume 1 and on page 1-47 of Inside
  2286. >Macintosh: More Macintosh Toolbox. Both places specifically say "do not
  2287. >use." So, how will your "API" serve to somehow magically make using
  2288. >undocumented (and "do not use") things acceptable?
  2289.  
  2290. It won't. It will, however, buy you a couple of other things:
  2291.  
  2292. 1) You won't have to reverse-engineer the information yourself.
  2293. 2) Presumably if it breaks I can fix it without your having to
  2294.    change your program.
  2295.  
  2296. It's not as if I'm going to claim in the documentation that the thing
  2297. is risk-free. However, it *is* better than having 17 people do it 17
  2298. different ways.
  2299.  
  2300. Now calm down. I give you permission to break it into itty bitty pieces
  2301. if you should be in a position to do so. Have fun.
  2302. -- 
  2303.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  2304.  
  2305. +++++++++++++++++++++++++++
  2306.  
  2307. >From Alexander M. Rosenberg <alexr@apple.com>
  2308. Date: Tue, 12 Apr 1994 10:39:58 GMT
  2309. Organization: Hackers Anonymous
  2310.  
  2311. In article <2nq6u9$ivm@terminator.rs.itd.umich.edu> Robert John Churchill,
  2312. rjc@terminator.rs.itd.umich.edu writes:
  2313. > I'm interested in putting up a menu on the right side of the
  2314. > menubar, much like the Balloon help and Application menus.
  2315. > Who knows how to do this?  (I saw this information posted a
  2316. > while ago but didn't retain it.)  Thanks!
  2317.  
  2318. You can't. Apple does not support the creation of "System Menus" by
  2319. third-party applications developers.
  2320.  
  2321. Re-read the "Toolbox Karma" technote if you have any questions.
  2322. - -------------------------------------------------------------------------
  2323. -  Alexander M. Rosenberg  - INTERNET: alexr@apple.com      - Yoyodyne    -
  2324. -  330 Waverley St., Apt B - UUCP:ucbvax!apple!alexr        - Propulsion  -
  2325. -  Palo Alto, CA 94301     -                                - Systems     -
  2326. -  (415) 329-8463          - Nobody is my employer so       - :-)         -
  2327. -                          - nobody cares what I say.       -             -
  2328.  
  2329. +++++++++++++++++++++++++++
  2330.  
  2331. >From zobkiw@datawatch.com (joe zobkiw)
  2332. Date: Wed, 13 Apr 1994 12:31:24 GMT
  2333. Organization: Datawatch Corporation
  2334.  
  2335. In article <1994Apr12.103958.979@gallant.apple.com>, Alexander M. Rosenberg
  2336. <alexr@apple.com> wrote:
  2337.  
  2338. > In article <2nq6u9$ivm@terminator.rs.itd.umich.edu> Robert John Churchill,
  2339. > rjc@terminator.rs.itd.umich.edu writes:
  2340. > > I'm interested in putting up a menu on the right side of the
  2341. > > menubar, much like the Balloon help and Application menus.
  2342. > > Who knows how to do this?  (I saw this information posted a
  2343. > > while ago but didn't retain it.)  Thanks!
  2344. > You can't. Apple does not support the creation of "System Menus" by
  2345. > third-party applications developers.
  2346.  
  2347. Apple might not support it...but...if you can get Microsoft to do it then
  2348. I'll betcha it'll never break in the future. :) There are numerous ways to
  2349. do this...but the important part of one way is...
  2350.  
  2351. - The menu IDs must be within a specific range. Start at -18321 and
  2352. increase (add to) this value until you find a blank space.
  2353. - IM-Text will show you how to put an icon as the title of the menu.
  2354. - Patch GetMenu, when it is called inserting the Balloon Help menu you can
  2355. insert your own menu first. Make sure you don't step on any other menu ids,
  2356. including the Balloon Help menu id.
  2357. - Patch MenuSelect to set up your menu items with the proper checkmarks,
  2358. disabled states, etc...
  2359. - Patch SystemMenu to get selections from your menu.
  2360.  
  2361. This works for a hack I wrote and has yet to break since 7.0. I also know
  2362. for a fact that this mechanism is used in numerous popular shareware and a
  2363. few commercial products.
  2364.  
  2365. ___________________________________________________________
  2366. _/_/_/_/   Joe Zobkiw                                   ,,,
  2367.     _/     Senior Software Engineer                     - -
  2368.   _/       Datawatch Corporation                         L
  2369. _/_/_/_/   zobkiw@datawatch.com                          -
  2370.  
  2371. ---------------------------
  2372.  
  2373. >From Joshua Joseph Marks <jmb1+@andrew.cmu.edu>
  2374. Subject: free vs. DisposPtr??
  2375. Date: Mon,  4 Apr 1994 01:48:44 -0400
  2376. Organization: Junior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  2377.  
  2378. Being new to the mac game I'm still frustrated by the Mac included vs
  2379. ASCI ways of handling memory.  If I use NewPtr to allocate a given
  2380. structure, should I use DisposPtr to deallocate it?  Im using THINK C
  2381. 6.0 and when I use DisposPtr nothing seems to happen.  I call it:
  2382.  
  2383.     some_struct *my_struct;
  2384.  
  2385.     my_struct = (some_struct *) NewPtr (sizeof(some_struct));
  2386.     DisposPtr ((Ptr) my_struct);
  2387.  
  2388.     if I use the debugger and check out the value of *my_struct, what should I
  2389.     see?  Is this the right way to go about things?
  2390.  
  2391. +++++++++++++++++++++++++++
  2392.  
  2393. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  2394. Date: Mon, 4 Apr 1994 13:43:27 GMT
  2395. Organization: DCRT, NIH, Bethesda, MD
  2396.  
  2397. In article <Ehbucwm00WBNE7_2FN@andrew.cmu.edu>, Joshua Joseph Marks <jmb1+@andrew.cmu.edu> writes:
  2398. >
  2399. >Being new to the mac game I'm still frustrated by the Mac included vs
  2400. >ASCI ways of handling memory.  If I use NewPtr to allocate a given
  2401. >structure, should I use DisposPtr to deallocate it?  Im using THINK C
  2402. >6.0 and when I use DisposPtr nothing seems to happen.  I call it:
  2403. >
  2404. >    some_struct *my_struct;
  2405. >
  2406. >    my_struct = (some_struct *) NewPtr (sizeof(some_struct));
  2407. >    DisposPtr ((Ptr) my_struct);
  2408. >
  2409. >    if I use the debugger and check out the value of *my_struct, what should I
  2410. >    see?  Is this the right way to go about things?
  2411.  
  2412. You shouldn't see anything.  You haven't *changed* the block pointed to
  2413. by my_struct; you've just told the OS to consider that chunk of memory as
  2414. available.
  2415.  
  2416. NewPtr() is *exactly* like malloc(), and DisposePtr() is *exactly* like
  2417. free(), for most purposes.  Just as you must use free() to deallocate a
  2418. block obtained from malloc(), you must use DisposePtr() to deallocate a
  2419. block that you got via NewPtr().
  2420.  
  2421. In general, you oughtn't mix malloc() allocation with NewPtr() allocation;
  2422. they work differently (malloc() isn't part of the OS!), and so you can get
  2423. memory fragmentation problems if you mix them.  I personally never use
  2424. malloc(); if I have to port something large that uses it, I just use
  2425. #define malloc(x) NewPtr(x) to override it, or do a global search-and-
  2426. replace.
  2427.  
  2428. The actual mechanisms of how allocation is handled, as far as the programmer
  2429. is concerned, is just like the ANSI-defined library functions.
  2430.  
  2431. - -------------------------------------------------------------------
  2432. Christopher Tate             |   "Blue ice cubes?  How degenerate!"
  2433. MSD, Inc.                    |
  2434. fixer@faxcsl.dcrt.nih.gov    |    < anybody recognize the source? >
  2435.  
  2436. +++++++++++++++++++++++++++
  2437.  
  2438. >From scott.m.silver@dartmouth.edu (Scott M. Silver)
  2439. Date: 4 Apr 1994 15:08:21 GMT
  2440. Organization: Dartmouth College - Hanover, NH
  2441.  
  2442. In article <1994Apr4.134327.2777@alw.nih.gov>
  2443. fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate) writes:
  2444.  
  2445. > In general, you oughtn't mix malloc() allocation with NewPtr() allocation;
  2446. > they work differently (malloc() isn't part of the OS!), and so you can get
  2447. > memory fragmentation problems if you mix them.  I personally never use
  2448. > malloc(); if I have to port something large that uses it, I just use
  2449. > #define malloc(x) NewPtr(x) to override it, or do a global search-and-
  2450. > replace.
  2451.  
  2452. Be very careful not to use a NewPtr() call and then use a free() to
  2453. dispose it.  Like Chris said, malloc is considered a private
  2454. implementation, and free is simply its complement.  Although you still
  2455. can get memory fragmentation problems when using either NewPtr or
  2456. malloc.
  2457.  
  2458. To summarize:
  2459. NewPtr begat DisposePtr
  2460. malloc begat free
  2461.  
  2462. Scott
  2463. ____________________________________________________________________
  2464. Scott Silver            Dartmouth College                Hanover, NH
  2465.  
  2466. +++++++++++++++++++++++++++
  2467.  
  2468. >From dsquirre@reed.edu (Douglas Squirrel)
  2469. Date: 5 Apr 1994 08:39:08 GMT
  2470. Organization: Reed College,  Portland, Oregon
  2471.  
  2472. >NewPtr() is *exactly* like malloc(), and DisposePtr() is *exactly* like
  2473. >free(), for most purposes.
  2474.  
  2475. 1. How *does* NewPtr() work?  Does it just do a NewHandle() and then HLock()
  2476.     it, and if so, doesn't this cause heap problems?
  2477.  
  2478. 2. When is NewPtr() *not* exactly like malloc()?
  2479.  
  2480. I don't pretend to understand memory management on the Mac, so non-technical
  2481. replies would be appreciated.
  2482.  
  2483. --dsquirre@reed.edu
  2484.  
  2485. +++++++++++++++++++++++++++
  2486.  
  2487. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  2488. Date: Tue, 5 Apr 1994 13:28:10 GMT
  2489. Organization: DCRT, NIH, Bethesda, MD
  2490.  
  2491. In article <2nr83c$3cc@scratchy.reed.edu>, dsquirre@reed.edu (Douglas Squirrel) writes:
  2492. > Chris Tate wrote:
  2493. >
  2494. >> NewPtr() is *exactly* like malloc(), and DisposePtr() is *exactly* like
  2495. >> free(), for most purposes.
  2496. >
  2497. >1. How *does* NewPtr() work?  Does it just do a NewHandle() and then HLock()
  2498. >    it, and if so, doesn't this cause heap problems?
  2499. >
  2500. >2. When is NewPtr() *not* exactly like malloc()?
  2501.  
  2502. NewPtr() is the native OS routine for allocating a block of memory.  It
  2503. finds a block of the appropriate size, marks it internally as being
  2504. "allocated," and returns a pointer to it for the program to use.  It
  2505. doesn't go through NewHandle().
  2506.  
  2507. malloc() and NewPtr() are different in that NewPtr() directly calls the OS's
  2508. memory management.  In particular, the OS keeps track of what parts of
  2509. memory are allocated or not.  malloc(), on the other hand, is a library
  2510. routine.  This means that the compiler writers created their own set of
  2511. routines for determining what memory is to be considered "allocated" or
  2512. not.
  2513.  
  2514. In its simplest form, malloc() could simply call NewPtr() directly, and
  2515. that would be that.  However, under many implementations of the C libraries,
  2516. malloc() works differently.  Under THINK C, for example, malloc() allocates
  2517. "chunks" much larger than your requested allocation, and manages "sub-blocks"
  2518. within those chunks itself.  So, if you malloc() three smallish objects,
  2519. you might actually find yourself with three pointers, all of which point
  2520. somewhere inside a single "chunk" that the malloc() library obtained from
  2521. the OS by calling NewPtr().
  2522.  
  2523. Practically speaking, the major issue that differs between using NewPtr()
  2524. and using malloc() is that with some compilers, when you use malloc(),
  2525. you can never actually reclaim *all* of the space you allocate.  The
  2526. library may not give the "chunks" back to the OS.  You can still malloc()
  2527. memory out of them (since the malloc() library still knows about them),
  2528. but the rest of the OS will never be able to access that memory.
  2529.  
  2530. Sometimes malloc() can be better; in particular, this "chunk"-based
  2531. mechanism, in which malloc() does its own free-block tracking, can be
  2532. rather faster than NewPtr().  But, as I said, it does have its drawbacks
  2533. as well.
  2534.  
  2535. - -------------------------------------------------------------------
  2536. Christopher Tate             |   "Blue ice cubes?  How degenerate!"
  2537. MSD, Inc.                    |
  2538. fixer@faxcsl.dcrt.nih.gov    |    < anybody recognize the source? >
  2539.  
  2540. +++++++++++++++++++++++++++
  2541.  
  2542. >From jwbaxter@olympus.net (John W. Baxter)
  2543. Date: Tue, 05 Apr 1994 08:25:59 -0700
  2544. Organization: Internet for the Olympic Peninsula
  2545.  
  2546. In article <2nr83c$3cc@scratchy.reed.edu>, dsquirre@reed.edu (Douglas
  2547. Squirrel) wrote:
  2548.  
  2549. > 1. How *does* NewPtr() work?  Does it just do a NewHandle() and then HLock()
  2550. >     it, and if so, doesn't this cause heap problems?
  2551.  
  2552. No...NewPtr () works quite hard to position the newly-allocated block as
  2553. low in the heap as possible, shoving relocatable blocks upwards to
  2554. accomplish that.  [You should have as few locked handles in arbitrary
  2555. locations about the heap as possible before calling NewPtr (), or proper
  2556. placement of the new non-relocatable block may not be possible.]
  2557.  
  2558. If the block you allocate is never going to move, use NewPtr ().  If it's
  2559. going to be relocatable but locked for longish periods, it's best (but not
  2560. ideal) to move it high on the heap before locking it.  Other locks should
  2561. be left in place for the shortest rational periods you can.
  2562.  
  2563. The above is all well described in Inside Macintosh:  Memory.  The
  2564. relationship with malloc () and free () isn't, since that's up to the
  2565. compiler implementors, who should do an equally good job of describing
  2566. their implementation.
  2567.  
  2568. -- 
  2569. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  2570.    jwbaxter@pt.olympus.net
  2571.  
  2572. +++++++++++++++++++++++++++
  2573.  
  2574. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  2575. Date: Thu, 7 Apr 1994 19:24:26 GMT
  2576. Organization: Apple Computer
  2577.  
  2578. fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate) writes:
  2579. > In general, you oughtn't mix malloc() allocation with NewPtr() allocation;
  2580. > they work differently (malloc() isn't part of the OS!), and so you can get
  2581. > memory fragmentation problems if you mix them.  I personally never use
  2582. > malloc(); if I have to port something large that uses it, I just use
  2583. > #define malloc(x) NewPtr(x) to override it, or do a global search-and-
  2584. > replace.
  2585.  
  2586. BAD idea! All the Mac implementations of malloc that I've seen are much more
  2587. efficient than NewPtr, in that they usually don't make trap calls or move
  2588. memory. (They get memory from NewPtr in large chunks and then parcel out that
  2589. memory bit by bit on every malloc call.) Their algorithms are also simpler
  2590. and faster because they don't have to deal with relocatable blocks.
  2591.  
  2592. Malloc also reduces heap fragmentation in that memory returned by free is
  2593. kept inside a Mac memory manager block until it's re-used by malloc, so the
  2594. MM doesn't try anything dumb like allocating a handle inside the unused space.
  2595.  
  2596. If you have stuff with both malloc and NewPtr calls I'd suggest replacing
  2597. NewPtr with malloc, not the other way 'round.
  2598.  
  2599. --Jens Alfke
  2600.   jens_alfke@powertalk              Rebel girl, rebel girl,
  2601.             .apple.com              Rebel girl you are the queen of my world
  2602.  
  2603. +++++++++++++++++++++++++++
  2604.  
  2605. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  2606. Date: Fri, 8 Apr 1994 11:50:19 GMT
  2607. Organization: DCRT, NIH, Bethesda, MD
  2608.  
  2609. In article <1994Apr7.192426.5155@gallant.apple.com>, Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  2610. >fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate) writes:
  2611. >> In general, you oughtn't mix malloc() allocation with NewPtr() allocation;
  2612. >> they work differently (malloc() isn't part of the OS!), and so you can get
  2613. >> memory fragmentation problems if you mix them.  I personally never use
  2614. >> malloc(); if I have to port something large that uses it, I just use
  2615. >> #define malloc(x) NewPtr(x) to override it, or do a global search-and-
  2616. >> replace.
  2617. >
  2618. >BAD idea! All the Mac implementations of malloc that I've seen are much more
  2619. >efficient than NewPtr, in that they usually don't make trap calls or move
  2620. >memory. (They get memory from NewPtr in large chunks and then parcel out that
  2621. >memory bit by bit on every malloc call.) Their algorithms are also simpler
  2622. >and faster because they don't have to deal with relocatable blocks.
  2623.  
  2624. Except that you can *never* recover memory allocated via malloc(), at least
  2625. under THINK C.  It's permanently part of the malloc() pool.  Also, malloc()
  2626. won't allocate pools of more than a certain size, and so anything bigger
  2627. than that will be allocated via a native NewPtr() call.  Fragmentation
  2628. in this case is just like using NewPtr() exclusively - actually worse,
  2629. since the permanent malloc() pools get in the way.
  2630.  
  2631. I would probably recommend thus:  if most of the memory allocation 
  2632. you do is via malloc() (i.e. is not done for use by the OS), then it's
  2633. probably better to go ahead and use the library malloc() function.
  2634. However, if you need to allocate OS-style memory in large part as well,
  2635. you will probably make fragmentation worse by using malloc() instead
  2636. of only NewPtr().
  2637.  
  2638. Offhand, I can think of a couple of ways to improve the library malloc().
  2639. One is to deallocate empty pools (which would avoid the problem of having
  2640. residual blocks permanently mucking up the heap).  Another might be to
  2641. have the pools allocated as *handles*, and locked whenever there is an
  2642. allocated sub-block.  When the last sub-block in the pool is free()'d,
  2643. unlock the pool handle and let it float until another allocation is
  2644. needed (then maybe move it high?  all sorts of possibilities here...).
  2645.  
  2646. - -------------------------------------------------------------------
  2647. Christopher Tate             |   "Blue ice cubes?  How degenerate!"
  2648. MSD, Inc.                    |
  2649. fixer@faxcsl.dcrt.nih.gov    |    < anybody recognize the source? >
  2650.  
  2651. +++++++++++++++++++++++++++
  2652.  
  2653. >From dsquirre@reed.edu (Douglas Squirrel)
  2654. Date: 9 Apr 1994 09:52:19 GMT
  2655. Organization: Reed College,  Portland, Oregon
  2656.  
  2657. I tried changing all my mallocs to NewPtrs and frees to DisposPtrs.
  2658.  
  2659. And my application runs ten times slower!!!
  2660.  
  2661. It is a fairly simple text viewer, with the text represented as a linked list 
  2662. of lines terminated by newlines.  So it dynamically allocates space for each
  2663. line as it reads it from the disk.
  2664.  
  2665. Why did this happen?
  2666. --dsquirre@reed.edu
  2667.  
  2668. +++++++++++++++++++++++++++
  2669.  
  2670. >From Reid Ellis <rae@alias.com>
  2671. Date: Wed, 13 Apr 1994 04:04:26 GMT
  2672. Organization: Alias Research, Inc., Toronto ON Canada
  2673.  
  2674. Douglas Squirrel <dsquirre@reed.edu> writes:
  2675. |I tried changing all my mallocs to NewPtrs and frees to DisposPtrs.
  2676. |
  2677. |And my application runs ten times slower!!!
  2678. [...]
  2679. |Why did this happen?
  2680.  
  2681. Because malloc() and free() were optimizing memory allocation for you.
  2682. NewPtr() and DisposPtr() are notoriously slow [on 68k Macintoshes].
  2683. This is one reason there is a "Modern Memory Manager" on the
  2684. PowerPC's.
  2685.  
  2686. Reid
  2687. --
  2688. - -
  2689. Reid Ellis, Alias Research Inc.
  2690. +1 416 362 9181 <rae@Alias.com>
  2691.  
  2692. ---------------------------
  2693.  
  2694. End of C.S.M.P. Digest
  2695. **********************
  2696.  
  2697.  
  2698.