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

  1. C.S.M.P. Digest             Mon, 07 Nov 94       Volume 3 : Issue 66
  2.  
  3. Today's Topics:
  4.  
  5.         #defines by the compiler (CodeWarrior)
  6.         Announcement: New Mac C++ Programming Book Available
  7.         Apple Guide:  Styled text FUBAR
  8.         Basic GWorlds and QuickDraw Newbie
  9.         CW & Code Resources -- poor?
  10.         Desktop Pictures
  11.         Drag-and-drop to cdev window?
  12.         Fastest way to fill memory with a given value?
  13.         Gestalt Selectors List 2.6
  14.         Global storage in code resources
  15.         How to execute MPW tools without MPW
  16.         MacTCP Completion Routines & Async Nofification
  17.         Memory Management within the Real World
  18.         NewGWorld returns null pointer
  19.         Pathnames? I don't think so...
  20.         Q: Creating Variable sized structures?
  21.         QuickTime + MIDI?
  22.         Software volume locking: HELP!
  23.         Some string routines for the PowerPC
  24.         Tech Notes on the World Wide Web, and History Is Made
  25.  
  26.  
  27.  
  28. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  29. (pottier@clipper.ens.fr).
  30.  
  31. The digest is a collection of article threads from the internet newsgroup
  32. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  33. regularly and want an archive of the discussions.  If you don't know what a
  34. newsgroup is, you probably don't have access to it.  Ask your systems
  35. administrator(s) for details.  If you don't have access to news, you may
  36. still be able to post messages to the group by using a mail server like
  37. anon.penet.fi (mail help@anon.penet.fi for more information).
  38.  
  39. Each issue of the digest contains one or more sets of articles (called
  40. threads), with each set corresponding to a 'discussion' of a particular
  41. subject.  The articles are not edited; all articles included in this digest
  42. are in their original posted form (as received by our news server at
  43. nef.ens.fr).  Article threads are not added to the digest until the last
  44. article added to the thread is at least two weeks old (this is to ensure that
  45. the thread is dead before adding it to the digest).  Article threads that
  46. consist of only one message are generally not included in the digest.
  47.  
  48. The digest is officially distributed by two means, by email and ftp.
  49.  
  50. If you want to receive the digest by mail, send email to listserv@ens.fr
  51. with no subject and one of the following commands as body:
  52.     help                        Sends you a summary of commands
  53.     subscribe csmp-digest Your Name    Adds you to the mailing list
  54.     signoff csmp-digest            Removes you from the list
  55. Once you have subscribed, you will automatically receive each new
  56. issue as it is created.
  57.  
  58. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  59. Questions related to the ftp site should be directed to
  60. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  61. digest are available there.
  62.  
  63. Also, the digests are available to WAIS users.  To search back issues
  64. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  65. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  66.  
  67.  
  68. -------------------------------------------------------
  69.  
  70. >From zobkiw@datawatch.com (joe zobkiw)
  71. Subject: #defines by the compiler (CodeWarrior)
  72. Date: Mon, 17 Oct 1994 13:45:40 GMT
  73. Organization: Datawatch Corporation
  74.  
  75. I have been writing some Aladdin InstallerMaker extensions recently and
  76. have a nice little system that (using two projects and a "switch" in my
  77. main source file) allows me to compile the extension as an application for
  78. easy testing. Then, when I'm done, I can switch projects, switch the
  79. #define switch in my main source file, and compile it as the proper
  80. resource type.
  81.  
  82. My question is, since CodeWarrior doesn't have a nice little "Prefix" type
  83. per-project option like THINK C had, is there another way? It would be
  84. great if the compiler knew what TYPE it was compiling the code as and I
  85. could get at this information in my code. Something like:
  86.  
  87. #ifdef APPL               // APPL is the TYPE of the project
  88.   InitializeMacintoshManagers();
  89. #endif
  90.  
  91. #ifdef IBeg               // IBeg is the RESOURCE TYPE of the project
  92.    SysBeep(0);
  93. #endif
  94.  
  95. Is there another way to accomplish this? Any thoughts?
  96.  
  97. _______________________________________________________ ,,,
  98. Joe Zobkiw                         zobkiw@datawatch.com - -
  99. Senior Software Engineer          Datawatch Corporation  L
  100. ___________ Zeros and Ones will take us there __________ _
  101.  
  102. +++++++++++++++++++++++++++
  103.  
  104. >From mwron@aol.com (MW Ron)
  105. Date: 17 Oct 1994 12:22:03 -0400
  106. Organization: America Online, Inc. (1-800-827-6364)
  107.  
  108. In article <zobkiw-1710940845400001@zobkiw.datawatch.com>,
  109. zobkiw@datawatch.com (joe zobkiw) writes:
  110.  
  111. >>My question is, since CodeWarrior doesn't have a nice little "Prefix"
  112. type per-project option like THINK C had, is there another way? It would
  113. be great if the compiler knew what TYPE it was compiling the code as and I
  114. could get at this information in my code.
  115.  
  116.  
  117. The "Prefix File" option in the Languages Preferences lets you specify
  118. a file that gets automatically prepended to every file. Be default, it is
  119. set to the precompiled header for the Toolbox routines. However, you can
  120. specify your own file.
  121.  
  122. For example, you could specify a Prefix File of  MyPrefix.h, where the
  123. contents of MyPrefix.h was:
  124.  
  125. #include <MacHeaders68K>   // Included precompiled header
  126.             // Define Symbols
  127.  
  128. #ifdef APPL               // APPL is the TYPE of the project
  129.   InitializeMacintoshManagers();
  130. #endif
  131.  
  132. #ifdef IBeg               // IBeg is the RESOURCE TYPE of the project
  133.    SysBeep(0);
  134. #endif
  135.  
  136. Your Prefix File can contain any valid C statements.
  137.  
  138. Ron Liechty
  139. RonL@metrowerks.com
  140. Metrowerks Inc.
  141.  
  142.  
  143.  
  144. ---------------------------
  145.  
  146. >From danparks@aol.com (DanParks)
  147. Subject: Announcement: New Mac C++ Programming Book Available
  148. Date: 15 Oct 1994 16:56:04 -0400
  149. Organization: America Online, Inc. (1-800-827-6364)
  150.  
  151. //******************************************************
  152.    Apologies if this isn't the proper newsgroup for this message.
  153.    I posted it to comp.sys.mac.announce, but it was returned as
  154.          "not acceptable topic for this newsgroup" !!
  155. //******************************************************
  156.  
  157. To All:
  158.  
  159. There's a new Mac programming book now available - "Symantec C++:
  160. Object-Oriented Programming Fundamentals for the Macintosh" by Prima
  161. Publishing. It should be at your bookstore by the time you read this. 
  162.  
  163. "Symantec C++:  Object-Oriented Programming Fundamentals for the
  164. Macintosh"
  165. Dan Parks Sydow
  166. Prima Publishing
  167. ISBN:  1-55958-633-8
  168.  
  169. The book assumes the reader has a knowledge of a higher-level language -
  170. preferably the C language. It also assumes the reader has done at least a
  171. little programming on the Mac. No advanced-level programming skills are
  172. needed, and no previous knowledge of C++ is required.
  173.  
  174. Like my previous Prima book, "Think THINK C", this book comes bundled with
  175. a disk that contains ALL of the source code examples presented in the
  176. book. It also has a tutorial software program that covers the major topics
  177. from the book, from a little different perspective. That program is called
  178. Simulator C++. The purpose of the software is to "bring to life" the
  179. concepts in the book through the use of text, graphics, QuickTime movies,
  180. and on-screen questions and answers.
  181.  
  182. All examples in the book work with Symantec C++ version 6 or version 7.
  183. All examples run on either a 680x0 Mac or a Power Mac. There are a couple
  184. of dozen example programs - most of them short and covering just a single
  185. key topic. But there are also a couple of larger programs that incorporate
  186. many C++/object-oriented programming concepts. Earlier examples stress
  187. basic techniques, later examples stress programming C++ using Macintosh
  188. techniques - writing programs that make use of menus, dialogs, windows,
  189. resources, and graphics.
  190.  
  191. As always, please feel free to send email to me ( addresses shown below)
  192. with any comments/suggestions/kind words/complaints/questions.
  193.  
  194. *Note to CodeWarrior Owners*
  195. If you want to learn C++ programming for the Mac, this book MAY be for
  196. you. You'd have to be willing to skip one chapter of the book, and make
  197. minimal changes to the source code. You CodeWarrior owners shouldn't have
  198. too much trouble adapting the examples to your Metrowerks compiler. You'll
  199. need to create a new project, then add the included source code file to
  200. it. Most source code files need only one or two changes to compile with
  201. CodeWarrior. I'll be posting an errata sheet in this newsgroup next week
  202. for CodeWarrior users. It will detail the changes that need to be made.
  203.  
  204. Internet:  danparks@aol.com
  205. CompuServe:   73747,1401
  206. America Online:  DanParks
  207.  
  208.  
  209. Regards,
  210.  
  211. Dan
  212.  
  213.  
  214.  
  215. +++++++++++++++++++++++++++
  216.  
  217. >From zobkiw@datawatch.com (joe zobkiw)
  218. Date: Mon, 17 Oct 1994 13:38:50 GMT
  219. Organization: Datawatch Corporation
  220.  
  221. In article <37pfl4$t91@newsbf01.news.aol.com>, danparks@aol.com (DanParks)
  222. wrote:
  223.  
  224. > //******************************************************
  225. >    Apologies if this isn't the proper newsgroup for this message.
  226. >    I posted it to comp.sys.mac.announce, but it was returned as
  227. >          "not acceptable topic for this newsgroup" !!
  228. > //******************************************************
  229.  
  230. How could the Macintosh programmers newsgroup not be the right place for
  231. an announcement about a new book about Macintosh programming? :) 
  232.  
  233. This damn info-super-highway has everyone afraid of getting flamed for the
  234. littlest thing, much like most kids in the inner-city are afraid to go to
  235. school because they'll get shot. So what do they do? Skip school and not
  236. post.
  237.  
  238. Dan, it sounds like a good book. Thanks for the info.
  239.  
  240. _______________________________________________________ ,,,
  241. Joe Zobkiw                         zobkiw@datawatch.com - -
  242. Senior Software Engineer          Datawatch Corporation  L
  243. ___________ Zeros and Ones will take us there __________ _
  244.  
  245. ---------------------------
  246.  
  247. >From cwiltgen@mcs.com (Charles Wiltgen)
  248. Subject: Apple Guide:  Styled text FUBAR
  249. Date: Sat, 22 Oct 1994 18:09:26 -0500
  250. Organization: Muso Communications
  251.  
  252. It's a major pain to use styled text in Apple Guide.  Basically, I can't
  253. make any hypertext links stand out because Apple didn't think of including
  254. an "embolden" tag in the dang compiler.
  255.  
  256. What is everyone using to create Apple Guide files with?  SimpleText is
  257. out of the question.  I'd like to use WriteNow, but the GuideMaker crashes
  258. when it tries to read it.
  259.  
  260. Anyone have a solution?
  261.  
  262. -- 
  263. Charles Wiltgen    "Love is a snowmobile racing across the tundra and
  264. cwiltgen@mcs.com    then suddenly it flips over, pinning you underneath.
  265. (INTP)              At night, the ice weasels come." - Nietzsche (Groening)
  266. The Apocalypso!     http://www.mcs.net/~cwiltgen
  267.  
  268. +++++++++++++++++++++++++++
  269.  
  270. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  271. Date: Sun, 23 Oct 1994 11:01:58 +0800
  272. Organization: Department of Computer Science, The University of Western
  273. Australia
  274.  
  275. In article <cwiltgen-2210941809260001@cwiltgen.pr.mcs.net>,
  276. cwiltgen@mcs.com (Charles Wiltgen) wrote:
  277.  
  278. >It's a major pain to use styled text in Apple Guide.  Basically, I can't
  279. >make any hypertext links stand out because Apple didn't think of including
  280. >an "embolden" tag in the dang compiler.
  281.  
  282. Yep, I've found this very annoying too.  I basically gave up on hot text,
  283. at least for the moment.
  284.  
  285. >What is everyone using to create Apple Guide files with?
  286.  
  287. I use TexEdit.  It's a pretty cool shareware styled text editor.  [And
  288. yes, I have sent off my shareware payment.]  Unfortunately there's no XTND
  289. filter for it, so the styles don't move across to AG.
  290.  
  291. >I'd like to use WriteNow, but the GuideMaker crashes
  292. >when it tries to read it.
  293.  
  294. I had *exactly* the same problem.  I think (god forbid) that MS Word might
  295. be a good choice.  As long as you restrict yourself to the core features
  296. it's fairly nice and the XTND filters are likely to be more stable. 
  297. However my hard disk is Microsloth-free, which eliminates this option for
  298. me.
  299.  
  300. Share and Enjoy.
  301. --
  302. Quinn "The Eskimo!"      "I wasn't the one who fired the heat seeking
  303.                           population annihilator out the window!"
  304.  
  305. +++++++++++++++++++++++++++
  306.  
  307. >From cwiltgen@mcs.com (Charles Wiltgen)
  308. Date: Sun, 23 Oct 1994 12:43:14 -0500
  309. Organization: Muso Communications
  310.  
  311. In article <quinn-2310941101580001@mac163.cs.uwa.oz.au>,
  312. quinn@cs.uwa.edu.au (Quinn "The Eskimo!") wrote:
  313.  
  314. > >It's a major pain to use styled text in Apple Guide.  Basically, I can't
  315. > >make any hypertext links stand out because Apple didn't think of including
  316. > >an "embolden" tag in the dang compiler.
  317. > Yep, I've found this very annoying too.  I basically gave up on hot text,
  318. > at least for the moment.
  319.  
  320. That's potentially one of the Best ThingsTM about Apple Guide, and we can't
  321. use it because there's no way to find out what what's hot-clickable.  I'm
  322. going to use Word on one of my smaller files (but I'm afraid!) or go to
  323. some sort of <<click here>> notation for now.
  324.  
  325. > >I'd like to use WriteNow, but the GuideMaker crashes
  326. > >when it tries to read it.
  327. > I had *exactly* the same problem.  I think (god forbid) that MS Word might
  328. > be a good choice.  As long as you restrict yourself to the core features
  329. > it's fairly nice and the XTND filters are likely to be more stable. 
  330. > However my hard disk is Microsloth-free, which eliminates this option for
  331. > me.
  332.  
  333. Thanks for the confirmation.  I got WriteNow for $12.95 when I ordered
  334. something from MacWarehouse (don't tell anyone about this special offer!)
  335. and thought it would be perfect for this.  Alas, it was not to be.
  336.  
  337. C'mon, Apple!  Add those <B>style</B> tags!!!
  338.  
  339. -- 
  340. Charles Wiltgen    "Love is a snowmobile racing across the tundra and
  341. cwiltgen@mcs.com    then suddenly it flips over, pinning you underneath.
  342. (INTP)              At night, the ice weasels come." - Nietzsche (Groening)
  343. The Apocalypso!     http://www.mcs.net/~cwiltgen
  344.  
  345. +++++++++++++++++++++++++++
  346.  
  347. >From cwiltgen@mcs.com (Charles Wiltgen)
  348. Date: Sun, 23 Oct 1994 13:41:56 -0500
  349. Organization: Muso Communications
  350.  
  351. In article <cwiltgen-2310941243140001@cwiltgen.pr.mcs.net>,
  352. cwiltgen@mcs.com (Charles Wiltgen) wrote:
  353.  
  354. > > I think (god forbid) that MS Word might
  355. > > be a good choice.  As long as you restrict yourself to the core features
  356. > > it's fairly nice and the XTND filters are likely to be more stable. 
  357. > > However my hard disk is Microsloth-free, which eliminates this option for
  358. > > me.
  359.  
  360. Nope, Word doesn't work either (although Guide reads Word files fine).
  361.  
  362. Can someone from Apple help?  I've already started doing my hot words like
  363. 'this$BB...
  364.  
  365. -- 
  366. Charles Wiltgen    "Love is a snowmobile racing across the tundra and
  367. cwiltgen@mcs.com    then suddenly it flips over, pinning you underneath.
  368. (INTP)              At night, the ice weasels come." - Nietzsche (Groening)
  369. The Apocalypso!     http://www.mcs.net/~cwiltgen
  370.  
  371. ---------------------------
  372.  
  373. >From jpo6@po.CWRU.Edu (Jared P. O'neal)
  374. Subject: Basic GWorlds and QuickDraw Newbie
  375. Date: 18 Oct 1994 21:28:47 GMT
  376. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  377.  
  378.  
  379. I've created a GWorld, at least I think I have.  Then, I used the
  380. GetGWorldPixMap() call to get the handle of the PixMap.  All I wanted to do
  381. was
  382. use CopyBits to take a picture I had put into the GWorld w/ DrawPicture onto
  383. a
  384. window I had created, but when I tried it, it didn't copy anything into the 
  385. window.  When I tried to debug it (just how do you debug a GWorld), I noticed
  386. that the baseaddr was 0, which doesn't seem right.  Is there anything I did 
  387. wrong here?  (I left out the error handling stuff)
  388.  
  389. GetGWorld(&origPort, &origDev);
  390.     myErr = NewGWorld(&myGWorldPtr, 0, &myRect, nil, nil, 0);
  391.     SetGWorld(myGWorldPtr, nil);
  392.     myPixMapHnd = GetGWorldPixMap(myGWorldPtr);
  393.     good = LockPixels(myPixMapHnd);
  394.     wndoRect = myGWorldPtr->portRect;
  395.     EraseRect(&wndoRect);
  396.  
  397. if (PictID != 0)
  398.     {
  399.         myPic = GetPicture(PictID);
  400.         DrawPicture(myPic, &myRect);
  401.     }
  402.     
  403.     SetGWorld(origPort, origDev);
  404.     
  405.     SetPort(wp);
  406.     
  407. CopyBits((BitMap *)*myPixMapHnd, (BitMap *)wp, &wndoRect, &(wp->portRect), 0,
  408. nil);
  409.  
  410. where wp is the WindowPtr of the destination window.
  411.  
  412. --Jared
  413. -- 
  414. Philosophy:  Master the colonel's secret blend of herbs & spices and all the 
  415. secrets of the universe will be yours!?!
  416.  
  417. Jared O'Neal aka jpo6@po.cwru.edu or oneale@ucsub.colorado.edu or
  418. JaredO@aol.co
  419.  
  420. +++++++++++++++++++++++++++
  421.  
  422. >From first.ascent@mindlink.bc.ca (Alex Curylo)
  423. Date: 19 Oct 1994 07:43:58 GMT
  424. Organization: First Ascent
  425.  
  426. In article <381emf$d5d@usenet.INS.CWRU.Edu>
  427. jpo6@po.CWRU.Edu (Jared P. O'neal) writes:
  428.  
  429. > Is there anything I did wrong here?
  430. >CopyBits((BitMap *)*myPixMapHnd, (BitMap *)wp, &wndoRect, &(wp->portRect),
  431. 0, nil);
  432.  
  433. Yes. (BitMap *)*myPixMapHnd is wrong. Changing that to
  434. &((GrafPtr)myGWorldPtr)->portBits should make it work just fine. And
  435. (BitMap*)wp is wrong too. You want &((GrafPtr)wp)->portBits.
  436.  
  437. +++++++++++++++++++++++++++
  438.  
  439. >From gbolsinga@aol.com (GBolsinga)
  440. Date: 19 Oct 1994 15:24:02 -0400
  441. Organization: America Online, Inc. (1-800-827-6364)
  442.  
  443. In article <382inu$idq@deep.rsoft.bc.ca>, first.ascent@mindlink.bc.ca
  444. (Alex Curylo) writes:
  445.  
  446. >Yes. (BitMap *)*myPixMapHnd is wrong. Changing that to
  447. >&((GrafPtr)myGWorldPtr)->portBits should make it work just fine. And
  448.  
  449. This is wrong! To quote NIM: Imaging With QuickDraw:
  450. "To ensure compatibility on systems running basic QuickDraw instead of
  451. Color Quickdraw, use GetGWorldPixMap whenever you need to gain
  452. access to the bitmap created for a graphics world--that is, do NOT 
  453. dereference the GWorldPtr record for that graphics world."
  454.  
  455. The funny thing is, all the code samples for CopyBIts in the book that I
  456. saw do the WRONG thing.  So many manuals, so little time... :)
  457.  
  458. The problem is with the second (destination) Bitmap: change it to:
  459.  
  460. &((GrafPtr)wp)->portBits
  461.  
  462. and thing should be fine.
  463.  
  464. Greg Bolsinga
  465. MPI Multimedia
  466.  
  467. +++++++++++++++++++++++++++
  468.  
  469. >From first.ascent@mindlink.bc.ca (Alex Curylo)
  470. Date: 24 Oct 1994 09:15:00 GMT
  471. Organization: First Ascent
  472.  
  473. In article <rac-2110941951310001@intrigue.intrigue.com>
  474. rac@intrigue.com (Robert Coie) writes:
  475.  
  476. > A word of caution about GetGWorldPixMap -- it was severely broken in
  477. > pre-7.0 systems.  I think it grabbed a half word instead of a full 32-bit
  478. > word.  If you are certain to be running on a post-7.0 system,
  479. > GetGWorldPixMap should be OK.  If you are certain that Color QuickDraw is
  480. > present and are concerned about System 6 compatibility, do the direct
  481. > dereference.
  482.  
  483. Yes indeed. Version 1.2, to be exact. Like this:
  484.  
  485.     // GetGWorldPixMap doesn't work in 32CQD 1.2
  486.     gLameCQD = (qdVersion >= gestalt32BitQD) && (qdVersion <
  487. gestalt32BitQD13);
  488.  
  489. // workaround for GetGWorldPixMap bug in CQD 1.2
  490. PixMapHandle OurGetGWorldPixMap(GWorldPtr world)
  491. {
  492.  if (gLameCQD)
  493.      return ((CGrafPtr)world)->portPixMap;
  494.  else
  495.      return GetGWorldPixMap(world);
  496. }
  497.  
  498. But in the particular case of CopyBits,
  499. &((GrafPtr)myGWorldPtr)->portBits really does always work. Up to 7.5,
  500. anyway.
  501.  
  502. ---------------------------
  503.  
  504. >From afrancke@netcom.com (Andrew Francke)
  505. Subject: CW & Code Resources -- poor?
  506. Date: Wed, 12 Oct 1994 03:00:02 GMT
  507. Organization: Netcom Online Communications Services (408-241-9760 login:
  508. guest)
  509.  
  510. After perusing CodeWarrior C for a little Component Manager
  511. development, I've formed the following reactions. Please respond with
  512. the approriate answers.
  513.  
  514. Is it just me, or:
  515.  
  516. * is there no way to create a single-segment code resource that uses
  517.   the MW ANSI libs?
  518.  
  519. * does the faux-segment loader just plain not work when the code
  520.   resource's resource fork isn't open? when there are multiple
  521.   multi-segment resources in the same file?
  522.  
  523. * is there no way to have the following declaration in an MW
  524.   code resource:
  525.  
  526.     char *foo = "bar"
  527.  
  528. If the answer to the first question is "yes," when will MW ship an
  529. intelligent linker? Yes, yes -- it's way better than the
  530. THINK/Symantec linker in its identification of dead code. That doesn't
  531. matter if it's convinced you need multiple segments based on the
  532. *un*stripped code/data size.
  533.  
  534. If the answer to any part of the second question is "yes," when will
  535. MW either: document the secret inner-workings of the multi-segment
  536. glue? Heck, if the answer is *no,* when will MW document it?
  537.  
  538. The third question is based on the fuzzy observation (i.e., I didn't
  539. ATFCO -- adjust the compiler options) that a struct with a char *
  540. member could not be initialized with a static string.
  541.  
  542. Finally -- on an entirely unrelated note -- when will somebody prepare
  543. a runtime library for MPW C-generated .o files that need such fine
  544. symbols as _iob and LDIVU -- that can then be used in MW projects.
  545.  
  546. +++++++++++++++++++++++++++
  547.  
  548. >From isochrome@aol.com (IsoChrome)
  549. Date: 13 Oct 1994 14:10:01 -0400
  550. Organization: America Online, Inc. (1-800-827-6364)
  551.  
  552. In article <afranckeCxJHo3.JD3@netcom.com>, afrancke@netcom.com (Andrew
  553. Francke) writes:
  554.  
  555. > * does the faux-segment loader just plain not work when the code
  556. >  resource's resource fork isn't open? when there are multiple
  557. >  multi-segment resources in the same file?
  558.  
  559. I've had the same problem with CW (we're writing 'cmm ' components). The
  560. component manager seems to cache the component code, so your resource fork
  561. isn't open when you are called. It looks like CW keeps some sort of jump
  562. table information in a separate resource ('cmmx' for 'cmm 's). The kiss of
  563. death is that the resource is loaded before a single line of your code is
  564. executed (to get the address of main maybe?), so there is no way you can
  565. open the resource fork yourself. I've had to punt and compile the 68K
  566. piece in Symantec and the PPC piece in CodeWarrior.
  567.  
  568. John Sarapata
  569.  
  570. +++++++++++++++++++++++++++
  571.  
  572. >From hanrek@cts.com (Mark Hanrek)
  573. Date: Sun, 16 Oct 1994 07:53:44 GMT
  574. Organization: The Information Worskhop
  575.  
  576. In article <afranckeCxJHo3.JD3@netcom.com>, afrancke@netcom.com (Andrew
  577. Francke) wrote:
  578.  
  579. Try posting your question in "comp.sys.mac.programmer.codewarrior" which
  580. you may not have known existed.  It's new, and you may find an answer to
  581. your question already posted, as I remember reading something along these
  582. lines recently.
  583.  
  584. Mark Hanrek
  585.  
  586. +++++++++++++++++++++++++++
  587.  
  588. >From richardb@cocytus.demon.co.uk (Richard Buckle)
  589. Date: Tue, 18 Oct 1994 07:51:57 GMT
  590. Organization: none
  591.  
  592. In article <afranckeCxJHo3.JD3@netcom.com>,
  593. afrancke@netcom.com (Andrew Francke) wrote:
  594.  
  595. >* is there no way to create a single-segment code resource that uses
  596. >  the MW ANSI libs?
  597.  
  598. Not if you want to use any vaguely useful ANSI function, such as pow() or
  599. tolower(). The problem is the dead-code stripping can't see through
  600. libraries.
  601. I've repeatedly suggested that MW sort this out and in the interim either
  602. distribute cut-down ANSI libraries (string.lib, math.lib etc) without
  603. 32-bit links hard-wired in or at the very least distribute a 68020 build. I
  604. have got *nowhere*.
  605.  
  606. >* does the faux-segment loader just plain not work when the code
  607. >  resource's resource fork isn't open? when there are multiple
  608. >  multi-segment resources in the same file?
  609.  
  610. Basically yes. It can also crash horribly if your multi-segment resource is
  611. unlocked between calls to it and moves, as the 32-bit jumps do not get
  612. remade. UnloadA4Seg() does not help. I have asked MW to provide a way to
  613. tell the multi-segment resource to remake its jumps, such as calling
  614. UnloadA4Seg(NULL), but this too has fallen on deaf ears. 
  615. Dammit, I feel strongly I should be entitled to unlock my code resources
  616. between calls to them.
  617. As I have no control over the third party app calling my code resource, I
  618. have been reduced to building a stub single-seg resource that calls the
  619. multi-seg resource, runs it and disposes of it to suit MW's brain-damaged
  620. segmentation scheme. Mail me if you want details.
  621.  
  622. The whole segmentation thing on CodeWarrior *sucks*, on apps as well as
  623. code resources. See a thread by Steve Dorner a while ago for a description
  624. of the pure evil that is the application segment loader under CW.
  625.  
  626. A dreadful shame, as this apart from this huge blind spot MW have a *very*
  627. fine product. Maybe some more net.pressure will do the trick.
  628.  
  629.  
  630. - -----------------------------------------------------
  631. Richard Buckle
  632. richardb@cocytus.demon.co.uk
  633. Using this darned fine NewsHopper thingy.
  634.  
  635.  
  636. +++++++++++++++++++++++++++
  637.  
  638. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  639. Date: Tue, 18 Oct 1994 17:26:12 GMT
  640. Organization: Apple Computer
  641.  
  642. Andrew Francke, afrancke@netcom.com writes:
  643. > * does the faux-segment loader just plain not work when the code
  644. >   resource's resource fork isn't open? when there are multiple
  645. >   multi-segment resources in the same file?
  646.  
  647. I believe it will work as long as you preload and detach the code segments.
  648. The loader obviously can't magically know how to open the resource file to
  649. get the code.
  650.  
  651. > * is there no way to have the following declaration in an MW
  652. >   code resource:
  653. >     char *foo = "bar"
  654.  
  655. Should work fine as long as A4 is set up properly at the time that the global
  656. data is referenced.
  657.  
  658. I've directed follow-ups to c.s.m.p.codewarrior.
  659.  
  660. --Jens Alfke                           jens_alfke@powertalk.apple.com
  661.                    "A man, a plan, a yam, a can of Spam ... Bananama!"
  662.  
  663. +++++++++++++++++++++++++++
  664.  
  665. >From ejr@netcom.com (Erik J. Rogers)
  666. Date: Thu, 20 Oct 1994 01:59:30 GMT
  667. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  668.  
  669. In article <1994Oct18.172612.15440@gallant.apple.com> wrote:
  670. : > * is there no way to have the following declaration in an MW
  671. : >   code resource:
  672. : >     char *foo = "bar"
  673.  
  674. : Should work fine as long as A4 is set up properly at the time that the
  675. global
  676. : data is referenced.
  677.  
  678. Try using:
  679.     char foo[] = "bar";
  680.  
  681. See "ReadMe Second" in WDEF sample of resource samples of CW CD for details.
  682.  
  683. Erik J. Rogers
  684.  
  685. ---------------------------
  686.  
  687. >From jacobowi@crab.rutgers.edu (Howard Jacobowitz)
  688. Subject: Desktop Pictures
  689. Date: 16 Oct 1994 13:34:52 -0400
  690. Organization: Rutgers University
  691.  
  692. I know of at least three INIT/cdev's that replaces the standard
  693. desktop pattern with a PICT.  HOW?!?!?!?!?
  694. I think it involves patching FillCRect/FillCRgn, althoug I've no idea why.
  695.  
  696. +++++++++++++++++++++++++++
  697.  
  698. >From h+@nada.kth.se (Jon W{tte)
  699. Date: Mon, 17 Oct 1994 11:09:43 +0100
  700. Organization: Royal Institute of Something or other
  701.  
  702. In article <37ro7s$5ki@crab.rutgers.edu>,
  703. jacobowi@crab.rutgers.edu (Howard Jacobowitz) wrote:
  704.  
  705. >I know of at least three INIT/cdev's that replaces the standard
  706. >desktop pattern with a PICT.  HOW?!?!?!?!?
  707. >I think it involves patching FillCRect/FillCRgn, althoug I've no idea why.
  708.  
  709. This happens to do that, and also replace SysBeep() with a 
  710. predetermined sound, and also play a sound at startup.
  711.  
  712. This particular feature set was used for freshman education
  713. earlier this year :-)
  714.  
  715. You can make it go faster by creating a GWorld and draw the 
  716. picture into it, and use CopyBits, and also re-create the 
  717. GWorld everytime the color environment changes. Cache the PICT 
  718. to disk when you do, instead of keeping it, too, in memory.
  719.  
  720. Compile with Think C 7
  721.  
  722. //    Note:
  723. //    Build this as an INIT; the resource flags HAVE to be System Heap,
  724. Locked and Preload
  725. //
  726. //    Install two "snd " resources; 4000 for the system beep and 4001 for
  727. the
  728. //    startup sound
  729. //    Both these resources HAVE to have the System Heap and Locked bits
  730. set;
  731. //    it helps if they also have the Preload bit set (in Resource info in
  732. ResEdit)
  733. //
  734. //    Install a PICT resource; ID 4000. This PICT HAS to have the System
  735. Heap and Locked
  736. //    bits set; it helps with the Preload bit as well (in Resource info in
  737. ResEdit)
  738. //    This PICT will be drawn in the background (on the desktop) - note
  739. that the PICT
  740. //    has to be rectangular (square) and the same size as your screen(s) to
  741. look best.
  742. //
  743. //    Screen sizes are:
  744. //    PowerBook        640x400
  745. //    13"/14"            640x480
  746. //    15" portrait    640x870
  747. //    16"/17"            832x624
  748. //    19"                1024x768
  749. //    19"/21"            1182x870
  750. //
  751. //    (c)1994 Jon W$E4tte    h+@nada.kth.se
  752.  
  753.  
  754. #include <SetupA4.h>
  755. #include <Traps.h>
  756. #include <Sound.h>
  757.  
  758.  
  759. Handle theBeep = NULL ;
  760.  
  761. static pascal void
  762. DoBeep ( short time )
  763. {
  764.     SetUpA4();
  765.     if ( theBeep ) {
  766.         SndPlay ( NULL , theBeep , false ) ;
  767.     }
  768.     RestoreA4();
  769. }
  770.  
  771.  
  772. static void
  773. PlayStart ( )
  774. {
  775.     Handle h = GetResource ( 'snd ' , 4001 ) ;
  776.     if ( h ) {
  777.         SndPlay ( NULL , h , false ) ;
  778.         ReleaseResource ( h ) ;
  779.     }
  780. }
  781.  
  782.  
  783. pascal void ( * oldFillCRgn ) ( RgnHandle rgn , PixPatHandle pat ) ;
  784.  
  785. PicHandle thePict = NULL ;
  786.  
  787.  
  788. static pascal void
  789. DrawDesk ( RgnHandle rgn , PixPatHandle pat )
  790. {
  791.     SetUpA4 ( ) ;
  792.     if ( ! EmptyRgn ( rgn ) )
  793.     {
  794.         // DeskCPat -- only works on color QD machines
  795.         if ( ( pat == * ( PixPatHandle * ) 0xcd8 ) &&
  796.             ( thePict != NULL ) )
  797.         {
  798.             RgnHandle clip = NewRgn ( ) ;
  799.             RgnHandle temp = NewRgn ( ) ;
  800.             Rect r = ( * * GetGrayRgn ( ) ) . rgnBBox ;
  801.             GetClip ( clip ) ;
  802.             SectRgn ( clip , rgn , temp ) ;
  803.             SetClip ( temp ) ;
  804.             DisposeRgn ( temp ) ;
  805.             if ( r . top > 0 )
  806.                 r . top = 0 ;
  807.             DrawPicture ( thePict , & r ) ;
  808.             SetClip ( clip ) ;
  809.             DisposeRgn ( clip ) ;
  810.         }
  811.         else
  812.         {
  813.             ( * oldFillCRgn ) ( rgn , pat ) ;
  814.         }
  815.     }
  816.     RestoreA4 ( ) ;
  817. }
  818.  
  819.  
  820. main()
  821. {
  822.     // Some glue to safely install ourselves
  823.     asm {
  824.         move.l a0,-(a7)
  825.         dc.w 0xa128 // _RecoverHandle
  826.         move.l a0,-(a7)
  827.         dc.w 0xa992 // _DetachResource
  828.         move.l (a7)+,a0
  829.     }
  830.     RememberA0();
  831.     SetUpA4();
  832.     PlayStart ( ) ;
  833.     if ( ! Button ( ) )
  834.     {
  835.         if ( ( thePict = ( PicHandle ) GetResource ( 'PICT' , 4000 )
  836. ) != NULL )
  837.         {
  838.             DetachResource ( ( Handle ) thePict ) ;
  839.             oldFillCRgn = ( pascal void ( * ) ( RgnHandle ,
  840. PixPatHandle ) ) GetToolTrapAddress ( 0xaa12 ) ;
  841.             SetToolTrapAddress ( ( ProcPtr ) DrawDesk , 0xaa12 )
  842. ;
  843.         }
  844.  
  845.         theBeep = GetResource ( 'snd ' , 4000 ) ;
  846.         if ( theBeep ) {
  847.             DetachResource ( theBeep ) ;
  848.             SetToolTrapAddress ( ( ProcPtr ) DoBeep , 0xA9C8 ) ;
  849. // SysBeep
  850.         }
  851.     }
  852.     RestoreA4();
  853. }
  854.  
  855.  
  856.  
  857. --
  858.   Jon W$E4tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  859.  
  860. "Smart Friends ask no SCSI questions!"
  861.     a Apple employee at the Bash
  862.  
  863.  
  864. ---------------------------
  865.  
  866. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  867. Subject: Drag-and-drop to cdev window?
  868. Date: 10 Oct 94 16:47:53 +1300
  869. Organization: University of Waikato, Hamilton, New Zealand
  870.  
  871. I'm writing this control panel which supports the Drag Manager. I've hit an
  872. odd problem: dragging Finder clipping files to my window doesn't seem to
  873. work.
  874.  
  875. I stepped through my drag-tracking handler with MacsBug, and watched it check
  876. for a PICT item type, by calling GetFlavorDataSize. If there is no PICT type,
  877. I get badDragFlavorErr = -1852, which makes sense. If there _is_ a PICT type,
  878. I get cantGetFlavorErr = -1854 instead.
  879.  
  880. If I drag a PICT item from another application to my control panel window,
  881. it works OK, so I figure a bug in my code is unlikely. :-)
  882.  
  883. Anybody else encountered this? Maybe the problem is that control panels
  884. run in the Finder's context, and its peculiar uses of the Drag Manager don't
  885. allow for this.
  886.  
  887. Any ideas welcomed.
  888.  
  889. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  890. Info & Tech Services Division              fax: +64-7-838-4066
  891. University of Waikato            electric mail: ldo@waikato.ac.nz
  892. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  893.  
  894. +++++++++++++++++++++++++++
  895.  
  896. >From jumplong@aol.com (Jump Long)
  897. Date: 11 Oct 1994 01:03:03 -0400
  898. Organization: America Online, Inc. (1-800-827-6364)
  899.  
  900. In article <1994Oct10.164754.34014@waikato.ac.nz>, ldo@waikato.ac.nz
  901. (Lawrence D'Oliveiro, Waikato University) writes:
  902.  
  903. >I'm writing this control panel which supports the Drag Manager. I've hit
  904. >an odd problem: dragging Finder clipping files to my window doesn't seem
  905. >to work.
  906.  
  907. We had the same report at work and the answer is, it won't work.  I can't
  908. remember the reason why, but Nitin tracked it down.
  909.  
  910. - Jim Luther
  911.  
  912. ---------------------------
  913.  
  914. >From rej@chinook.halcyon.com (Randy Jones)
  915. Subject: Fastest way to fill memory with a given value?
  916. Date: 14 Oct 1994 17:58:54 GMT
  917. Organization: NWNEXUS, Inc. - We Make Internet Easy
  918.  
  919. I want to fill a given block of memory with copies of a long.
  920. I'm guessing there has to be a faster way than a loop which
  921. sets each word in turn.  BlockMove, for example, runs faster
  922. than a copy loop.  But there's no Mac toolbox equivalent of 
  923. memset that I've found.  
  924.  
  925. Are compilers smart enough to turn my loop of word writes into 
  926. something faster, maybe involving the MMU?  If not, then what
  927. am I missing?  Think and/or MetroWerks C, BTW.
  928.  
  929. --Randy Jones
  930.  
  931.  
  932.  
  933. +++++++++++++++++++++++++++
  934.  
  935. >From relmore@halcyon.com (Richard Elmore)
  936. Date: Sat, 15 Oct 1994 01:54:09 -0800
  937. Organization: Northwest Nexus Inc.
  938.  
  939. In article <37mgsu$opv@news.halcyon.com>, rej@chinook.halcyon.com (Randy
  940. Jones) wrote:
  941.  
  942. > I want to fill a given block of memory with copies of a long.
  943. > I'm guessing there has to be a faster way than a loop which
  944. > sets each word in turn.  BlockMove, for example, runs faster
  945. > than a copy loop.  But there's no Mac toolbox equivalent of 
  946. > memset that I've found.  
  947.  
  948. The most common way to speed up mem copy/fill operations is to unroll your
  949. loop.  That is, instead of copying one long word during each iteration of
  950. your loop copy several.  This is in fact the approach taken by
  951. _BlockMove.  Another thing that will make a difference is to make sure all
  952. of your moves are longword aligned (ever notice how Hypercard snaps its
  953. windows an invisible grid on the screen, thats why).
  954.  
  955. -- 
  956. Richard Elmore
  957. relmore@halcyon.com
  958.  
  959. +++++++++++++++++++++++++++
  960.  
  961. >From Arnold Kim <ahk12@columbia.edu>
  962. Date: 16 Oct 1994 20:26:04 GMT
  963. Organization: Nemesis Productions
  964.  
  965. In article <37mgsu$opv@news.halcyon.com> Randy Jones,
  966. rej@chinook.halcyon.com writes:
  967. > I want to fill a given block of memory with copies of a long.
  968. > I'm guessing there has to be a faster way than a loop which
  969. > sets each word in turn.  BlockMove, for example, runs faster
  970. > than a copy loop.  But there's no Mac toolbox equivalent of 
  971. > memset that I've found.  
  972.  
  973. If you want an only-68k solution, then probably the fastest you'll get is
  974. the "movem" command in 68000 assembly.
  975.  
  976. What it does is move the contents of multiple registers into a desired
  977. memory location.... so....
  978.  
  979. initialize all registers as 0x11111111
  980. set a7 as the pointer to where you're writing
  981.  
  982. movem.l  a0-a6/d0-d7,(a7)+
  983.  
  984. that'll blast out 15 longs where (a7) is...
  985.  
  986. (that's probably not the exact syntax, and you'd want to preserve a7,
  987. amongst other things... but that's the gist of it - check a 680x0
  988. assembly book)
  989.  
  990. arnold
  991.  
  992. +++++++++++++++++++++++++++
  993.  
  994. >From resnick@uiuc.edu (Pete Resnick)
  995. Date: Mon, 17 Oct 1994 01:26:18 -0500
  996. Organization: University of Illinois at Urbana-Champaign
  997.  
  998. In article <37s28s$5mi@apakabar.cc.columbia.edu>, Arnold Kim
  999. <ahk12@columbia.edu> wrote:
  1000.  
  1001. > In article <37mgsu$opv@news.halcyon.com> Randy Jones,
  1002. > rej@chinook.halcyon.com writes:
  1003. > > I want to fill a given block of memory with copies of a long.
  1004. > If you want an only-68k solution, then probably the fastest you'll get is
  1005. > the "movem" command in 68000 assembly.
  1006.  
  1007. Yes, both MOVEM, and MOVE16 on 68040's, are very good block move
  1008. instructions. There are lots of ways to use them in creative ways.
  1009.  
  1010. > initialize all registers as 0x11111111
  1011. > set a7 as the pointer to where you're writing
  1012. > movem.l  a0-a6/d0-d7,(a7)+
  1013.  
  1014. Aside from the syntax being bad (you can only work with pre-decrement in
  1015. this mode, not post-increment), even using that would be *very* bad. You
  1016. don't want to use A7 unless you disable interrupts, since any interrupt
  1017. that comes through will allocate space on the stack where A7 currently
  1018. points. If you want to use this method, leave A7 alone completely, move
  1019. the address of the end of the block into one of the other address
  1020. registers, move the value you want into all of the other registers, and
  1021. then do the MOVEM. Here's some sample code I wrote to do a block clear, 52
  1022. bytes at a time (4 bytes per register in 13 registers):
  1023.  
  1024. ; Written in THINK C assembler, so some of the syntax is wierd
  1025. ; Start with the address of block to clear in A0 and the length in D0
  1026.  
  1027.         move.l  d1,-(sp)    ; 12
  1028.         moveq   #0,d1       ;  4
  1029.         adda.l  d0,a0       ;  8
  1030.         cmpa.w  #1,a0       ; 10
  1031.         bcs.s   @0          ;  8/10
  1032.         move.b  d1,-(a0)    ;  8
  1033.         subq.l  #1,d0       ;  8
  1034.     @0  cmpi.l  #160,d0     ; 14
  1035.         blt.s   @5          ; 10/8
  1036.  
  1037.         swap    d0                      ;  4
  1038.         move.w  d0,d1                   ;  4
  1039.         beq.s   @1                      ;  8/10
  1040.         divu.w  #52,d1                  ;144
  1041.         swap    d1                      ;  4
  1042.         move.w  d1,d0                   ;  4
  1043.     @1  swap    d0                      ;  4
  1044.         divu.w  #52,d0                  ;144
  1045.         move.w  d0,d1                   ;  4
  1046.         clr.w   d0                      ;  4
  1047.         swap    d0                      ;  4
  1048.         movem.l d0/d2-d7/a1-a6,-(sp)    ;112
  1049.         move.l  d1,d0                   ;  4
  1050.         moveq   #0,d1                   ;  4
  1051.         move.l  d1,d2                   ;  4
  1052.         move.l  d1,d3                   ;  4
  1053.         move.l  d1,d4                   ;  4
  1054.         move.l  d1,d5                   ;  4
  1055.         move.l  d1,d6                   ;  4
  1056.         move.l  d1,d7                   ;  4
  1057.         move.l  d1,a1                   ;  4
  1058.         move.l  d1,a2                   ;  4
  1059.         move.l  d1,a3                   ;  4
  1060.         move.l  d1,a4                   ;  4
  1061.         move.l  d1,a5                   ;  4
  1062.         move.l  d1,a6                   ;  4
  1063.         bra.s   @4                      ; 10
  1064.     @2  swap    d0                      ;  4
  1065.     @3  movem.l d1-d7/a1-a6,-(a0)       ;112
  1066.     @4  dbra    d0,@3                   ; 14/10
  1067.         swap    d0                      ;  4
  1068.         dbra    d0,@2                   ; 14/10
  1069.         movem.l (sp)+,d0/d2-d7/a1-a6    ;116 = 770
  1070.  
  1071.     @5  bclr    #2,d0       ; 14
  1072.         beq.s   @6          ;  8/10
  1073.         move.w  d1,-(a0)    ;  8
  1074.     @6  addq.b  #1,d0       ;  4
  1075.         lsr.l   #2,d0       ; 12
  1076.         bra.s   @9          ; 10
  1077.     @7  swap    d0          ;  4
  1078.     @8  move.l  d1,-(a0)    ; 12
  1079.     @9  dbra    d0,@8       ; 14/10
  1080.         swap    d0          ;  4
  1081.         dbra    d0,@7       ; 14/10
  1082.         addx.w  d0,d0       ;  4
  1083.         bpl.s   @10         ;  8/10
  1084.         move.b  d1,-(a0)    ;  8
  1085.     @10 move.l  (sp)+,d1    ; 12
  1086.         rts                 ; 16 = 252 +
  1087.  
  1088.  
  1089. pr
  1090. -- 
  1091. Pete Resnick    (...so what is a mojo, and why would one be rising?)
  1092. Doctoral Student - Philosophy Department, Gregory Hall, UIUC
  1093. System manager - Cognitive Science Group, Beckman Institute, UIUC
  1094. Internet: resnick@uiuc.edu
  1095.  
  1096. ---------------------------
  1097.  
  1098. >From rgaros@bio.vu.nl (Rene G.A. Ros)
  1099. Subject: Gestalt Selectors List 2.6
  1100. Date: Wed, 12 Oct 1994 07:53:12 GMT
  1101. Organization: VU Biology, Amsterdam, The Netherlands
  1102.  
  1103. Dear Mac-programmers,
  1104.  
  1105.  
  1106. Today I released version 2.6 of the
  1107.  
  1108.  
  1109.                        Gestalt Selectors List (GSL)
  1110.  
  1111.  
  1112. This list celibrates its second anniversary today.
  1113.  
  1114. It lists all sorts of information about the Gestalt Manager, but mainly
  1115. about selectors and the meaning of the returned values.
  1116. The Gestalt Manager is part of the Apple Macintosh System Software to
  1117. enable programmers to determine the availability of certain software and
  1118. hardware.
  1119.  
  1120. You can obtain the latest version in several ways:
  1121. - by sending an email to the mail archive server:
  1122.       gestalt-selectors-list-request@bio.vu.nl
  1123.   with as subject:
  1124.       archive get recent/gestalt-selectors.etx
  1125.   or to get the compressed version:
  1126.       archive get recent/gestalt-selectors.sit.hqx
  1127.  
  1128. - FTP to the info-mac archives at sumex-aim.stanford.edu and get the file
  1129.       /info-mac/dev/info/gestalt-selectors-26.hqx
  1130.   You can also use any of its mirror sites.
  1131.  
  1132. - World Wide Web
  1133.   The GSL is also available, together with other Macintosh FAQs, at:
  1134.       http://www.astro.nwu.edu/lentz/mac/faqs/source/gestalt.html
  1135.  
  1136. - CompuServe members can find it at the Macintosh Developers Forum
  1137.   (GO MACDEV) in the Tools/Debuggers section.
  1138.  
  1139. - Subscribers of the maillist have received their copy already.
  1140.   If you want to join this list you need to send an email to:
  1141.       gestalt-selectors-list-request@bio.vu.nl
  1142.   with in the subject line 'subscribe'. You will then also receive
  1143.   several updates before the next version is released.
  1144.  
  1145. Please, be aware that it may take a couple of days before the new version
  1146. is available at all these locations. It is available immediatly by using
  1147. the mail archive server.
  1148.  
  1149. Beside a large number of new and changed selectors, these are the major
  1150. changes since the previous version:
  1151.  
  1152. ***************************************************************************
  1153. Added selectors
  1154.   Apple System  : -
  1155.   Apple Add.    : fsm , srta, srtb, ws 1
  1156.   Third Parties : CsWT, FPUE, PPP
  1157. Added unknown
  1158.   Apple Softw.  : diag, jkbd, lang, mtem, ot
  1159.   Third Parties : *DC*, AlaC, Blad, Cafe, FW14, Mgc!, SNIT, SPAL, SPLO
  1160. Changed selectors
  1161.   Apple System  : a/ux, afps, cfrg, csvr, ctbv, cpnt, dplv, dply, easy,
  1162.                   fndr, fs  , gval, hdwr, help, hscd, icon, intd, kbd ,
  1163.                   mach, mbox, proc, qd  , qdrw, sdev, sdvr, snhw, sysv,
  1164.                   vm  , xlat
  1165.   Apple Add.    : cmta, cmtc, gfxa, grfx, ttsc
  1166.   Third Parties : jsm1, SAVR
  1167. Changed unknown
  1168.   Apple Softw.  : aslm, batt, bugx, bugy, dude, dudi, fnda, fnd*, fndc,
  1169.                   port
  1170.   Third Parties : FWCP, ReSp
  1171. Previously unknown
  1172.   Apple System  : scsi
  1173.   Apple Add.    : -
  1174.   Third Parties : Cafe
  1175. Includes updates 2.5.1 up to and including 2.5.10, sent to subscribers of
  1176. the mailing list.
  1177.  
  1178. The new Inside Macintosh Operating System Utilities is available (at least
  1179. electronically) and a few pieces of information in the GSL are corrected or
  1180. added. I see no reason to change the basics for the GSL, new selectors and
  1181. attribute bits will keep appearing as the system software develops...
  1182.  
  1183. The note about the gestaltKeyboardType selector not being installed on
  1184. the PowerMac 7100/66 was triggered by an Usenet posting by Marc Cooperman.
  1185. His observation was confirmed by me because Gestalt! reports of the
  1186. PM 7100/66 indeed do not list this selector, but I never noticed this when
  1187. I received these reports! Other (Power)Macs don't seem to have this
  1188. problem.
  1189.  
  1190. The GSL has been made available by Robert Lentz on a World Wide Web server.
  1191. It now has the latest version and a reference to it is included with the
  1192. 'About This List/Availability' section.
  1193.  
  1194. Included information from the:
  1195.  - Bookmark CD #18,
  1196.  - Bookmark CD #19,
  1197.  - WWDC 1994 CD,
  1198.  - Developer CD Series August 1994 Tool Chest CD and
  1199.  - Developer CD Series September 1994 Reference Library CD.
  1200.  
  1201. Roland Mansson provided the information from the latest Gestalt &
  1202. SysEnvirons TechNote (rev. September 1994). The most important news
  1203. is that the machine ID's will be reused...
  1204.  
  1205. The following selectors are now installed with software included with
  1206. System 7.5 and are moved from the 'Apple Additional Software' to the 'Apple
  1207. System Software' section:
  1208.       ascr, ascv, aucd, cpkr,
  1209.       drag, hscd, icmp, iscd,
  1210.       kpcd, mtcp, qtim, qtrs,
  1211.       scra, sdev, sdvr, snhw,
  1212.       teat, thds, ufox, xlat
  1213. And these from the unknown 'Third Party Software' to the unknown 'Apple
  1214. Software' section:
  1215.       CDJR, HAM , MClk
  1216. ***************************************************************************
  1217.  
  1218.  
  1219. Best regards,
  1220. Rene Ros
  1221. rgaros@bio.vu.nl
  1222.  
  1223. -- 
  1224.   Rene G.A. Ros           rgaros@bio.vu.nl          Amsterdam, The
  1225. Netherlands
  1226. -
  1227. ------------------------------------------------------------------------------
  1228.  
  1229.   English is deliberately designed to frustrate foreigners, you know...
  1230.   (Jeremy Roussak (UK) while trying to explain 'an/a' to me)
  1231.  
  1232. ---------------------------
  1233.  
  1234. >From danmcd@sundance.itd.nrl.navy.mil (Dan McDonald)
  1235. Subject: Global storage in code resources
  1236. Date: 14 Oct 1994 17:13:29 GMT
  1237. Organization: Information Technology Division, Naval Research Laboratory
  1238.  
  1239.  
  1240. With the advent of PowerPC, I'm again confused on something I thought I
  1241. knew.
  1242.  
  1243. I assumed that:
  1244.  
  1245.     * Global variables between procedures in a separate code resource
  1246.       were okay, as long as A4 was set up properly
  1247.  
  1248. If that assumption was wrong, fine.  If it's right, then
  1249.  
  1250.     * How the HELL do you set up A4 in PowerPC code resources?
  1251.  
  1252. I may end up designing my external code modules such that the module asks
  1253. the main program for storage, and the main program delivers, and
  1254. subsequently sends pointers to it whenever the code in the module is called.
  1255.  
  1256. Any comments, hints, death threats, etc. are vastly appreciated.
  1257. -- 
  1258. Daniel L. McDonald | Mail:  danmcd@itd.nrl.navy.mil
  1259. -------------------------+
  1260. Computer Scientist | WWW:   http://wintermute.itd.nrl.navy.mil/danmcd.html  
  1261. |
  1262. Naval Research Lab | Phone: (202) 404-7122        #include <disclaimer.h>   
  1263. |
  1264. Washington, DC     | "Rise from the ashes, A blaze of everyday glory" - Rush
  1265. +
  1266.  
  1267. +++++++++++++++++++++++++++
  1268.  
  1269. >From isis@netcom.com (Mike Cohen)
  1270. Date: Sat, 15 Oct 1994 19:09:29 GMT
  1271. Organization: ISIS International
  1272.  
  1273. In article <37me7q$b40@ra.nrl.navy.mil>, danmcd@sundance.itd.nrl.navy.mil
  1274. (Dan McDonald) wrote:
  1275.  
  1276. > With the advent of PowerPC, I'm again confused on something I thought I
  1277. > knew.
  1278. > I assumed that:
  1279. >         * Global variables between procedures in a separate code resource
  1280. >           were okay, as long as A4 was set up properly
  1281. > If that assumption was wrong, fine.  If it's right, then
  1282. >         * How the HELL do you set up A4 in PowerPC code resources?
  1283. 68K code resources still need to have A4 set up, but you don't have to do
  1284. anything in native code resources. In PPC code, every code fragment
  1285. (including code resources) has its own global space accessible thru the
  1286. RTOC, which a register is always pointing to when that code fragment is
  1287. executing.
  1288.  
  1289. -- 
  1290. Mike Cohen - isis@netcom.com
  1291. NewtonMail, eWorld: MikeC / ALink: D6734 / AOL: MikeC20
  1292. Home Page: ftp://ftp.netcom.com/pub/isis/home.html
  1293.  
  1294. ---------------------------
  1295.  
  1296. >From zack@netcom.com (Zack T. Smith)
  1297. Subject: How to execute MPW tools without MPW
  1298. Date: Wed, 12 Oct 1994 13:58:39 GMT
  1299. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1300.  
  1301. Hi,
  1302.  
  1303. I'd like to find out how I can execute MPW commands without
  1304. having MPW. I know that there is a program available for
  1305. doing this (toolserver), but I don't want to use it.
  1306.  
  1307. I notice that the MPW tool that I have (gcc) contains only code 
  1308. and version resources. I've tried to execute that as a 
  1309. standalone app by changing creator to FNDR and type to APPL, 
  1310. but the program immediately exits.
  1311.  
  1312. Does anyone know why this might be happening, assuming that gcc
  1313. is not buggy. I've tried to inquire with Apple via email, but 
  1314. they won't respond. My guess is that, if gcc had been
  1315. executing properly, it simply didn't find any params to work on,
  1316. so it exited. 
  1317.  
  1318. Would anyone know whether it's necessary to load MPW tools 
  1319. into memory in order to execute them and pass parameters?
  1320.  
  1321. Thanks for any info,
  1322.  
  1323. Zack Smith
  1324.  
  1325.  
  1326. +++++++++++++++++++++++++++
  1327.  
  1328. >From shebs@cygnus.com (Stan Shebs)
  1329. Date: Wed, 12 Oct 1994 18:52:22 GMT
  1330. Organization: /cygint/s1/users/shebs/.organization
  1331.  
  1332.  
  1333. In article <zackCxKC5s.Jnx@netcom.com> zack@netcom.com (Zack T. Smith)
  1334. writes:
  1335.  
  1336.    I notice that the MPW tool that I have (gcc) contains only code 
  1337.    and version resources. I've tried to execute that as a 
  1338.    standalone app by changing creator to FNDR and type to APPL, 
  1339.    but the program immediately exits.
  1340.  
  1341. Uh, MPW GCC requires considerable MPW infrastructure - for one thing,
  1342. it is a collection of tools, for another, it expects to be able to use
  1343. the MPW Assembler.  And where do you plan to get include files and
  1344. libraries?  Changing the file type to get it to run is about like
  1345. working the shift lever on an engineless car - it *might* start
  1346. rolling if you happen to shift into neutral while on a downhill slope...
  1347.  
  1348. MPW GCC needs a full MPW environment in order to be used.  Jonathan
  1349. Kimmitt has hacked up a standalone version, but it has a number of
  1350. limitations (the last time I looked, it couldn't build itself, for
  1351. instance).
  1352.  
  1353.    Does anyone know why this might be happening, assuming that gcc
  1354.    is not buggy. I've tried to inquire with Apple via email, but 
  1355.    they won't respond. My guess is that, if gcc had been
  1356.    executing properly, it simply didn't find any params to work on,
  1357.    so it exited. 
  1358.  
  1359. It's not that "Apple won't respond", it's that there's nobody there
  1360. *to* respond.  MPW GCC is not an Apple product, it was a project I
  1361. did while in Apple's ATG (and as you might guess from the address below,
  1362. I'm no longer there).  If you use it with MPW, it works just fine.
  1363.  
  1364. (For those more knowledgeable who might be wondering, yes Cygnus
  1365. would be willing to do an updated Mac GCC, *if* appropriate funding
  1366. were to be provided - I have no spare time these days :-( )
  1367.  
  1368.                             Stan Shebs
  1369.                             Cygnus Support
  1370.                             shebs@cygnus.com
  1371.  
  1372. +++++++++++++++++++++++++++
  1373.  
  1374. >From jwbaxter@olympus.net (John W. Baxter)
  1375. Date: Wed, 12 Oct 1994 09:52:59 -0700
  1376. Organization: Internet for the Olympic Peninsula
  1377.  
  1378. In article <zackCxKC5s.Jnx@netcom.com>, zack@netcom.com (Zack T. Smith)
  1379. wrote:
  1380.  
  1381. > Hi,
  1382. > I'd like to find out how I can execute MPW commands without
  1383. > having MPW. I know that there is a program available for
  1384. > doing this (toolserver), but I don't want to use it.
  1385. > I notice that the MPW tool that I have (gcc) contains only code 
  1386. > and version resources. I've tried to execute that as a 
  1387. > standalone app by changing creator to FNDR and type to APPL, 
  1388. > but the program immediately exits.
  1389.  
  1390. MPW (and ToolServer) provides a considerable amount of environment in
  1391. which MPW tools operate.  (Including in MPW's case a "foreign file system"
  1392. so that the tool access the current content of a window being edited, when
  1393. it thinks it is opening a file by that name.)
  1394.  
  1395. What you want to do is not impossible (witness Think/Symantec's SARez and
  1396. SADerez, which are apps which provide the needed environment), but more
  1397. trouble than it's worth.
  1398.  
  1399.    --John
  1400.  
  1401. -- 
  1402. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  1403.    Sorry...clever signatures require cleverness, not found here.
  1404.    jwbaxter@pt.olympus.net
  1405.  
  1406. +++++++++++++++++++++++++++
  1407.  
  1408. >From zack@netcom.com (Zack T. Smith)
  1409. Date: Fri, 14 Oct 1994 23:48:09 GMT
  1410. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1411.  
  1412. In article <SHEBS.94Oct12105222@andros.cygnus.com> shebs@cygnus.com (Stan
  1413. Shebs) writes:
  1414. >
  1415. >In article <zackCxKC5s.Jnx@netcom.com> zack@netcom.com (Zack T. Smith)
  1416. writes:
  1417. >
  1418. >   I notice that the MPW tool that I have (gcc) contains only code 
  1419. >   and version resources. I've tried to execute that as a 
  1420. >   standalone app by changing creator to FNDR and type to APPL, 
  1421. >   but the program immediately exits.
  1422. >
  1423. >Uh, MPW GCC requires considerable MPW infrastructure - for one thing,
  1424. >it is a collection of tools, for another, it expects to be able to use
  1425. >the MPW Assembler.  And where do you plan to get include files and
  1426. >libraries?  Changing the file type to get it to run is about like
  1427. >working the shift lever on an engineless car - it *might* start
  1428. >rolling if you happen to shift into neutral while on a downhill slope...
  1429.  
  1430. Libs and header files are available from ftp.apple.com.
  1431.  
  1432. MPW asm can be replaced with GNU asm (gas).
  1433.  
  1434. Much of the "infrastructure" would be provided through my C Shell,
  1435. assuming you mean environment variables, scripting, access to other
  1436. tools.
  1437.  
  1438. >MPW GCC needs a full MPW environment in order to be used.  Jonathan
  1439. >Kimmitt has hacked up a standalone version, but it has a number of
  1440. >limitations (the last time I looked, it couldn't build itself, for
  1441. >instance).
  1442.  
  1443. Has anyone got Kimmit's email address?
  1444.  
  1445. >   Does anyone know why this might be happening, assuming that gcc
  1446. >   is not buggy. I've tried to inquire with Apple via email, but 
  1447. >   they won't respond. My guess is that, if gcc had been
  1448. >   executing properly, it simply didn't find any params to work on,
  1449. >   so it exited. 
  1450. >
  1451. >It's not that "Apple won't respond", it's that there's nobody there
  1452. >*to* respond.  MPW GCC is not an Apple product, it was a project I
  1453. >did while in Apple's ATG (and as you might guess from the address below,
  1454. >I'm no longer there).  If you use it with MPW, it works just fine.
  1455. >
  1456. >(For those more knowledgeable who might be wondering, yes Cygnus
  1457. >would be willing to do an updated Mac GCC, *if* appropriate funding
  1458. >were to be provided - I have no spare time these days :-( )
  1459. >
  1460. >                            Stan Shebs
  1461. >                            Cygnus Support
  1462. >                            shebs@cygnus.com
  1463.  
  1464. Zack Smith
  1465.  
  1466. +++++++++++++++++++++++++++
  1467.  
  1468. >From khatt@shell.portal.com (Judy Ann Kettenhofen)
  1469. Date: 23 Oct 1994 09:04:32 GMT
  1470. Organization: Portal Communications Company -- 408/973-9111 (voice)
  1471. 408/973-8091 (data)
  1472.  
  1473. Zack T. Smith (zack@netcom.com) wrote:
  1474. : In article <SHEBS.94Oct12105222@andros.cygnus.com> shebs@cygnus.com (Stan
  1475. Shebs) writes:
  1476. : >
  1477. : >In article <zackCxKC5s.Jnx@netcom.com> zack@netcom.com (Zack T. Smith)
  1478. writes:
  1479. : >
  1480. : >   I notice that the MPW tool that I have (gcc) contains only code 
  1481. : >   and version resources. I've tried to execute that as a 
  1482. : >   standalone app by changing creator to FNDR and type to APPL, 
  1483. : >   but the program immediately exits.
  1484. : >
  1485. : >Uh, MPW GCC requires considerable MPW infrastructure - for one thing,
  1486. : >it is a collection of tools, for another, it expects to be able to use
  1487. : >the MPW Assembler.  And where do you plan to get include files and
  1488. : >libraries?  Changing the file type to get it to run is about like
  1489. : >working the shift lever on an engineless car - it *might* start
  1490. : >rolling if you happen to shift into neutral while on a downhill slope...
  1491.  
  1492. : Libs and header files are available from ftp.apple.com.
  1493.  
  1494. : MPW asm can be replaced with GNU asm (gas).
  1495.  
  1496. : Much of the "infrastructure" would be provided through my C Shell,
  1497. : assuming you mean environment variables, scripting, access to other
  1498. : tools.
  1499.  
  1500. You just aren't going to be able to run an MPW tool as an app, at
  1501. least very easily.  I suspect it is more trouble than it is worth.
  1502.  
  1503. An MPW tool has some curious code that is executed in the runtime.o
  1504. library.  This code basically hooks up the tools' input/output to
  1505. the Shell's.  You can think of it as almost like a dynamically-linked
  1506. library.  To give you some idea of which routines, do a dumpobj of
  1507. stubs.o, a library generally included when making tools; you'll notice
  1508. that most of these routines are simply empty routines.  They are there
  1509. to make the linker happy; they aren't used other than for that.
  1510.  
  1511. Stubs.o, plus other mechanisms, are used by tools running under the
  1512. Shell to provide the ability, as someone has pointed out, to deal
  1513. with the contents of open (and unsaved) windows.
  1514.  
  1515.  IF you could talk Apple out of telling you *exactly* how
  1516. this works, you might be able to build something around the tool to
  1517. provide those services; but the tool, in and of itself does not
  1518. contain those services.  (Altho', if I recall correctly, someone
  1519. within Apple once made one of the MPW tools so that it was able to
  1520. determine whether it was running as a tool or as an app and do the
  1521. appropriate thing.).
  1522.  
  1523. ==Judy
  1524.  
  1525. --former MPW/ToolServer/Asm Hack.
  1526.  
  1527. ---------------------------
  1528.  
  1529. >From Jon Lipsky <jml16@po.cwru.edu>
  1530. Subject: MacTCP Completion Routines & Async Nofification
  1531. Date: 18 Oct 1994 20:45:22 GMT
  1532. Organization: Case Western Reserve University
  1533.  
  1534. I am having trouble getting async connections working with
  1535. my TCP library I am working on.  I had no problems getting
  1536. syncronous connection to work.
  1537.  
  1538. I was wondering if there were bugs in the TCP header files
  1539. with the Completion Rountine, and Async Notification Routine
  1540. prototypes.  If anyone could help me out, I would appreciate
  1541. it.
  1542.  
  1543. Thanks in advance,
  1544.  
  1545. Jon...
  1546.  
  1547. +++++++++++++++++++++++++++
  1548.  
  1549. >From Aaron Wohl <aw0g+@andrew.cmu.edu>
  1550. Date: Wed, 19 Oct 1994 08:01:07 -0400
  1551. Organization: Systems Group 97, Carnegie Mellon, Pittsburgh, PA
  1552.  
  1553. Excerpts from netnews.comp.sys.mac.programmer: 18-Oct-94 MacTCP
  1554. Completion Routines .. Jon Lipsky@po.cwru.edu (363)
  1555.  
  1556. > I was wondering if there were bugs in the TCP header files
  1557. > with the Completion Rountine, and Async Notification Routine
  1558. > prototypes.  If anyone could help me out, I would appreciate
  1559. > it.
  1560.  
  1561.  
  1562. No none that I know of.   However, the compleation routine is called
  1563. from interrupt level.  If you haven't done this sort of thing before it
  1564. is almost impossible to get it right.    The key items are:
  1565.  
  1566. - be carefull of the registers, like A5 isn't setup so you can't access
  1567. any globals
  1568. - some compilers generate functionc calls off of A5 so you may not be able
  1569. to call anything before A5 is setup.
  1570. - You can't call hardly any of the mac OS system calls.
  1571.  
  1572. For debugging such code take a look on host akutaktak.andrew.cmu.edu
  1573. [128.2.35.1] in /aw0g/softkiss*.*.   There is a debugging printf that
  1574. can be called from hardware interrupt level.  It writes directly to the
  1575. screen memory so you can even call it from a VBL, inside a trap patch
  1576. etc.
  1577.  
  1578. A sample async notification routine:
  1579.  
  1580. /*
  1581.  * handle incomming data or connection drop
  1582.  */
  1583. static pascal void myTCPNotifyProc(StreamPtr tcpStream,
  1584.     unsigned short eventCode,
  1585.     Ptr userDataPtr,
  1586.     unsigned short terminReason,
  1587.     struct ICMPReport *icmpMsg)
  1588. {
  1589.     register tcp_conv_pt acnv=(tcp_conv_pt)userDataPtr;
  1590.  
  1591.     acnv->last_event=eventCode;
  1592.     acnv->service_me=TRUE;
  1593.  
  1594.     switch (eventCode) {
  1595.         case TCPTerminate:
  1596.             acnv->terminating++;
  1597.             break;
  1598.         case TCPClosing:
  1599.             acnv->closing++;
  1600.             break;
  1601.         case TCPULPTimeout:
  1602.             break;
  1603.         case TCPDataArrival:
  1604.             acnv->data_arrived++;
  1605.             break;
  1606.         case TCPUrgent:
  1607.             break;
  1608.         case TCPICMPReceived:
  1609.             break;
  1610.         default:    
  1611.             break;
  1612.         }
  1613. }
  1614.  
  1615. Async compleation routines should similarly be kept very simple.
  1616. Aaron Wohl / ham callsign N3LIW / 412-731-3691 / 412-268-5032
  1617.  
  1618. ---------------------------
  1619.  
  1620. >From jbeeghly@u.washington.edu (Jeff Beeghly)
  1621. Subject: Memory Management within the Real World
  1622. Date: 17 Oct 1994 06:11:53 GMT
  1623. Organization: University of Washington
  1624.  
  1625. Well, the app which I am writing is up to the fully functioning stage, so 
  1626. now I have to tackle those neat real world scenarios .... like gracefully 
  1627. handling error conditions, running under low memory scenarios, etc...   
  1628. and I have several questions on issues which have come up recently.
  1629.  
  1630. 1) Under a low memory condition (~6,000 to 7,000 bytes free) calling the 
  1631. StandardGetFile toolbox call crashes my app.  When I ran my app under the 
  1632. debugger (THINK C ver 6.0) and called my function, my machine locked up 
  1633. (my app didn't even break to the THINK C debugger).  I've tried to narrow 
  1634. down the conditions (for example, in my app I was originally using a 
  1635. custom file open dialog box), but right now I am just using 
  1636. StandardGetFile(0L, -1, 0L, &reply), and when I call this function (e.g. 
  1637. when I select the menu item that calls this function), I'm not calling 
  1638. anything else, so I'm VERY CONFIDENT that it is the system call that is 
  1639. crashing, not something that I have done (I've been working as a 
  1640. professional software tester for several years now.. believe me, I know 
  1641. how to isolate a bug    ;-)  ).
  1642.  
  1643. Is this a known fact?  Does StandardGetFile crash under low memory 
  1644. conditions?  Do I have to do something like the following, just to ensure 
  1645. that my app doesn't crash?
  1646.  
  1647. if(FreeMem() >7000L)
  1648. {
  1649.     StandardGetFile(0L, -1, 0L, &reply);
  1650. }
  1651. else
  1652. {
  1653.     //flash an alert and warn the user
  1654. }
  1655.  
  1656.  
  1657. 2) In one of my dialogs, I am loading four separate pictures (only one 
  1658. picture is displayed at a time) and displaying them to create an 
  1659. 'animation' effect within the dialog (OK.  yes.  it is my about dialog 
  1660. box).  I'm doing something like the following:
  1661.  
  1662. while( !dlgDone )
  1663. {
  1664.     ModalDialog(AboutDlgProc, &dlgItem);
  1665.     dlgDone = (dlgItem == OK_ITEM || dlgItem == CANCEL_ITEM);
  1666. }
  1667.  
  1668. - -----------------------
  1669.  
  1670. pascal Boolean AboutDlgProc(DialogPtr theDialog, EventRecord *e, short *iPtr)
  1671. {
  1672.     static short step = 0;
  1673.  
  1674.     switch( e->what )
  1675.     {
  1676.         case keyDown:
  1677.         case autoKey:
  1678.             .
  1679.             .
  1680.             bla, bla, bla.... the usual
  1681.     }
  1682.  
  1683.     DoAnimation(theDialog, step);
  1684.     step++;
  1685.     if(step >= 4)
  1686.         step = 0;
  1687. }
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693. void DoAnimation(DialogPtr theDialog, short step)
  1694. {
  1695.     PicHandle    pic;
  1696.     Rect        r;
  1697.  
  1698.  
  1699.     switch( step )
  1700.     {
  1701.         case 0:
  1702.             pic = GetPicture(128);
  1703.             break;
  1704.  
  1705.         case 1:
  1706.             pic = GetPicture(129);
  1707.             break;
  1708.  
  1709.         case 2:
  1710.             pic = GetPicture(130);
  1711.             break;
  1712.  
  1713.         case 3:
  1714.             pic = GetPicture(131);
  1715.             break;
  1716.     }
  1717.  
  1718.  
  1719.     if(pic != nil)
  1720.     {
  1721.         HLock( (Handle )pic );
  1722.         SetRect(&r, 20, 40, 20 + 124, 40 + 60);
  1723.         DrawPicture(pic, &r);
  1724.         HUnlock( (Handle )pic);
  1725.     }
  1726. }
  1727.  
  1728. Looks good so far, no?
  1729. Well, the problem is that under a low memory condition (say ~7,000 - 
  1730. 8,000 bytes free), the first picture is loaded and displays fine, but 
  1731. when the second image is loaded, my app crashes (BTW:  each picture is 
  1732. 124 x 60 pixels x 256 colors and ResEdit said each were ~ 4500 bytes large).
  1733.  
  1734. I then went in and added a
  1735.     ReleaseResource( (Handle )pic);
  1736. call after the HUnlock call.  This time, each of the four pictures were 
  1737. loaded (and my app didn't crash), but when the counter turned back to 0, the 
  1738. first pic wasn't displayed.
  1739.  
  1740. I dismissed the dialog box and brought it back up again.  This time, none 
  1741. of the pictures were displayed!  Well, this leads me to believe that when 
  1742. I call ReleaseResource(), it not only frees up the memory of the handle 
  1743. holding the picture, but it clears it from the current resource as well.  
  1744. I then tried to use the DisposeHandle() call in place of the 
  1745. ReleaseResource() call, and the same thing occurred (all four pictures 
  1746. were displayed once and only once).
  1747.  
  1748.  
  1749. At this point, I added following:
  1750.  
  1751. if(pic != nil)
  1752. {
  1753.     .
  1754.     .
  1755.     .
  1756. }
  1757. else
  1758. {
  1759.     MoveTo(20, 20);
  1760.     DrawString("\pCan't open image");
  1761. }
  1762.  
  1763.  
  1764. I was thinking, OK, the problem is there is not enough memory to open the 
  1765. image... that is why my app is crashing... I'll just check to see if the 
  1766. PicHandle is nil.  If it is not nil, I will draw the picture.  If it is 
  1767. nil, I will not draw the pic and continue on.
  1768.  
  1769. When I ran my program and brought up the dialog, the error message never 
  1770. came up!
  1771.  
  1772.  
  1773. So what gives?  I can't load and display the image, yet the pic isn't nil 
  1774. either!?!?!  (btw:  I did this for the case of when I try to release 
  1775. memory (via ReleaseResource or DisposeHandle) and when I don't release 
  1776. the Handle).
  1777.  
  1778.  
  1779.  
  1780. Do I need to do a lot of watch dogging and not let any operations be 
  1781. performed if the app goes beneath 0k of memory is free?
  1782.  
  1783.  
  1784. 3) In Macintosh C Programming Primmer Vol 2, it states that when a 
  1785. program starts, it contains a block of master pointers.  It is within 
  1786. this location that the location of the Handles are kept (64 of them).  If 
  1787. the program requires more than 64, the MoreMasters() call needs to be 
  1788. made (which will create 64 more locations for handles).  What happens if 
  1789. I have filled up all 64 locations with handles, then create another 
  1790. handle (for arguments' sake, let's say that there is enough memory to 
  1791. create the size of the handle, and we create a new handle without 
  1792. calling MoreMasters())?  Will I run the risk of loosing the handle when 
  1793. memory is juggled around?
  1794.  
  1795. 4) In my program, I manage multiple files at the same time (hence, my app 
  1796. manages several windows at the same time).  In each file/window, there 
  1797. are LOTS of different handles (my app displays dozens of icon suites, and 
  1798. each icon suite is a handle).  In fact, if I have a window that is maxed 
  1799. out (each window will hold a maximum amount of 50 icon suites), It would 
  1800. seem that I would almost have to call MoreMasters() each time I 
  1801. create/open a new window (when I create/open a new window, I perform a
  1802. NewHandle( sizeof(data_in_my_window) ) type of call in my program).  Is 
  1803. there a call that REMOVES 64 master pointers?  In other words, I was 
  1804. wondering if there is a way to call MoreMasters() before I create/open a 
  1805. window, and call RemoveMastersFunction() after I close a window?  Yes, I 
  1806. could just add another MoreMasters() call at the begining of my program, 
  1807. but I intend to allow the user to have as many windows/files opened as 
  1808. they want.
  1809.  
  1810. 5) Is there a call that forces the system to compact the fragmented 
  1811. memory of an app?  I 
  1812. remember reading that the system automatically compacts the memory at 
  1813. certain intervals, and I know that there are functions that will compact 
  1814. the memory, so there is a certain amount of memory free (e.g.  
  1815. CompactMem( x ), where x is the number of bytes needed), but is there a 
  1816. call that will force the system to compact as much as possible?
  1817.  
  1818.  
  1819. +++++++++++++++++++++++++++
  1820.  
  1821. >From philip@cs.wits.ac.za (Philip Machanick)
  1822. Date: 17 Oct 1994 12:10:17 GMT
  1823. Organization: Computer Science Dept, U of Witwatersrand
  1824.  
  1825. In article <37t4j9$bq4@nntp1.u.washington.edu>, jbeeghly@u.washington.edu
  1826. (Jeff Beeghly) wrote:
  1827.  
  1828. >         DoAnimation(theDialog, step);
  1829. >         step++;
  1830. >         if(step >= 4)
  1831. >                 step = 0;
  1832. > }
  1833.  
  1834. Just a minor thing - I'll leave the memory management thing for others -
  1835. but if your PICTs are sequentially numbered, why not use the resource ID
  1836. directly, and savve yourself the switch statement? If they aren't
  1837. guaranteed to be sequential, you could still store them in an array which
  1838. would be easier to update than adding another case in the switch.
  1839.  
  1840. > void DoAnimation(DialogPtr theDialog, short step)
  1841. > {
  1842. >         PicHandle       pic;
  1843. >         Rect            r;
  1844. >  
  1845. >  
  1846. >         switch( step )
  1847. >         {
  1848. >                 case 0:
  1849. >                         pic = GetPicture(128);
  1850. >                         break;
  1851. >  
  1852. >                 case 1:
  1853. >                         pic = GetPicture(129);
  1854. >                         break;
  1855.  
  1856. etc.
  1857. -- 
  1858. Philip Machanick                   philip@cs.wits.ac.za
  1859. Department of Computer Science, University of the Witwatersrand
  1860. 2050 Wits, South Africa        (at University of Cape Town 4 July-7 Nov)
  1861. phone 27(11)716-3309  fax 27(11)339-7965
  1862.  
  1863. +++++++++++++++++++++++++++
  1864.  
  1865. >From mhl@icf.hrb.com (MARK H. LINTON)
  1866. Date: 17 Oct 94 13:44:22 EST
  1867. Organization: HRB Systems, Inc.
  1868.  
  1869. In article <37t4j9$bq4@nntp1.u.washington.edu>, jbeeghly@u.washington.edu
  1870. (Jeff Beeghly) writes:
  1871. >  
  1872. > 1) ... Does StandardGetFile crash under low memory conditions?  
  1873. >
  1874.  
  1875.         Sorry, don't know for sure, but I wouldn't be too
  1876.         surprised.
  1877.  
  1878. >  
  1879. > 2) I am loading four separate pictures...
  1880. >  
  1881.  
  1882. void DoAnimation(short step) {
  1883.     PicHandle    pic = GetPicture(128+step);
  1884.      
  1885.     if (pic != nil) DrawPicture(pic, &(**pic).portRect);
  1886. }
  1887.  
  1888. >  
  1889. > Looks good so far, no?
  1890.  
  1891.         Well, no. I would guess this flashes like mad (but if you
  1892.         haven't gotten it to work yet, you wouldn't know that ;^).
  1893.         I would probably load the resources once, image them into
  1894.         offscreen graphics worlds and then just CopyBits in
  1895.         DoAnimation. Lots of sample code available to do this BTW.
  1896.  
  1897. > Well, the problem is that under a low memory condition (say ~7,000 - 
  1898. > 8,000 bytes free), the first picture is loaded and displays fine, but 
  1899. > when the second image is loaded, my app crashes...
  1900.  
  1901.         How do you know how much memory you have free?
  1902.  
  1903. >  
  1904. > I then went in and added a
  1905. >     ReleaseResource( (Handle )pic);
  1906. > This time, each of the four pictures were loaded (and my app didn't crash)
  1907.  
  1908.         This should be a clue... (what has changed? why did that
  1909.         make a difference?... are your PICT resources marked
  1910.         purgeable?)
  1911.  
  1912. > ...but when the counter turned back to 0, the first pic wasn't displayed.
  1913. >  
  1914. > I dismissed the dialog box and brought it back up again.  This time, none 
  1915. > of the pictures were displayed!  Well, this leads me to believe that when 
  1916. > I call ReleaseResource(), it not only frees up the memory of the handle 
  1917. > holding the picture, but it clears it from the current resource as well.  
  1918. > I then tried to use the DisposeHandle() call in place of the 
  1919. > ReleaseResource() call, and the same thing occurred (all four pictures 
  1920. > were displayed once and only once).
  1921. >  
  1922. > At this point, I added following:
  1923. >  
  1924.  if (pic != nil) {
  1925.        ...
  1926.  } else {
  1927. >     MoveTo(20, 20);
  1928. >     DrawString("\pCan't open image");
  1929. > }
  1930. >  
  1931. > the error message never came up!
  1932. >  
  1933. > So what gives?  I can't load and display the image, yet the pic isn't nil 
  1934. > either!?!?!  
  1935. >  
  1936.  
  1937.         There were three statements in that last line.
  1938.  
  1939.         1) I can't load the image
  1940.         2) I can't display the image
  1941.         3) The handle to the image is not nil
  1942.  
  1943.         These can not all be true. GetPicture returns nil if it
  1944.         was unable to load the image. Since you say "the error
  1945.         message never came up" I will assume that 3 is true. This
  1946.         means that 1 must be false. This leaves only 2 as a
  1947.         problem for your application. This is what you must
  1948.         investigate.
  1949.  
  1950.         BTW, have you investigated how QuickDraw reports errors.
  1951.         Given that it appears that this "feature" is occurring in
  1952.         the DrawPicture call, how would you know that it failed?
  1953.         Apart from not being able to see the picture.
  1954.  
  1955. > Do I need to do a lot of watch dogging and not let any operations be 
  1956. > performed if the app goes beneath 0k of memory is free?
  1957. >  
  1958.  
  1959.         You have less than 0k of memory free and expect the
  1960.         program to do something?
  1961.  
  1962.         BTW, just to be a total smart-***, the generally accepted
  1963.         way to handle this type of situation is to:
  1964.  
  1965.         1) Figure out how much memory you application needs.
  1966.         2) Make sure that it gets at least that much.
  1967.  
  1968.         ;^) <--- note the smiley!
  1969.  
  1970. >  
  1971. > 3) In Macintosh C Programming Primmer Vol 2, it states that when a 
  1972. > program starts, it contains a block of master pointers.  It is within 
  1973. > this location that the location of the Handles are kept (64 of them).  If 
  1974. > the program requires more than 64, the MoreMasters() call needs to be 
  1975. > made (which will create 64 more locations for handles).  What happens if 
  1976. > I have filled up all 64 locations with handles, then create another 
  1977. > handle (for arguments' sake, let's say that there is enough memory to 
  1978. > create the size of the handle, and we create a new handle without 
  1979. > calling MoreMasters())?  Will I run the risk of loosing the handle when 
  1980. > memory is juggled around?
  1981. >  
  1982.  
  1983.         If you call NewHandle, and you have no more master
  1984.         pointers available, NewHandle will call MoreMasters for
  1985.         you. The point behind doing it youself is that master
  1986.         pointer blocks are non-relocatable and tend to lead to
  1987.         heap fragmentation. 
  1988.  
  1989.         If you let NewHandle make the call, the master pointer
  1990.         block will be placed as low in the heap as possible.
  1991.         Depending on what you have been doing, you may have
  1992.         relocatable or purgeable structures in heap below that
  1993.         block. If you want to reuse that memory, especially with
  1994.         something that may be larger than the things that
  1995.         previously occupied that space (as seems like you may) you
  1996.         are unable to because you have a master pointer block
  1997.         sitting where you need to put your new structure.
  1998.  
  1999.         Go ahead and call MoreMasters two, three... maybe ten
  2000.         times early in your program. Master pointer blocks are
  2001.         pretty small compared to the space you could loose letting
  2002.         NewHandle do it for you.
  2003.  
  2004. > 4) In my program, I manage multiple files at the same time (hence, my app 
  2005. > manages several windows at the same time).  In each file/window, there 
  2006. > are LOTS of different handles (my app displays dozens of icon suites, and 
  2007. > each icon suite is a handle).  In fact, if I have a window that is maxed 
  2008. > out (each window will hold a maximum amount of 50 icon suites), It would 
  2009. > seem that I would almost have to call MoreMasters() each time I 
  2010. > create/open a new window (when I create/open a new window, I perform a
  2011. > NewHandle( sizeof(data_in_my_window) ) type of call in my program).  
  2012. >
  2013.  
  2014.         that would be a BadThing(r), see above.
  2015.  
  2016. >
  2017. > Is 
  2018. > there a call that REMOVES 64 master pointers?  In other words, I was 
  2019. > wondering if there is a way to call MoreMasters() before I create/open a 
  2020. > window, and call RemoveMastersFunction() after I close a window?  Yes, I 
  2021. > could just add another MoreMasters() call at the begining of my program, 
  2022. > but I intend to allow the user to have as many windows/files opened as 
  2023. > they want.
  2024. >  
  2025.  
  2026.         no, again, see above
  2027.  
  2028. > 5) Is there a call that forces the system to compact the fragmented 
  2029. > memory of an app?  I 
  2030. > remember reading that the system automatically compacts the memory at 
  2031. > certain intervals, and I know that there are functions that will compact 
  2032. > the memory, so there is a certain amount of memory free (e.g.  
  2033. > CompactMem( x ), where x is the number of bytes needed), but is there a 
  2034. > call that will force the system to compact as much as possible?
  2035.  
  2036.         The memory manager has a number of calls in addition to
  2037.         CompactMem (FreeMem and PurgeMem come to mind) but these
  2038.         only help with relocatable and purgeable objects. If your
  2039.         memory is fragmented, it will stay fragmented, these calls
  2040.         only help you use the memory that you have left.
  2041.  
  2042.         From your literary reference above (an excellent starting
  2043.         point, I might add) I assume that you are (fairly) new to
  2044.         Macintosh programming, although from the apparent
  2045.         complexity of your application not to programming in
  2046.         general. Rather than answer you questions with answers, I
  2047.         will answer them with questions and refer you to further
  2048.         reading, so that you can learn the material yourself and
  2049.         not have to ask again next time.
  2050.  
  2051.         (new) Inside Macintosh: Memory - for references to
  2052.         questions about: MoreMasters, NewHandle, CompactMem,
  2053.         PurgeMem, FreeMem, etc.
  2054.  
  2055.         (new) Inside Macintosh: Imaging with QuickDraw - for
  2056.         references to questions about: DrawPicture, GetPicture,
  2057.         etc.
  2058.  
  2059. -- 
  2060. Hope this helps.
  2061.  
  2062. Mark H. Linton
  2063. ____________________________________________________________________
  2064. mark \'m$E4rk\ n [ME, fr. OE mearc boundary, march, sign; akin to OHG
  2065. marha boundary, L margo] 1 a : a conspicuous object serving as a guide
  2066. for travelers 2 : A standard or criterion of quality 3 : An object or
  2067. point that serves as a guide --idiom. mark time. 1 : To make little or
  2068. no progress
  2069.  
  2070. +++++++++++++++++++++++++++
  2071.  
  2072. >From jbeeghly@u.washington.edu (Jeff Beeghly)
  2073. Date: 18 Oct 1994 17:00:33 GMT
  2074. Organization: University of Washington
  2075.  
  2076. mhl@icf.hrb.com (MARK H. LINTON) writes:
  2077.  
  2078. >In article <37t4j9$bq4@nntp1.u.washington.edu>, jbeeghly@u.washington.edu
  2079. (Jeff Beeghly) writes:
  2080. >> 1) ... Does StandardGetFile crash under low memory conditions?
  2081. >        Sorry, don't know for sure, but I wouldn't be too
  2082. >        surprised.
  2083.  
  2084. I've received one reply that stated all standard system calls will most
  2085. likely crash when memory gets too low.  Therefore, in my app, if the
  2086. memory gets below 10k or 12k, I am going to inform the user that there is
  2087. not enough, and that they should close a file.
  2088.  
  2089.  
  2090. >>
  2091. >> 2) I am loading four separate pictures...
  2092. >>
  2093. >void DoAnimation(short step) {
  2094. >    PicHandle    pic = GetPicture(128+step);
  2095. >    if (pic != nil) DrawPicture(pic, &(**pic).portRect);
  2096. >}
  2097.  
  2098. >>
  2099. >> Looks good so far, no?
  2100.  
  2101. >        Well, no. I would guess this flashes like mad (but if you
  2102. >        haven't gotten it to work yet, you wouldn't know that ;^).
  2103. >        I would probably load the resources once, image them into
  2104. >        offscreen graphics worlds and then just CopyBits in
  2105. >        DoAnimation. Lots of sample code available to do this BTW.
  2106.  
  2107. Well, I guess you missed my point.  Yes, the function works
  2108. fine (if there is enough memory available).  For right now, I'm not
  2109. calling my animation at a set interval, so YES, obviously on faster CPUs it
  2110. will be 'FLASHED'.  Yes, I'm am going to put in a timer, so the interval is
  2111. standard from one machine to another.
  2112.  
  2113. I do know how to use CopyBits and off screen GWorlds.  For this portion
  2114. of the code, it is redundant.  Why?  I don't want to permanently 'hold'
  2115. the pictures... all I need is one picture drawn to the screen at a time
  2116. (therefore, I don't feel I need to hold all four).  Holding the bits in
  2117. an offscreen gworld would mean I am using twice the memory for the images:
  2118. one for the resource and one for the offscreen memory
  2119.  
  2120.  
  2121. >> Well, the problem is that under a low memory condition (say ~7,000 -
  2122. >> 8,000 bytes free), the first picture is loaded and displays fine, but
  2123. >> when the second image is loaded, my app crashes...
  2124.  
  2125. >        How do you know how much memory you have free?
  2126.  
  2127. There is a call called FreeMem() which I am using to output the free
  2128. memory.  I am also using a utility called SWATCH (System Watch) which
  2129. graphically & numerically displays the amount of locked used memory,
  2130. moveable used memory, and free memory each app is using.
  2131.  
  2132.  
  2133. >>
  2134. >> I then went in and added a
  2135. >>      ReleaseResource( (Handle )pic);
  2136. >> This time, each of the four pictures were loaded (and my app didn't crash)
  2137.  
  2138. >        This should be a clue... (what has changed? why did that
  2139. >        make a difference?... are your PICT resources marked
  2140. >        purgeable?)
  2141.  
  2142. Yes, it was a clue.  It was telling me that not only the handle was being
  2143. released, but the location of the resource was being released as well.
  2144. That is why I was only able to display each image once (and only once).
  2145. No, I was not marking the pictures within the resource as being
  2146. purgeable, but I am now doing HPurge( (Handle pic ) after the
  2147. DrawPicture call... it works..... better, but it still crashes (better in
  2148. the sence that if I set my app to run with ~ 12k free and call my dialog
  2149. it works, but if memory gets below 6k, it crashes... looks like I will
  2150. definately have to work on this a bit.
  2151.  
  2152. The point I was trying to make was this:
  2153.  
  2154. If I perform a DisposeHandle on a pic handle, how come I am not able to
  2155. load and display the picture a second time?  DisposeHandle should just
  2156. remove the handle, not the resouce, shouldn't it?
  2157.  
  2158. The other point I was trying to make was this:  If I can get the image
  2159. (and pic != nil), how come I am not able to display it?  If GetPicture
  2160. failed, it's supposed to return a 0, yet it doesn't, so what gives?
  2161.  
  2162.  
  2163. >>
  2164. >> At this point, I added following:
  2165. >>
  2166. > if (pic != nil) {
  2167. >       ...
  2168. > } else {
  2169. >>      MoveTo(20, 20);
  2170. >>      DrawString("\pCan't open image");
  2171. >> }
  2172. >>
  2173. >> the error message never came up!
  2174. >>
  2175. >> So what gives?  I can't load and display the image, yet the pic isn't nil
  2176. >> either!?!?!
  2177. >>
  2178.  
  2179. >        There were three statements in that last line.
  2180.  
  2181. >        1) I can't load the image
  2182. >        2) I can't display the image
  2183. >        3) The handle to the image is not nil
  2184.  
  2185. >        These can not all be true. GetPicture returns nil if it
  2186. >        was unable to load the image. Since you say "the error
  2187. >        message never came up" I will assume that 3 is true. This
  2188. >        means that 1 must be false. This leaves only 2 as a
  2189. >        problem for your application. This is what you must
  2190. >        investigate.
  2191.  
  2192. >        BTW, have you investigated how QuickDraw reports errors.
  2193. >        Given that it appears that this "feature" is occurring in
  2194. >        the DrawPicture call, how would you know that it failed?
  2195. >        Apart from not being able to see the picture.
  2196.  
  2197.  
  2198. Yes, I was a bit unclear.  The second time I get the picture, GetPicture 
  2199. does not return a nil, yet I am unable to display the image.  I have THINK
  2200. Reference and it states that DrawPicture is a void, and it does not 
  2201. indicate any error codes from DrawPicture.  I just looked up in my IM QD 
  2202. book the QDError function.  I will use it for my app.  Thanks for the tip.
  2203.  
  2204.  
  2205. >> Do I need to do a lot of watch dogging and not let any operations be
  2206. >> performed if the app goes beneath 0k of memory is free?
  2207. >        You have less than 0k of memory free and expect the
  2208. >        program to do something?
  2209.  
  2210. That was a typo.  It should have been 10k free.
  2211.  
  2212. >        BTW, just to be a total smart-***, the generally accepted
  2213. >        way to handle this type of situation is to:
  2214.  
  2215. >        1) Figure out how much memory you application needs.
  2216. >        2) Make sure that it gets at least that much.
  2217.  
  2218. >        ;^) <--- note the smiley!
  2219.  
  2220. Yep.  Verry standard.  But the problem is this:  My app will handle an
  2221. unlimited number of files/windows (memory permitting).  I do not wish to
  2222. limit the user by only allowing them a max number of files open at a time
  2223. (like 5 or 10).  Each window/file at it's maximum will use ~ 55 handles
  2224. (I'm displaing a max of 50 icons, each is contained within an IconSuite,
  2225. which is a handle).  If I plan on having 5 files open, I should probably
  2226. call MoreMasters 4 times.  If I plan on having 10 files open, I should
  2227. probably call MoreMasters 9 times.
  2228.  
  2229. Get my point?
  2230.  
  2231. It's varriable depending on the user.  Ideally it would be nice to Call a
  2232. MoreMasters() call before I open a file, then do a DeleteMoreMasters call
  2233. (if such a call had existed) after I calosed a file.  These are all
  2234. design issues I will have to iron out I guess.
  2235.  
  2236.  
  2237. >>
  2238.  
  2239. >        If you call NewHandle, and you have no more master
  2240. >        pointers available, NewHandle will call MoreMasters for
  2241. >        you. The point behind doing it youself is that master
  2242. >        pointer blocks are non-relocatable and tend to lead to
  2243. >        heap fragmentation.
  2244.  
  2245. yep.
  2246.  
  2247. >        If you let NewHandle make the call, the master pointer
  2248. >        block will be placed as low in the heap as possible.
  2249. >        Depending on what you have been doing, you may have
  2250. >        relocatable or purgeable structures in heap below that
  2251. >        block. If you want to reuse that memory, especially with
  2252. >        something that may be larger than the things that
  2253. >        previously occupied that space (as seems like you may) you
  2254. >        are unable to because you have a master pointer block
  2255. >        sitting where you need to put your new structure.
  2256. yep
  2257. >        Go ahead and call MoreMasters two, three... maybe ten
  2258. >        times early in your program. Master pointer blocks are
  2259. >        pretty small compared to the space you could loose letting
  2260. >        NewHandle do it for you.
  2261.  
  2262. see above.
  2263.  
  2264.  
  2265. >        The memory manager has a number of calls in addition to
  2266. >        CompactMem (FreeMem and PurgeMem come to mind) but these
  2267. >        only help with relocatable and purgeable objects. If your
  2268. >        memory is fragmented, it will stay fragmented, these calls
  2269. >        only help you use the memory that you have left.
  2270.  
  2271. Yes, but for each of these call you need to specify an amount of space to try
  2272. to free up.  What I was wondering was if there was a call that causes the
  2273. system to compact ALL of the free memory.  From what I can tell, it
  2274. doesn't look like it.
  2275.  
  2276. >        From your literary reference above (an excellent starting
  2277. >        point, I might add) I assume that you are (fairly) new to
  2278. >        Macintosh programming, although from the apparent
  2279. >        complexity of your application not to programming in
  2280. >        general. Rather than answer you questions with answers, I
  2281. >        will answer them with questions and refer you to further
  2282. >        reading, so that you can learn the material yourself and
  2283. >        not have to ask again next time.
  2284.  
  2285. Pretty close.  I've been programming for several years and have
  2286. programmed several different operating systems (Unix, Atari ST/GEM,
  2287. Windows, now Mac).  I've been programming the Mac for ~ 6 months in my
  2288. spare time.  The biggest problems I have encountered w/the Mac are:
  2289.  
  2290. 1 Unconventional.  I'm not taliking about event-driven programming
  2291. conceps, but things like string types.  Who the hell even USES Str63 or
  2292. Str255?!?!???  After years of honning my pointer & string skills, I have
  2293. to deal with this junk.  If I write my own function, I use pointers, if I
  2294. use a toolbox call, well... I use  StrXXX.  And linked lists... try doing
  2295. a linked list on the Mac... I DARE YOU.
  2296.  
  2297. 2 There are several good Mac programming books out there, but all only
  2298. cover the basics.  What I'd like to see is something that covers a full
  2299. scale real world type app.  One that covers such topics as Multiple
  2300. files/windows opened at a time, localization, printing, error-proofing
  2301. apps, etc...  I've seen some books that start to deal with some of these 
  2302. topics, but don't go into very much depth on them.
  2303.  
  2304. 3 Example code base is meeger.  There are several areas of Mac programming
  2305. which need some indepth examples.  The app which I'm writing shouldn't
  2306. have taken this long, but I got locked up on a couple topics.
  2307.  
  2308.  
  2309. >        (new) Inside Macintosh: Memory - for references to
  2310. >        questions about: MoreMasters, NewHandle, CompactMem,
  2311. >        PurgeMem, FreeMem, etc.
  2312.  
  2313. Don't have it, but I have THINK Reference.
  2314.  
  2315.  
  2316. >        (new) Inside Macintosh: Imaging with QuickDraw - for
  2317. >        references to questions about: DrawPicture, GetPicture,
  2318. >        etc.
  2319.  
  2320.  
  2321. Have it.
  2322.  
  2323. >--
  2324.  
  2325. >Hope this helps.
  2326.  
  2327.  
  2328. a little
  2329.  
  2330.  
  2331. Jeff
  2332.  
  2333.  
  2334.  
  2335. +++++++++++++++++++++++++++
  2336.  
  2337. >From gbolsinga@aol.com (GBolsinga)
  2338. Date: 18 Oct 1994 17:41:08 -0400
  2339. Organization: America Online, Inc. (1-800-827-6364)
  2340.  
  2341. In article <380uvh$lqm@nntp1.u.washington.edu>, jbeeghly@u.washington.edu
  2342. (Jeff Beeghly) writes:
  2343.  
  2344. >If I perform a DisposeHandle on a pic handle, how come I am not able to
  2345. >load and display the picture a second time?  DisposeHandle should just
  2346. >remove the handle, not the resouce, shouldn't it?
  2347.  
  2348. This is bad.  Use KillPicture for all PICTs that aren't resources.
  2349. Use ReleaseResource for all other PICTs.
  2350.  
  2351. Greg
  2352. MPI Multimedia
  2353.  
  2354.  
  2355. +++++++++++++++++++++++++++
  2356.  
  2357. >From bj@lamar.colostate.edu (B.J. Buchalter)
  2358. Date: Tue, 18 Oct 1994 17:10:45 -0700
  2359. Organization: CSU Physics Department
  2360.  
  2361. In article <380uvh$lqm@nntp1.u.washington.edu>, jbeeghly@u.washington.edu
  2362. (Jeff Beeghly) wrote:
  2363.  
  2364.  
  2365. >  
  2366. > I've received one reply that stated all standard system calls will most
  2367. > likely crash when memory gets too low.  Therefore, in my app, if the
  2368. > memory gets below 10k or 12k, I am going to inform the user that there is
  2369. > not enough, and that they should close a file.
  2370. >  
  2371.  
  2372. Yes, this is important. Basically, your strategy needs to be that if the
  2373. amount of free memory gets to be too small (e.g. sufficently small that
  2374. operations WILL fail), you need to disable all of the commands that will
  2375. cause memory to be allocated. That is, if you don;t have enough memory for
  2376. the about box, disable the about box command. Similarly, if you are really
  2377. low on memory, don't allow the user to open another file, and perhaps ask
  2378. them to close one, or ask them to do something else that will free up
  2379. memory.
  2380.  
  2381.  
  2382. > If I perform a DisposeHandle on a pic handle, how come I am not able to
  2383. > load and display the picture a second time?  DisposeHandle should just
  2384. > remove the handle, not the resouce, shouldn't it?
  2385.  
  2386. You definitely do not want to use DisposeHandle on a resource. The
  2387. Resource Manager keeps a table of which resources are loaded and where
  2388. they are in memory. The Memory Manager keeps a table(s) of which handles
  2389. are allocated and where they are in memory. If you tell the resource
  2390. manager to release the resource it cleans up its table and marks the
  2391. resource purgable. If you tell the memory manager to Dispose the handle,
  2392. it frees the handle, but the resource manager still thinks that the handle
  2393. exists... bad news. If you make the resource purgable (HPurge), then
  2394. GetPicture will return the resource handle, even if the handle has been
  2395. purged. This means that you will get an empty PicHandle (if the available
  2396. memory is small enough). An empty PicHandle is a non-null handle that
  2397. points to a NULL value. This will cause quickdraw problems.
  2398.  
  2399. >  
  2400. > The other point I was trying to make was this:  If I can get the image
  2401. > (and pic != nil), how come I am not able to display it?  If GetPicture
  2402. > failed, it's supposed to return a 0, yet it doesn't, so what gives?
  2403.  
  2404. See above about empty PicHandles. Also, even if you do get the picture,
  2405. there may not be enough memory available for the DrawPicture command to
  2406. complete. If the picture is simply a bitmap there is not too much overhead
  2407. in DrawPicture, but if there are any regions polygons, etc, DrawPicture
  2408. can require a reasonable amount of memory. What program did you use to
  2409. create the picture? SuperPaint, for example, stuffs a lot of crap into its
  2410. pictures, including PostScript dictionaries. If you really want to be safe
  2411. for low mem conditions, convert your picture into a bitmap or a pixmap,
  2412. and use copybits to image it. Even with copybits, the fact that it is not
  2413. interrupt safe probably means that you cannot rely on it not to use
  2414. memory. 
  2415.  
  2416. Basically, the toolbox is not terribly stable under really low memory
  2417. conditions. It was generally written to assume that memory allocation will
  2418. not fail. It is your responsibility to ensure that the Toolbox has enough
  2419. memory to satisfy any allocations that it wants to make. In your case, you
  2420. have found that about 10-12K is required. You must ensure that the amount
  2421. of memory avaiable to the system never drops below this amount. Disable
  2422. commands if you must and explain to the user why these commands are
  2423. disabled.  It is better to not be able to do something than to have the
  2424. entire machine crash, especially if the function in question is simply
  2425. seeing the about box of the program.
  2426.  
  2427. If you want to get a little more sophisticated, read about growzone
  2428. functions in IM:Memory. This will allow you to set aside some 'emergency'
  2429. memory for those system calls that just cannot fail.
  2430.  
  2431. >
  2432. > Yes, I was a bit unclear.  The second time I get the picture, GetPicture 
  2433. > does not return a nil, yet I am unable to display the image.  I have THINK
  2434. > Reference and it states that DrawPicture is a void, and it does not 
  2435. > indicate any error codes from DrawPicture.  I just looked up in my IM QD 
  2436. > book the QDError function.  I will use it for my app.  Thanks for the tip.
  2437. >  
  2438.  
  2439. See above statments about empty handles and DrawPicture. 
  2440.  
  2441. > >> Do I need to do a lot of watch dogging and not let any operations be
  2442. > >> performed if the app goes beneath 10k of memory is free?
  2443. > >        You have less than 10k of memory free and expect the
  2444. > >        program to do something?
  2445. >  
  2446.  
  2447. Yes. But you should allow operations that increase the amount of free memory.
  2448.  
  2449.  
  2450. > Yep.  Verry standard.  But the problem is this:  My app will handle an
  2451. > unlimited number of files/windows (memory permitting).  I do not wish to
  2452. > limit the user by only allowing them a max number of files open at a time
  2453. > (like 5 or 10).  Each window/file at it's maximum will use ~ 55 handles
  2454. > (I'm displaing a max of 50 icons, each is contained within an IconSuite,
  2455. > which is a handle).  If I plan on having 5 files open, I should probably
  2456. > call MoreMasters 4 times.  If I plan on having 10 files open, I should
  2457. > probably call MoreMasters 9 times.
  2458. >  
  2459. > Get my point?
  2460. >  
  2461. > It's varriable depending on the user.  Ideally it would be nice to Call a
  2462. > MoreMasters() call before I open a file, then do a DeleteMoreMasters call
  2463. > (if such a call had existed) after I calosed a file.  These are all
  2464. > design issues I will have to iron out I guess.
  2465. >  
  2466. >  
  2467.  
  2468. There are a few things realed to this question. A master pointer block has
  2469. 100 master pointers. The space for the pointers plus overhead is about 512
  2470. bytes (I think... don't remember exactly). You can get approx. 2 files per
  2471. master pointer block. If you initialize, say, 20 master pointer blocks,
  2472. that is only about 10k and it will allow approx. 40 windows before you
  2473. automagically get a new block. Probably OK (not many people can deal with
  2474. 40 windows at once). Remeber, you need the master pointer blocks for other
  2475. types of handles also... not too much of a problem to have too many. Also,
  2476. will all of the icons in every window be different? 40 x 50 = 2000. I
  2477. would be really surprized if your app would actually have to show 2000
  2478. different icon suites (I could be wrong). You might look at sharing
  2479. handles for the common suites (This could be a big win).
  2480.  
  2481. If all of the above does not appeal, you can also look at generating new
  2482. heaps for each window (probably not a great solution).
  2483.  
  2484. But finally, fragmentation happens. You do everything you can to avoid it,
  2485. but there are parts of the toolbox that make it kind of difficult (if you
  2486. want to have no limits on your code). It is not the end of the world, just
  2487. something to be avoided. Especially if, as in your case, each window will
  2488. require approximately the same amount of space. If you have a memory map
  2489. like
  2490.  
  2491.    X
  2492.    P
  2493.    X <-
  2494.    X
  2495.    X
  2496.    X
  2497.    P
  2498.    P
  2499.    P
  2500.    P
  2501.  
  2502. where X = stuff for the window
  2503. and P = non-relocatable (e.g. Master pointer block)
  2504. if one window is closed (the one with the '<-', say) and another is
  2505. opened, then with what you have described, the new window ought to fit
  2506. into the memory occupied by the old window. In this case the fragmentation
  2507. does not affect you. 
  2508.  
  2509. [stuff about memory management and MP blocks]
  2510.  
  2511. see above
  2512.   
  2513.  
  2514. > 1 Unconventional.  I'm not taliking about event-driven programming
  2515. > conceps, but things like string types.  Who the hell even USES Str63 or
  2516. > Str255?!?!???  After years of honning my pointer & string skills, I have
  2517. > to deal with this junk.  If I write my own function, I use pointers, if I
  2518. > use a toolbox call, well... I use  StrXXX.  And linked lists... try doing
  2519. > a linked list on the Mac... I DARE YOU.
  2520.  
  2521. The Str63/Str255 is a legacy from pascal, and certain limits imposed from
  2522. the early design of the operating system (e.g. filename length limits).
  2523. They are generally not a problem (but I guess that I am used to them).
  2524.  
  2525. As far as linked lists goes.... use them all of the time. What is the
  2526. problem?
  2527.  
  2528. > 3 Example code base is meeger.  There are several areas of Mac programming
  2529. > which need some indepth examples.  The app which I'm writing shouldn't
  2530. > have taken this long, but I got locked up on a couple topics.
  2531. >  
  2532.  
  2533. Well, I guess that it is hard to make these claims if you don;t have
  2534. access to New Inside Macintosh. There are pretty good examples and
  2535. explanations of many of the issues you mention. Also, there is alot of
  2536. good source out on the net that essentially functions as sample code of
  2537. the type that you are looking for.
  2538.  
  2539. >  
  2540. > >        (new) Inside Macintosh: Memory - for references to
  2541. > >        questions about: MoreMasters, NewHandle, CompactMem,
  2542. > >        PurgeMem, FreeMem, etc.
  2543. >  
  2544. > Don't have it, but I have THINK Reference.
  2545. >  
  2546.  
  2547. Think reference is not really a substitute.
  2548.  
  2549. Good luck, and don't let it get you down. It gets easier. Really.
  2550.  
  2551. B.J.
  2552.  
  2553. +++++++++++++++++++++++++++
  2554.  
  2555. >From Glenn L. Austin <glenn_a@efn.org>
  2556. Date: Wed, 19 Oct 1994 04:02:29 GMT
  2557. Organization: Eugene FreeNet
  2558.  
  2559. In article <380uvh$lqm@nntp1.u.washington.edu> Jeff Beeghly,
  2560. jbeeghly@u.washington.edu writes:
  2561. >Pretty close.  I've been programming for several years and have
  2562. >programmed several different operating systems (Unix, Atari ST/GEM,
  2563. >Windows, now Mac).  I've been programming the Mac for ~ 6 months in my
  2564. >spare time.
  2565.  
  2566. 6 months is really not long enough to know the toolbox very well, but
  2567. certainly long enough to get a feel of what programming the Mac is like. 
  2568. It's taken me 10 years to REALLY understand the guts of how the Macintosh
  2569. work -- and I was programming for 10 years prior to the Mac introduction
  2570. (mainframes, minis, micros).
  2571.  
  2572. In relation to your problem with the pictures, if the handle is NULL, the
  2573. resource didn't exist. If the first dereference of the handle is NULL,
  2574. there either wasn't enough memory to load the resource, or the resource
  2575. was purged.  If the first dereference is NULL, call LoadResource to see
  2576. if you can load it.  Code that I use for loading any handle looks like
  2577. this:
  2578.  
  2579.     Handle h = GetResource('XXXX', id);
  2580.  
  2581.     if (h)            // resource exists?
  2582.     {
  2583.         if (!*h)
  2584.             LoadResource(h);
  2585.  
  2586.         if (*h)
  2587.         {
  2588.             // use the resource
  2589.         }
  2590.  
  2591.         ReleaseResource(h);            // or HPurge(h) is
  2592. even better!
  2593.     }
  2594.  
  2595. >The biggest problems I have encountered w/the Mac are:
  2596. >1 Unconventional.  I'm not taliking about event-driven programming
  2597. >conceps, but things like string types.  Who the hell even USES Str63 or
  2598. >Str255?!?!???  After years of honning my pointer & string skills, I have
  2599. >to deal with this junk.  If I write my own function, I use pointers, if I
  2600. >use a toolbox call, well... I use  StrXXX.  And linked lists... try doing
  2601. >a linked list on the Mac... I DARE YOU.
  2602.  
  2603. No problem.  I use linked lists all the time.  Pointer AND Handles.
  2604.  
  2605. >2 There are several good Mac programming books out there, but all only
  2606. >cover the basics.  What I'd like to see is something that covers a full
  2607. >scale real world type app.  One that covers such topics as Multiple
  2608. >files/windows opened at a time, localization, printing, error-proofing
  2609. >apps, etc...  I've seen some books that start to deal with some of these 
  2610. >topics, but don't go into very much depth on them.
  2611.  
  2612. I agree.  I've been thinking about that one for a while.  Especially
  2613. printing.  Printing is *EASY* on the Mac.  Try writing a simple printable
  2614. app for Windows -- what a NIGHTMARE!  For example, under Windows, you
  2615. have to do your own scaling (Move and Line are
  2616. device-resolution-specific, but Ellipse and such are based upon the
  2617. current scaling factor set).  I also found a major bug in printing
  2618. landscape (on an HP PCL printer) -- the same code which worked correctly
  2619. when printing portrait broke badly when printing landscape.  Items were
  2620. moved, portions of graphic items were drawn in different places on the
  2621. page (for example, half of an ellipse was drawn in one spot, the other
  2622. half was drawn in another spot, and there was white space between the two
  2623. halves!).  I ended up writing my own landscape code, and letting the
  2624. print drivers (plural -- each printer does its own print code) tell me
  2625. whether I should do my landscaping code.  That bug alone took two months
  2626. to find, diagnose and fix, because, although you can rotate text, many of
  2627. the parts of Windows GDI break down when dealing with vertical rather
  2628. than horizontal text.
  2629.  
  2630. >3 Example code base is meeger.  There are several areas of Mac
  2631. programming
  2632. >which need some indepth examples.  The app which I'm writing shouldn't
  2633. >have taken this long, but I got locked up on a couple topics.
  2634.  
  2635. I definately agree on this one, especially some of the newer managers! 
  2636. However, many of the newer managers (that are extensive, like AOCE or
  2637. QDGX) have many example programs to search through to find the answers to
  2638. many questions.
  2639.  
  2640. However, it has been my experience that Windows programming examples are
  2641. even scarcer -- I had to find PD applications which addressed some of the
  2642. same issues I had to deal with!  Microsoft basically doesn't provide
  2643. anything easily accessable, and although Borland did provide some sample
  2644. code with their compiler, most of it had to do with the "bells &
  2645. whistles" of Windows, like OLE, MCI, and so forth, but very little on
  2646. standard "how to display a window contents and deal with scroll bars."  I
  2647. basically had to experiment with that until I got it right -- another two
  2648. months down the drain.
  2649.  
  2650. The same basic program that I wrote under Windows which took 12 months to
  2651. write and debug took 1 weekend (that's less than 40 hrs, folks!) to write
  2652. using Symantec C++ and TCL.  Much of the stuff I got for free on the
  2653. Macintosh.  Much of the stuff I had to write under Windows...
  2654. //
  2655. // Glenn L. Austin
  2656. // Computer Wizard and Racing Car Driver
  2657. // Internet:  glenn_a@efn.org
  2658. //
  2659.  
  2660. +++++++++++++++++++++++++++
  2661.  
  2662. >From Jaeger@fquest.com (Brian Stern)
  2663. Date: 19 Oct 1994 17:25:21 GMT
  2664. Organization: The University of Texas at Austin, Austin, Texas
  2665.  
  2666. In article <380uvh$lqm@nntp1.u.washington.edu>, jbeeghly@u.washington.edu
  2667. (Jeff Beeghly) wrote:
  2668.  
  2669. <  
  2670. <  
  2671. < >> Do I need to do a lot of watch dogging and not let any operations be
  2672. < >> performed if the app goes beneath 0k of memory is free?
  2673. < >        You have less than 0k of memory free and expect the
  2674. < >        program to do something?
  2675. <  
  2676. < That was a typo.  It should have been 10k free.
  2677. <  
  2678. < >        BTW, just to be a total smart-***, the generally accepted
  2679. < >        way to handle this type of situation is to:
  2680. <  
  2681. < >        1) Figure out how much memory you application needs.
  2682. < >        2) Make sure that it gets at least that much.
  2683. <  
  2684. < >        ;^) <--- note the smiley!
  2685. <  
  2686. < Yep.  Verry standard.  But the problem is this:  My app will handle an
  2687. < unlimited number of files/windows (memory permitting).  I do not wish to
  2688. < limit the user by only allowing them a max number of files open at a time
  2689. < (like 5 or 10).  Each window/file at it's maximum will use ~ 55 handles
  2690. < (I'm displaing a max of 50 icons, each is contained within an IconSuite,
  2691. < which is a handle).  If I plan on having 5 files open, I should probably
  2692. < call MoreMasters 4 times.  If I plan on having 10 files open, I should
  2693. < probably call MoreMasters 9 times.
  2694. <  
  2695. < Get my point?
  2696. <  
  2697. < It's varriable depending on the user.  Ideally it would be nice to Call a
  2698. < MoreMasters() call before I open a file, then do a DeleteMoreMasters call
  2699. < (if such a call had existed) after I calosed a file.  These are all
  2700. < design issues I will have to iron out I guess.
  2701. <  
  2702. <  
  2703.  
  2704. Most of the sample code I've seen uses a size of about 40K as the time to
  2705. post a low memory warning.  Since we're talking about 'Real World' apps
  2706. you should know that ALL real world apps have a growZone procedure and use
  2707. some mechanism for keeping a buffer of memory available.  Usually this
  2708. done by a mechanism known as the rainy-day fund.  Briefly, at app startup
  2709. you allocate a handle of, say, 40K.  That's your rainy day fund.  Each
  2710. time through your main event loop ( or perhaps only on null events) you
  2711. check the available memory.  If it's too low you post a warning alert. 
  2712. Under some circumstances you release the rainy day handle.  Either from
  2713. your growZone Proc or possibly in response to an explicit call from
  2714. somewhere in your app.
  2715.  
  2716. Regarding the MoreMasters calls.  Exercise your app thoroughly with a
  2717. number of windows/documents open that is on the high side of what you
  2718. would consider avaerage.  See how many Master Pointer blocks were needed. 
  2719. Maybe add 2 or 3 to this number and call MoreMasters this many times. 
  2720. Eight or ten should be more than sufficient.  Realize that any user that
  2721. sees the 'not enough memory' warning is going to up the partition size for
  2722. the app.  Although this doesn't automatically increase the number of
  2723. Master Pointer blocks it does give the app more breathing room so that if
  2724. any are automatically allocated any problems caused by heap fragmentation
  2725. are minimized.  The important thing is to warn when memory gets low.
  2726.  
  2727.  
  2728. <   The biggest problems I have encountered w/the Mac are:
  2729. <  
  2730. < 1 Unconventional.  I'm not taliking about event-driven programming
  2731. < conceps, but things like string types.  Who the hell even USES Str63 or
  2732. < Str255?!?!???  After years of honning my pointer & string skills, I have
  2733. < to deal with this junk.  If I write my own function, I use pointers, if I
  2734. < use a toolbox call, well... I use  StrXXX.  And linked lists... try doing
  2735. < a linked list on the Mac... I DARE YOU.
  2736.  
  2737. Gee Jeff, we were just beginning to like you, and then you turn on us like
  2738. this:)  Are you aware that your windowlist is a linked list?  There are
  2739. numerous operating system queues that are linked lists.  Doing linked
  2740. lists with memory allocated by NewPtr or by malloc is no different than on
  2741. any other architecture.  You can do linked lists with handles.  The only
  2742. difference is an extra * here or there when referring to the memory
  2743. blocks.
  2744.  
  2745. If you're not aware, the reason for the Str255 and friends string types
  2746. are due to the Mac's Pascal heritage.  Don't complain about it, just
  2747. accept it.  Every development environment has utility routines to
  2748. translate between C and P strings.  Sorry you had to learn something new.
  2749.  
  2750. <  
  2751. < 2 There are several good Mac programming books out there, but all only
  2752. < cover the basics.  What I'd like to see is something that covers a full
  2753. < scale real world type app.  One that covers such topics as Multiple
  2754. < files/windows opened at a time, localization, printing, error-proofing
  2755. < apps, etc...  I've seen some books that start to deal with some of these 
  2756. < topics, but don't go into very much depth on them.
  2757. <  
  2758. < 3 Example code base is meeger.  There are several areas of Mac programming
  2759. < which need some indepth examples.  The app which I'm writing shouldn't
  2760. < have taken this long, but I got locked up on a couple topics.
  2761.  
  2762. Are you aware of the sample code at ftp.apple.com and at the
  2763. alt.sources.mac archive at ftp://ftpbio.bgsu.edu/?
  2764.  
  2765. <  
  2766. <  
  2767. <  
  2768. < Have it.
  2769. <  
  2770. < >--
  2771. <  
  2772. < >Hope this helps.
  2773. <  
  2774. <  
  2775. < a little
  2776. <  
  2777. <  
  2778. < Jeff
  2779.  
  2780. Good luck,
  2781.  
  2782. -- 
  2783. Brian  Stern  :-{)}
  2784. Toolbox commando and Menu bard
  2785. Jaeger@fquest.com
  2786.  
  2787. +++++++++++++++++++++++++++
  2788.  
  2789. >From ari@world.std.com (Ari I Halberstadt)
  2790. Date: Thu, 20 Oct 1994 04:00:28 GMT
  2791. Organization: The World Public Access UNIX, Brookline, MA
  2792.  
  2793. In article <Jaeger-1910941228440001@slip-8-14.ots.utexas.edu>,
  2794. Brian Stern <Jaeger@fquest.com> wrote:
  2795. >In article <380uvh$lqm@nntp1.u.washington.edu>, jbeeghly@u.washington.edu
  2796. >(Jeff Beeghly) wrote:
  2797. >
  2798. ><  
  2799. ><  
  2800. >< >> Do I need to do a lot of watch dogging and not let any operations be
  2801. >< >> performed if the app goes beneath 0k of memory is free?
  2802. >...
  2803. >< Get my point?
  2804.  
  2805. Get ZoneRanger and a color monitor. This is the *coolest* free program
  2806. for figuring out what the heck your app is doing in its memory
  2807. partition. It should be on any archive site and plenty of CDs.
  2808. Also, get ProcessWatcher, another free and useful tool.
  2809.  
  2810. >Most of the sample code I've seen uses a size of about 40K as the time to
  2811. >post a low memory warning.  Since we're talking about 'Real World' apps
  2812. >you should know that ALL real world apps have a growZone procedure and use
  2813. >some mechanism for keeping a buffer of memory available.  Usually this
  2814. >done by a mechanism known as the rainy-day fund.  Briefly, at app startup
  2815. >you allocate a handle of, say, 40K.  That's your rainy day fund.  Each
  2816. >time through your main event loop ( or perhaps only on null events) you
  2817. >check the available memory.  If it's too low you post a warning alert. 
  2818. >Under some circumstances you release the rainy day handle.  Either from
  2819. >your growZone Proc or possibly in response to an explicit call from
  2820. >somewhere in your app.
  2821.  
  2822. I've abstracted and elaborated this. Each level in an app gets a
  2823. reserve memory. Then there's a memory cushion in addition. The app
  2824. sets the allocation level. The Toolbox level is the lowest, since the
  2825. TB can crash if it doesn't get memory. When I need to allocate memory,
  2826. I bump up the level, then restore it afterwards. For critical things,
  2827. like quitting and saving a file, I bump up the memory to a "critical"
  2828. level. Each level allows access to different memory reserves. The size
  2829. of the memory reserves for each level is set in a configuration
  2830. resource. The grow zone function runs a loop in which it frees up
  2831. reserves (depending on the current level) until enough bytes have been
  2832. freed. Memory warnings are issued depending on how much of the
  2833. reserves are depleted and how little memory is left. At each warning
  2834. level, the application can take different actions, e.g., at first just
  2835. an alert, then disabling functions like undo, then automatically
  2836. asking the user to close files, then automatically closing unmodified
  2837. files and saving modified files to temporary locations, and, finally,
  2838. terminating the application if all of the reserves are depleted and
  2839. there is very little memory left (e.g., less than 10K). I also have
  2840. code to automatically unload inactive segments, but it's not very
  2841. portable (works only with THINK C, not with Metrowerks).
  2842.  
  2843. >...
  2844. >< 1 Unconventional.  I'm not taliking about event-driven programming
  2845. >< conceps, but things like string types.  Who the hell even USES Str63 or
  2846. >< Str255?!?!???  After years of honning my pointer & string skills, I have
  2847. >< to deal with this junk.  If I write my own function, I use pointers, if I
  2848. >< use a toolbox call, well... I use  StrXXX.  And linked lists... try doing
  2849. >< a linked list on the Mac... I DARE YOU.
  2850. >...
  2851. >If you're not aware, the reason for the Str255 and friends string types
  2852. >are due to the Mac's Pascal heritage.  Don't complain about it, just
  2853. >accept it.  Every development environment has utility routines to
  2854. >translate between C and P strings.  Sorry you had to learn something new.
  2855.  
  2856. I got tired of worrying about string types. At first, I just made a
  2857. rule that everything was a C string, and wrote wrappers around
  2858. offending toolbox routines. Then I decided it just didn't make sense
  2859. to worry about how long a string is, especially for variable length
  2860. things. So I wrote a string library that allocates everything
  2861. dynamically, and even replaces sprintf. This would have been easier
  2862. with C++, but hey, it works even with C. For string-intensive portions
  2863. of my code where many strings are used and where performance is
  2864. important, say parsing, I use direct pointers and allocate things from
  2865. a large chunk of memory or use a fixed string length. the string
  2866. library has functions for converting to and from regular C or Pascal
  2867. strings.
  2868.  
  2869. >< 3 Example code base is meeger.  There are several areas of Mac programming
  2870. >< which need some indepth examples.  The app which I'm writing shouldn't
  2871. >< have taken this long, but I got locked up on a couple topics.
  2872. >
  2873. >Are you aware of the sample code at ftp.apple.com and at the
  2874. >alt.sources.mac archive at ftp://ftpbio.bgsu.edu/?
  2875.  
  2876. Yup, I'd have to agree that there's tons of sample code. And there's
  2877. all the sample code that comes with your compiler (e.g., TC,
  2878. Metrowerks), and with Develop, etc.
  2879.  
  2880. -- 
  2881. "Ramsgate (n.) All institutional buildings must, by law, contain at
  2882. least twenty ramsgates. These are doors that open the opposite way to
  2883. the one you expect." -- D. Adams & J. Lloyd "The Meaning of Liff", p75.
  2884.  
  2885. +++++++++++++++++++++++++++
  2886.  
  2887. >From ari@world.std.com (Ari I Halberstadt)
  2888. Date: Thu, 20 Oct 1994 04:25:35 GMT
  2889. Organization: The World Public Access UNIX, Brookline, MA
  2890.  
  2891. In article <CxyDst.7n0@world.std.com>,
  2892. Ari I Halberstadt <ari@world.std.com> wrote:
  2893. >I've abstracted and elaborated this. Each level in an app gets a
  2894. >reserve memory. Then there's a memory cushion in addition. The app
  2895. >sets the allocation level. The Toolbox level is the lowest, since the
  2896. >TB can crash if it doesn't get memory. When I need to allocate memory,
  2897. >I bump up the level, then restore it afterwards. For critical things,
  2898. >like quitting and saving a file, I bump up the memory to a "critical"
  2899. >level. Each level allows access to different memory reserves. The size
  2900. >...
  2901.  
  2902. This paragraph is inconsistent. Basically, the Toolbox level has the
  2903. highest priority. The normal priority is the Toolbox level, since
  2904. there are so many TB calls that can allocate memory it's just easier
  2905. to keep it as the default. At the TB level, both my reserves and the
  2906. TB reserves can be accessed. When I allocate memory, I lower the
  2907. priority so as not to deplete the TB reserves, but I can still deplete
  2908. my reserves. This scheme can be extended to any number of levels
  2909. (which, in my case, is a bit necessary, since I have the TB, low-level
  2910. libraries, then the real application, each of which should have their
  2911. own reserves, even though my libraries aren't supposed to crash if
  2912. they run out of memory).
  2913. -- 
  2914. "Ramsgate (n.) All institutional buildings must, by law, contain at
  2915. least twenty ramsgates. These are doors that open the opposite way to
  2916. the one you expect." -- D. Adams & J. Lloyd "The Meaning of Liff", p75.
  2917.  
  2918. +++++++++++++++++++++++++++
  2919.  
  2920. >From h+@nada.kth.se (Jon W{tte)
  2921. Date: Thu, 20 Oct 1994 19:44:46 +0100
  2922. Organization: Royal Institute of Something or other
  2923.  
  2924. In article <Jaeger-1910941228440001@slip-8-14.ots.utexas.edu>,
  2925. Jaeger@fquest.com (Brian Stern) wrote:
  2926.  
  2927. >< conceps, but things like string types.  Who the hell even USES Str63 or
  2928. >< Str255?!?!???  After years of honning my pointer & string skills, I have
  2929. >< to deal with this junk.  If I write my own function, I use pointers, if I
  2930. >< use a toolbox call, well... I use  StrXXX.  And linked lists... try doing
  2931. >< a linked list on the Mac... I DARE YOU.
  2932.  
  2933. I use Str31, Str63 and Str255 where appropriate; mostly as 
  2934. structure members and stack-based variables.
  2935.  
  2936. Anyone who knows enough C or C++ to program any computer for a 
  2937. living (in those languages...) knows that when you have a 
  2938. typedef:
  2939.  
  2940. typedef unsigned char Str31 [ 32 ] ;
  2941.  
  2942. what really gets passed to functions is a pointer to unsigned 
  2943. char, so all functions should be declared as:
  2944.  
  2945. void
  2946. MyFunc (
  2947.     const unsigned char * source ,
  2948.     unsigned char * dest )
  2949.  
  2950.  
  2951. Similarly; you can pass an unsigned char pointer everywhere the 
  2952. headers say "StrXXX"
  2953.  
  2954. Similarly for linked lists; use malloc() if you like it better, 
  2955. or use NewPtr(). Or do a linked list with Handles; it's really 
  2956. easy:
  2957.  
  2958. typedef struct elem {
  2959.     struct elem * * next ;
  2960.     long data ;
  2961. } elem , * elemPtr , * * elemHandle ;
  2962.  
  2963. elemHandle theList ;
  2964.  
  2965. void
  2966. insertelematend (
  2967.     long data )
  2968. {
  2969.     elemHandle theE = ( elemHandle ) NewHandle ( sizeof ( elem ) ) ;
  2970.     elemHandle * theP = & theList ;
  2971.  
  2972.     ( * theE ) -> next = NULL ;
  2973.     ( * theE ) -> data = data ;
  2974.     while ( * theP )
  2975.     {
  2976.         theP = & ( * theP ) -> next ;
  2977.     }
  2978.     * theP = theE ;
  2979. }
  2980.  
  2981.  
  2982. Cheers,
  2983.  
  2984.                 / h+
  2985.  
  2986.  
  2987. --
  2988.   Jon W$E4tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  2989.    This is the kind of totally-gross-out-sick stuff you can do with C++ that
  2990.    makes the language kind of neat.
  2991.                                             -- Keith Rollin
  2992.  
  2993.  
  2994. +++++++++++++++++++++++++++
  2995.  
  2996. >From lsr@taligent.com (Larry Rosenstein)
  2997. Date: Wed, 19 Oct 1994 01:22:44 GMT
  2998. Organization: Taligent, Inc.
  2999.  
  3000. In article <bj-1810941710450001@ivan.physics.colostate.edu>,
  3001. bj@lamar.colostate.edu (B.J. Buchalter) wrote:
  3002.  
  3003. > Yes, this is important. Basically, your strategy needs to be that if the
  3004. > amount of free memory gets to be too small (e.g. sufficently small that
  3005. > operations WILL fail), you need to disable all of the commands that will
  3006.  
  3007. You also have to make sure that the amount of free memory doesn't get so
  3008. small that the user can't save documents, quit, etc.
  3009.  
  3010. -- 
  3011. Larry Rosenstein
  3012. Taligent, Inc.
  3013.  
  3014. lsr@taligent.com
  3015.  
  3016. +++++++++++++++++++++++++++
  3017.  
  3018. >From Peter_Gontier@novell.com (Pete Gontier)
  3019. Date: Mon, 24 Oct 1994 19:52:54 -0800
  3020. Organization: Novell, Inc., Walnut Creek Macintosh Site
  3021.  
  3022. In article <380uvh$lqm@nntp1.u.washington.edu>,
  3023. jbeeghly@u.washington.edu (Jeff Beeghly) wrote:
  3024.  
  3025. > I've received one reply that stated all standard system calls will most
  3026. > likely crash when memory gets too low.  Therefore, in my app, if the
  3027. > memory gets below 10k or 12k, I am going to inform the user that there is
  3028. > not enough, and that they should close a file.
  3029.  
  3030. Try 33K. Why? Because 32K is the largest several of the more complicated
  3031. data structures in the Toolbox can be. Add 1K for super-emergencies and
  3032. you should be better off than using only 12K.
  3033.  
  3034. > The other point I was trying to make was this:  If I can get the image
  3035. > (and pic != nil), how come I am not able to display it?  If GetPicture
  3036. > failed, it's supposed to return a 0, yet it doesn't, so what gives?
  3037.  
  3038. Because the data in a 'PICT' is compressed. It gets expanded somewhat
  3039. during DrawPicture.
  3040.  
  3041. Also, consider skipping calls like GetPicture and simply using GetResource
  3042. directly. It provides an opportunity to do better error checking at the
  3043. price of the following difference in typing:
  3044.  
  3045.         PicHandle ph = GetPicture (128);
  3046.  
  3047.         PicHandle ph = (PicHandle) GetResource ('PICT',128);
  3048.  
  3049. Now you can call 'ResError' and find out all the other things which might
  3050. have gone wrong other than 'resNotFound'.
  3051.  
  3052. >The biggest problems I have encountered w/the Mac are:
  3053. >  
  3054. > 1 Unconventional.  I'm not taliking about event-driven programming
  3055. > conceps, but things like string types.  Who the hell even USES Str63 or
  3056. > Str255?!?!???  After years of honning my pointer & string skills, I have
  3057. > to deal with this junk.  If I write my own function, I use pointers, if I
  3058. > use a toolbox call, well... I use  StrXXX.
  3059.  
  3060. I actually prefer Pascal strings for most operations because I always have
  3061. the length available without worrying about caching the result of
  3062. 'strlen'. The fact that there are a zillion 'Str...' shouldn't faze you;
  3063. they're just Pascal strings with different maximum sizes. I use 'Str15',
  3064. for example, all the time for quick calls to 'NumToString'.
  3065.  
  3066. > And linked lists... try doing
  3067. > a linked list on the Mac... I DARE YOU.
  3068.  
  3069. I have. Other posters have pointed out that handles on the Macintosh are
  3070. not the same as handles on Windows. There's no more difficulty in writing
  3071. linked list code on the Mac than there is in typing an extra '*'. (It's
  3072. when people start trying to optimize the double-dereferencing that they
  3073. get into trouble.)
  3074.  
  3075. > 3 Example code base is meeger.  There are several areas of Mac programming
  3076. > which need some indepth examples.  The app which I'm writing shouldn't
  3077. > have taken this long, but I got locked up on a couple topics.
  3078.  
  3079. This is an odd observation, given that you appear to have "real" internet
  3080. access. Perhaps you are unaware of the many 'ftp' archive sites. There is
  3081. also copious example code on the various CD ROMs produced by Apple.
  3082.  
  3083. > >        (new) Inside Macintosh: Memory - for references to
  3084. > >        questions about: MoreMasters, NewHandle, CompactMem,
  3085. > >        PurgeMem, FreeMem, etc.
  3086. >  
  3087. > Don't have it, but I have THINK Reference.
  3088.  
  3089. You absitively posolutely need to buy the relevant Inside Macintosh
  3090. volumes. They cost a lot of money. You need to buy them anyway.
  3091.  
  3092. -- 
  3093.  Views expressed here do not necessarily reflect the views of Novell.
  3094.  
  3095. ---------------------------
  3096.  
  3097. >From pwhull@crl.com (Peter Hull)
  3098. Subject: NewGWorld returns null pointer
  3099. Date: 20 Oct 1994 09:24:21 GMT
  3100. Organization: CRL Dialup Internet Access    (415) 705-6060  [Login:
  3101. guest]
  3102.  
  3103. Hello,
  3104.  
  3105. I have a problem related to using GWorlds-- NewGWorld returns null in the
  3106. GWorld pointer.  I am using TCL 1.1.3.  When the problem occurs, I already
  3107. have one document object open, identical to the one I am trying to create.
  3108. If I close the first document and then open a second one, everything is
  3109. cool.  But if I try to open a second document while the first is still open,
  3110. when my CGWorld object calls NewGWorld to create the offscreen world, it
  3111. gets this null pointer.  I am running the program in 4 megs of memory,
  3112. and the images are only 256x256 pixels.  (I'm using the Pico sample images
  3113. from 'develop' #10, from 'develop' CD #19.)
  3114.  
  3115. Does anybody have any idea why NewGWorld would return a null GWorld?  There's
  3116. nothing in Inside Macintosh that would suggest that NewGWorld might return
  3117. a null pointer except for the example code in NIM: "Imaging with QuickDraw",
  3118. chapter 6, which tests for a null pointer.  That is where I got the idea that
  3119. that might be the problem.  (Originally I thought the problem might be with
  3120. DrawPicture, because that's where the program froze.)
  3121.  
  3122. Any help would be appreciated...
  3123.  
  3124. Thanks in advance!
  3125.  
  3126. --
  3127. --
  3128. Peter Hull <pwhull@crl.com>
  3129.  
  3130. +++++++++++++++++++++++++++
  3131.  
  3132. >From pwhull@crl.com (Peter Hull)
  3133. Date: 20 Oct 1994 21:18:34 GMT
  3134. Organization: CRL Dialup Internet Access    (415) 705-6060  [Login:
  3135. guest]
  3136.  
  3137. Peter Hull (pwhull@crl.com) wrote:
  3138. : Hello,
  3139.  
  3140. : I have a problem related to using GWorlds-- NewGWorld returns null in the
  3141. : GWorld pointer.  I am using TCL 1.1.3.  When the problem occurs, I already
  3142. : have one document object open, identical to the one I am trying to create.
  3143. : If I close the first document and then open a second one, everything is
  3144. : cool.  But if I try to open a second document while the first is still
  3145. open,
  3146. : when my CGWorld object calls NewGWorld to create the offscreen world, it
  3147. : gets this null pointer.  I am running the program in 4 megs of memory,
  3148. : and the images are only 256x256 pixels.  (I'm using the Pico sample images
  3149. : from 'develop' #10, from 'develop' CD #19.)
  3150.  
  3151. : Does anybody have any idea why NewGWorld would return a null GWorld? 
  3152. There's
  3153. : nothing in Inside Macintosh that would suggest that NewGWorld might return
  3154. : a null pointer except for the example code in NIM: "Imaging with
  3155. QuickDraw",
  3156. : chapter 6, which tests for a null pointer.  That is where I got the idea
  3157. that
  3158. : that might be the problem.  (Originally I thought the problem might be with
  3159. : DrawPicture, because that's where the program froze.)
  3160.  
  3161. I now have discovered that the problem occurs also on the first document
  3162. object sometimes.  Why this is I still have no idea.  Here is the call,
  3163. straight from my source code:
  3164.  
  3165.     FailOSErr(anErr = NewGWorld(&itsWorld, depth,
  3166.                   &boundsRect, NULL, NULL, 0));
  3167.  
  3168. 'boundsRect' is { 0, 0, 256, 256 }, 'depth' is 16.
  3169.  
  3170. After the call, sometimes 'itsWorld' is NULL.
  3171.  
  3172. However, I have never had an error show up in 'anErr'.
  3173. Any ideas?
  3174.  
  3175. --
  3176. --
  3177. Peter Hull <pwhull@crl.com>
  3178.  
  3179. +++++++++++++++++++++++++++
  3180.  
  3181. >From Jaeger@fquest.com (Brian Stern)
  3182. Date: 23 Oct 1994 18:07:12 GMT
  3183. Organization: The University of Texas at Austin, Austin, Texas
  3184.  
  3185. In article <386mra$kqk@nntp.crl.com>, pwhull@crl.com (Peter Hull) wrote:
  3186.  
  3187. < Peter Hull (pwhull@crl.com) wrote:
  3188. < : Hello,
  3189. < : I have a problem related to using GWorlds-- NewGWorld returns null in the
  3190. < : GWorld pointer.  I am using TCL 1.1.3.  When the problem occurs, I
  3191. already
  3192. <         FailOSErr(anErr = NewGWorld(&itsWorld, depth,
  3193. <                   &boundsRect, NULL, NULL, 0));
  3194. < 'boundsRect' is { 0, 0, 256, 256 }, 'depth' is 16.
  3195. < After the call, sometimes 'itsWorld' is NULL.
  3196. < However, I have never had an error show up in 'anErr'.
  3197. < Any ideas?
  3198. < --
  3199. < --
  3200. < Peter Hull <pwhull@crl.com>
  3201.  
  3202. Actually this very question was posted a month or so back.  Are you
  3203. locking the object before making this call?  NewGWorld moves memory.  TCL
  3204. 1.1.3 objects are handles.  If itsWorld is an instance varible and the
  3205. object is unlocked then NewGWorld will succeed but &itsWorld won't point
  3206. to the object anymore.  Either lock the object, or use a local varible for
  3207. the first parameter to NewGWorld and  then set itsWorld from the local
  3208. variable.
  3209.  
  3210. Good luck,
  3211.  
  3212. -- 
  3213. Brian  Stern  :-{)}
  3214. Toolbox commando and Menu bard
  3215. Jaeger@fquest.com
  3216.  
  3217. +++++++++++++++++++++++++++
  3218.  
  3219. >From pwhull@crl.com (Peter Hull)
  3220. Date: 24 Oct 1994 10:16:33 GMT
  3221. Organization: CRL Dialup Internet Access    (415) 705-6060  [login:
  3222. guest]
  3223.  
  3224. Regarding the GWorld problem with NewGWorld returning a null pointer,
  3225. Brian Stern's solution was correct.  He suggested that the problem was
  3226. being caused by NewGWorld moving memory while the object that called
  3227. it was unlocked in the heap.  This caused the (handle-based) object to
  3228. not receive the pointer correctly.  Here is my implementation of the fix:
  3229.  
  3230. HLock ((Handle) this);
  3231.  
  3232. <NewGWorld call here>
  3233.  
  3234. HUnlock ((Handle) this);
  3235.  
  3236. Depressingly simple, isn't it?  Many thanks to Brian and also to
  3237. Francois Pottier who e-mailed me with the same solution.
  3238.  
  3239. Cheers,
  3240.  
  3241. Peter
  3242.  
  3243. --
  3244.  
  3245. Peter Hull
  3246. <pwhull@crl.com>
  3247.  
  3248. ---------------------------
  3249.  
  3250. >From mclow@san_marcos.csusm.edu (Marshall Clow)
  3251. Subject: Pathnames? I don't think so...
  3252. Date: Fri, 14 Oct 1994 17:36:29 -0700
  3253. Organization: Aladdin Systems
  3254.  
  3255. In article <272202942.8010432@chatter.chatter.com>,
  3256. Daaron_Dwyer@chatter.com wrote:
  3257.  
  3258. > Not to answer the question, but to advance it to a different level, when
  3259. you
  3260. > do a call to FindFolder (let's say to find the preferences folder on the
  3261. > startup volume) and you get a Folder ID, what is the most efficient way to
  3262. > convert it or utilize the information to be a path?
  3263. > Just another newbie,
  3264.  
  3265. OK. Here we go:
  3266.    On the mac, in general, you don't want to use pathnames. Users have
  3267. this distressing habit of moving files and renaming folders.
  3268.  
  3269. To open/rename/delete/etc a file:
  3270.    All the appropriate routines take a triplet:
  3271.       volume, directory ID, and file name.
  3272. In your example, you already have a volume refnum, and directory ID,
  3273. (from your call to FindFolder), and presumably you have the name.
  3274.    err = HOpen ( vrefNum, dirID, fName, fsRdWrPerm, &refNum );
  3275.  
  3276.  
  3277. To save the location of a file so you can find it later:
  3278.    Use the alias manager.
  3279.  
  3280. NewAlias (...);
  3281. later: ResolveAlias ( ... );
  3282.  
  3283. -- 
  3284. Marshall Clow
  3285. Aladdin Systems
  3286. mclow@san_marcos.csusm.edu
  3287.  
  3288.  
  3289. ---------------------------
  3290.  
  3291. >From bb@lightside.com (Bob Bradley)
  3292. Subject: Q: Creating Variable sized structures?
  3293. Date: Sun, 16 Oct 1994 09:26:42 -0800
  3294. Organization: SS Software Inc.
  3295.  
  3296. How do you create variable sized structures, similar to how DITL resources
  3297. are used by the Dialog Manager?
  3298.  
  3299. Do they just create a handle and tack on things as they go? If so, it
  3300. would seem like they'd need some sort of index or they'd have to parse the
  3301. list each time to access individual items.
  3302.  
  3303. I'm writing a View-like library for creating Windows/Dialogs and I'm
  3304. looking for a good way to create variable sized structures that define the
  3305. details of the View but, having a tough time with this part of it.
  3306.  
  3307. Any comments appreciated.
  3308.  
  3309. +++++++++++++++++++++++++++
  3310.  
  3311. >From Eric Kidd <emk@dartmouth.edu>
  3312. Date: 18 Oct 1994 03:00:39 GMT
  3313. Organization: Dartmouth College
  3314.  
  3315. Q: Creating Variable sized structures?
  3316.  
  3317. One easy way to do this is--if the variable part of the record is of
  3318. constant
  3319. size--is to define a struct like:
  3320.  
  3321. typedef struct
  3322. {
  3323.    // header info
  3324.     
  3325.    short index;
  3326.    element_type element[1];
  3327. } myType;
  3328.  
  3329. Reference data of this type with a handle and use the memory manager
  3330. (ResizeHandle? SizeHandle? I forget at the moment.) to resize it as you
  3331. need. You
  3332. could write a routine:
  3333.  
  3334.    ResizeMyType( myType** theData, short numSlots )
  3335.  
  3336. and call it as needed. Hope this helps. Any feedback appreciated.
  3337.  
  3338. +++++++++++++++++++++++++++
  3339.  
  3340. >From Jaeger@fquest.com (Brian Stern)
  3341. Date: 18 Oct 1994 06:52:05 GMT
  3342. Organization: The University of Texas at Austin, Austin, Texas
  3343.  
  3344. In article <bb-1610940926420001@user38.lightside.com>, bb@lightside.com
  3345. (Bob Bradley) wrote:
  3346.  
  3347. < How do you create variable sized structures, similar to how DITL resources
  3348. < are used by the Dialog Manager?
  3349. < Do they just create a handle and tack on things as they go? If so, it
  3350. < would seem like they'd need some sort of index or they'd have to parse the
  3351. < list each time to access individual items.
  3352. < I'm writing a View-like library for creating Windows/Dialogs and I'm
  3353. < looking for a good way to create variable sized structures that define the
  3354. < details of the View but, having a tough time with this part of it.
  3355. < Any comments appreciated.
  3356.  
  3357. Yes, variable-sized resources are built by allocating a handle and then
  3358. tacking things onto the end of it.  The routines like GetDItem, SetDItem,
  3359. and GetIndString walk down the resource each time to find the particular
  3360. item's data.  In general these data structures are small so that finding
  3361. the third or tenth item doesn't take very long.  Finding the hundreth or
  3362. thousandth item this way would be very slow.
  3363.  
  3364. Each of the items in these variable length data structures has a length
  3365. byte or short that is at a fixed offset from the beginning of each item
  3366. (often the offset is zero) to facilitate walking down the structure.  Also
  3367. the resource has an entry count in it, usually at the beginning.  Adding a
  3368. new item at the end is just a matter of using PtrAndHand and then updating
  3369. the item counter.  Modifying existing items or inserting items in the
  3370. middle is a matter of adjusting the size of the handle and blockmove to
  3371. make space in the middle, followed by blockmove to insert the new data.
  3372.  
  3373. My personal favorite is the Speech Manager 'dict' resource.  In this
  3374. perverse resource there is a header, followed by a variable length array
  3375. of variable length records.  Each of these last records consists of two
  3376. (or more) variable length records.  Sort of like an array of STR#
  3377. resources.
  3378.  
  3379. -- 
  3380. Brian  Stern  :-{)}
  3381. Toolbox commando and Menu bard
  3382. Jaeger@fquest.com
  3383.  
  3384. +++++++++++++++++++++++++++
  3385.  
  3386. >From larson@base.cs.ucla.edu (Christopher Larson)
  3387. Date: 18 Oct 1994 16:51:27 GMT
  3388. Organization: UCLA, Computer Science Department
  3389.  
  3390. In article <37vdon$gvt@dartvax.dartmouth.edu> Eric Kidd <emk@dartmouth.edu>
  3391. writes:
  3392. >Q: Creating Variable sized structures?
  3393. >
  3394. >One easy way to do this is--if the variable part of the record is of
  3395. >constant
  3396. >size--is to define a struct like:
  3397. >
  3398. >typedef struct
  3399. >{
  3400. >   // header info
  3401. >    
  3402. >   short index;
  3403. >   element_type element[1];
  3404. >} myType;
  3405.  
  3406. In THINK C (don't know about CW) it is legal to declare an array of
  3407. unspecified
  3408. size (e.g. "element_type element[];") which will not contribute to the size
  3409. of
  3410. the struct. Then allocation of the handle becomes:
  3411.  
  3412.   Handle  theHandle;
  3413.   Size    elementCount = kDefaultElementCount; // The number of array
  3414. elements
  3415.  
  3416.   theHandle = NewHandle(sizeof(myType) + sizeof(element_type) *
  3417. elementCount);
  3418.  
  3419. IMHO this is easier than having to remember that you get one element for free
  3420. in sizeof(myType).
  3421.  
  3422. >Reference data of this type with a handle and use the memory manager
  3423. >(ResizeHandle? SizeHandle? I forget at the moment.) to resize it as you
  3424. >need. You could write a routine:
  3425.  
  3426. That would be SetHandleSize();
  3427.  
  3428. All of the routines dealing with handles are documented in Inside Macintosh:
  3429. Memory.
  3430.  
  3431. --Chris
  3432. ______________________________________________________________________________
  3433. _
  3434. Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
  3435. L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
  3436. Death to the Trojans! Go Bruins!
  3437.  
  3438. (Insert disclaimer here)
  3439. Internet: larson@kingston.cs.ucla.edu
  3440.  
  3441. ---------------------------
  3442.  
  3443. >From b.kobben@frw.ruu.nl (Barend Kobben)
  3444. Subject: QuickTime + MIDI?
  3445. Date: Tue, 11 Oct 1994 15:45:13 GMT
  3446. Organization: Cartography dept., Utrecht University
  3447.  
  3448. Hi,
  3449.  
  3450. REMARK: I recently was shown that if you have Quicktime 2.0 + "QuickTime
  3451. Musical Instruments" extension, you have the ability to handle MIDI-files.
  3452. When openening these Midi files with a QuickTime player (like MoviePlayer,
  3453. PetersPlayer, etc.) you can convert the MIDI file to a Quicktime movie
  3454. (Sound only, of course). 
  3455. Even better is the ability (under the Options... button) to fiddle around
  3456. with the instruments. 
  3457. This means that the MIDI instruments (made by Roland, if you believe the
  3458. About... button) are there, a samples, inside these extensions!
  3459.  
  3460. QUESTION: Is there a description of this: How is it formatted, how can I
  3461. handle this from inside my programs?
  3462.  
  3463. -- 
  3464. Barend Kobben (b.kobben@frw.ruu.nl)
  3465. Cartography Dept., Utrecht University
  3466. PO Box 80115, 3508 TC Utrecht, The Netherlands
  3467. tel +31-(0)30-532086; fax +31-(0)30-540604
  3468.  
  3469. +++++++++++++++++++++++++++
  3470.  
  3471. >From sandvik@apple.com (Kent Sandvik)
  3472. Date: Sun, 16 Oct 1994 13:18:45 -0800
  3473. Organization: Apple Computer, Inc. Developer Technical Support
  3474.  
  3475. In article <b.kobben-111094164513@kartoserver.frw.ruu.nl>,
  3476. b.kobben@frw.ruu.nl (Barend Kobben) wrote:
  3477.  
  3478. > Hi,
  3479. > REMARK: I recently was shown that if you have Quicktime 2.0 + "QuickTime
  3480. > Musical Instruments" extension, you have the ability to handle MIDI-files.
  3481. > When openening these Midi files with a QuickTime player (like MoviePlayer,
  3482. > PetersPlayer, etc.) you can convert the MIDI file to a Quicktime movie
  3483. > (Sound only, of course). 
  3484. > Even better is the ability (under the Options... button) to fiddle around
  3485. > with the instruments. 
  3486. > This means that the MIDI instruments (made by Roland, if you believe the
  3487. > About... button) are there, a samples, inside these extensions!
  3488.  
  3489. Yes, but you need the MoviePlayer version shipped with the 2.0b9 SDK CD.
  3490.  
  3491. > QUESTION: Is there a description of this: How is it formatted, how can I
  3492. > handle this from inside my programs?
  3493.  
  3494. This documentation will be released in the forthcoming SDK CD (2.0 final),
  3495. as for final dates, sorry I don't have the data.
  3496.  
  3497. Cheers, KEnt
  3498.  
  3499. -- 
  3500. Kent Sandvik    sandvik@apple.com            New Media Analyst/Programmer
  3501. Private activities on the net not sponsored by the company I work for.
  3502.  
  3503. +++++++++++++++++++++++++++
  3504.  
  3505. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  3506. Date: 17 Oct 94 16:06:59 +1300
  3507. Organization: University of Waikato, Hamilton, New Zealand
  3508.  
  3509. (sorry for the previous failures, our News system ran out of room...)
  3510.  
  3511. In article <sandvik-1610941318450001@17.255.38.231>, sandvik@apple.com (Kent
  3512. San
  3513. dvik) writes:
  3514. > In article <b.kobben-111094164513@kartoserver.frw.ruu.nl>,
  3515. > b.kobben@frw.ruu.nl (Barend Kobben) wrote:
  3516. >
  3517. >> REMARK: I recently was shown that if you have Quicktime 2.0 + "QuickTime
  3518. >> Musical Instruments" extension, you have the ability to handle MIDI-files.
  3519. >> When openening these Midi files with a QuickTime player (like MoviePlayer,
  3520. >> PetersPlayer, etc.) you can convert the MIDI file to a Quicktime movie
  3521. >> (Sound only, of course).
  3522. >> Even better is the ability (under the Options... button) to fiddle around
  3523. >> with the instruments.
  3524. >> This means that the MIDI instruments (made by Roland, if you believe the
  3525. >> About... button) are there, a samples, inside these extensions!
  3526. >
  3527. > Yes, but you need the MoviePlayer version shipped with the 2.0b9 SDK CD.
  3528.  
  3529. No you don't! I was trying this out over the weekend, with MoviePlayer 1.0.
  3530. The MIDI files were off the CD-ROM that came with the July issue of "Future
  3531. Music" magazine. I copied them to my hard disk, set their type to "Midi", and
  3532. then did an "Open..." from within MoviePlayer. Sure enough, they showed up,
  3533. and I was able to convert them.
  3534.  
  3535. Just one problem: I had to click the "Options..." button before each file
  3536. would
  3537. convert properly. If I didn't, I got a garbage movie. Just bringing up the
  3538. options dialog and clicking "Cancel" to go back to the save dialog was
  3539. enough.
  3540.  
  3541. By the way, the options dialog is fun: you get to see all the instruments
  3542. that
  3543. are installed, and there's a little keyboard so you can try them out!
  3544.  
  3545. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  3546. Computer Services Dept                     fax: +64-7-838-4066
  3547. University of Waikato            electric mail: ldo@waikato.ac.nz
  3548. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  3549.  
  3550. +++++++++++++++++++++++++++
  3551.  
  3552. >From jim _reekes@quickmail.apple.com (Jim Reekes)
  3553. Date: Mon, 17 Oct 1994 22:30:03 GMT
  3554. Organization: Apple Computer, Inc.
  3555.  
  3556. In article <1994Oct17.160700.34288@waikato.ac.nz>, ldo@waikato.ac.nz
  3557. (Lawrence D'Oliveiro, Waikato University) wrote:
  3558.  
  3559. > (sorry for the previous failures, our News system ran out of room...)
  3560. > In article <sandvik-1610941318450001@17.255.38.231>, sandvik@apple.com
  3561. (Kent San
  3562. > dvik) writes:
  3563. > > In article <b.kobben-111094164513@kartoserver.frw.ruu.nl>,
  3564. > > b.kobben@frw.ruu.nl (Barend Kobben) wrote:
  3565. > >
  3566. > >> REMARK: I recently was shown that if you have Quicktime 2.0 + "QuickTime
  3567. > >> Musical Instruments" extension, you have the ability to handle
  3568. MIDI-files.
  3569. > >> When openening these Midi files with a QuickTime player (like
  3570. MoviePlayer,
  3571. > >> PetersPlayer, etc.) you can convert the MIDI file to a Quicktime movie
  3572. > >> (Sound only, of course).
  3573. > >> Even better is the ability (under the Options... button) to fiddle
  3574. around
  3575. > >> with the instruments.
  3576. > >> This means that the MIDI instruments (made by Roland, if you believe the
  3577. > >> About... button) are there, a samples, inside these extensions!
  3578. > >
  3579. > > Yes, but you need the MoviePlayer version shipped with the 2.0b9 SDK CD.
  3580. > No you don't! I was trying this out over the weekend, with MoviePlayer 1.0.
  3581. > The MIDI files were off the CD-ROM that came with the July issue of "Future
  3582. > Music" magazine. I copied them to my hard disk, set their type to "Midi",
  3583. and
  3584. > then did an "Open..." from within MoviePlayer. Sure enough, they showed up,
  3585. > and I was able to convert them.
  3586. > Just one problem: I had to click the "Options..." button before each
  3587. file would
  3588. > convert properly. If I didn't, I got a garbage movie. Just bringing up the
  3589. > options dialog and clicking "Cancel" to go back to the save dialog was
  3590. enough.
  3591. > By the way, the options dialog is fun: you get to see all the instruments
  3592. that
  3593. > are installed, and there's a little keyboard so you can try them out!
  3594.  
  3595. The file type needs to be set to 'Midi' and then you import them. But
  3596. there's a bug and they may get imported as type TEXT. So you get a movie
  3597. with a TEXT track and not a Midi track. The workaround, as Lawrence has
  3598. found, is to first click the Options button. Then the Import will work.
  3599.  
  3600. You only need the new and un-tested version of MoviePlayer to change the
  3601. instruments *after* importing the Midi file to a movie.
  3602.  
  3603. - ---------------------------------------------------------------------
  3604. Jim Reekes, Polterzeitgeist   |     Macintosh Toolbox Engineering
  3605.                               |          Sound Manager Expert
  3606. Apple Computer, Inc.          | "All opinions expressed are mine, and do
  3607. 2 Infinite Loop  MS 302-3KS   |   not necessarily represent those of my
  3608. Cupertino, CA 95014           |       employer, Apple Computer Inc."
  3609.  
  3610. +++++++++++++++++++++++++++
  3611.  
  3612. >From 103t_english@west.cscwc.pima.edu
  3613. Date: 18 Oct 94 12:15:06 MST
  3614. Organization: (none)
  3615.  
  3616. In article <jim-1710941525530001@reekes1.apple.com>, jim
  3617. _reekes@quickmail.apple.com (Jim Reekes) writes:
  3618. > In article <1994Oct17.160700.34288@waikato.ac.nz>, ldo@waikato.ac.nz
  3619. > (Lawrence D'Oliveiro, Waikato University) wrote:
  3620. >> (sorry for the previous failures, our News system ran out of room...)
  3621. >> 
  3622. >> In article <sandvik-1610941318450001@17.255.38.231>, sandvik@apple.com
  3623. > (Kent San
  3624. >> dvik) writes:
  3625. >> > In article <b.kobben-111094164513@kartoserver.frw.ruu.nl>,
  3626. >> > b.kobben@frw.ruu.nl (Barend Kobben) wrote:
  3627. >> >
  3628. >> >> REMARK: I recently was shown that if you have Quicktime 2.0 +
  3629. "QuickTime
  3630. >> >> Musical Instruments" extension, you have the ability to handle
  3631. MIDI-files.
  3632. >> >> When openening these Midi files with a QuickTime player (like
  3633. MoviePlayer,
  3634.  
  3635. [mucho snipto]
  3636.  
  3637. >> 
  3638. >> Just one problem: I had to click the "Options..." button before each
  3639. > file would
  3640. >> convert properly. If I didn't, I got a garbage movie. Just bringing up the
  3641. >> options dialog and clicking "Cancel" to go back to the save dialog was
  3642. enough.
  3643. >> 
  3644. >> By the way, the options dialog is fun: you get to see all the instruments
  3645. that
  3646. >> are installed, and there's a little keyboard so you can try them out!
  3647. > The file type needs to be set to 'Midi' and then you import them. But
  3648. > there's a bug and they may get imported as type TEXT. So you get a movie
  3649. > with a TEXT track and not a Midi track. The workaround, as Lawrence has
  3650. > found, is to first click the Options button. Then the Import will work.
  3651. > You only need the new and un-tested version of MoviePlayer to change the
  3652. > instruments *after* importing the Midi file to a movie.
  3653.  
  3654.  
  3655. ON a related question: I know that QT 2.0 has MPEG capabilities also. WHile
  3656. I'm aware that there's no software-based decompressor, I noticed that when I
  3657. tried to open a .mpg file off of the SIGGRAPH CD, the latest Movie Player
  3658. gave 
  3659. me the "CONVERT" button, just like when one converts a sound-track off of an 
  3660. audio CD.
  3661.  
  3662. Unfortunately, it wouldn't actually do anything, saying "this is not a
  3663. movie."
  3664.  
  3665. Is this a feature that wasn't completely implemented, or am I not completing
  3666. the process correctly?
  3667.  
  3668.  
  3669. Thanks in advance.
  3670.  
  3671.  
  3672. Lawson
  3673.  
  3674. +++++++++++++++++++++++++++
  3675.  
  3676. >From paulcho@io.org (Paul C. H. Ho)
  3677. Date: Wed, 19 Oct 1994 14:42:33 -0500
  3678. Organization: Pink Elephant Technologies
  3679.  
  3680. In article <jim-1710941525530001@reekes1.apple.com>, jim
  3681. _reekes@quickmail.apple.com (Jim Reekes) wrote:
  3682.  
  3683. > In article <1994Oct17.160700.34288@waikato.ac.nz>, ldo@waikato.ac.nz
  3684. > (Lawrence D'Oliveiro, Waikato University) wrote:
  3685. > > (sorry for the previous failures, our News system ran out of room...)
  3686. > > 
  3687. > > In article <sandvik-1610941318450001@17.255.38.231>, sandvik@apple.com
  3688. > (Kent San
  3689. > > dvik) writes:
  3690. > > >
  3691. > > > Yes, but you need the MoviePlayer version shipped with the 2.0b9 SDK
  3692. CD.
  3693. > > 
  3694. > > No you don't! I was trying this out over the weekend, with MoviePlayer
  3695. 1.0.
  3696. > > The MIDI files were off the CD-ROM that came with the July issue of
  3697. "Future
  3698. > > Music" magazine. I copied them to my hard disk, set their type to
  3699. "Midi", and
  3700. > > then did an "Open..." from within MoviePlayer. Sure enough, they showed
  3701. up,
  3702. > > and I was able to convert them.
  3703. > > 
  3704. > > Just one problem: I had to click the "Options..." button before each
  3705. > file would
  3706. > > convert properly. If I didn't, I got a garbage movie. Just bringing up
  3707. the
  3708. > > options dialog and clicking "Cancel" to go back to the save dialog was
  3709. enough.
  3710. > > 
  3711. > > By the way, the options dialog is fun: you get to see all the
  3712. instruments that
  3713. > > are installed, and there's a little keyboard so you can try them out!
  3714. > The file type needs to be set to 'Midi' and then you import them. But
  3715. > there's a bug and they may get imported as type TEXT. So you get a movie
  3716. > with a TEXT track and not a Midi track. The workaround, as Lawrence has
  3717. > found, is to first click the Options button. Then the Import will work.
  3718.  
  3719. I wrote a freeware program All Midi to do this in batch. Just drag and drop
  3720. (based on DropShell 2.0), no need to change file type or click the Options 
  3721. button. All Midi will automatically skip all non-midi file, so you can just
  3722. drop in a folder. I side step the bug by using Movie Data Exchange directly.
  3723.  
  3724. > You only need the new and un-tested version of MoviePlayer to change the
  3725. > instruments *after* importing the Midi file to a movie.
  3726.  
  3727. For the rest of us, download my shareware QuickMovie to change the
  3728. instruments after importing the Midi. It's in beta...
  3729.  
  3730. I wrote four QT midi programs with no document at all (except the header
  3731. files
  3732. that come with CW4). Any comment or suggestion on my midi stuff are welcome.
  3733. ftp://sumex-aim.stanford.edu/info-mac/grf/util/desktop-tv-120.hqx
  3734. ftp://sumex-aim.stanford.edu/info-mac/grf/util/screen-movie-110.hqx
  3735. ftp://sumex-aim.stanford.edu/info-mac/grf/util/quick-movie-10b2.hqx
  3736. ftp://sumex-aim.stanford.edu/info-mac/snd/util/all-midi-10.hqx
  3737.  
  3738. DesktopTV and ScreenMovie can record MIDI sequence and connect
  3739. your MIDI keyboard to QT2.0 music instruments via MIDI manager.
  3740.  
  3741. BTW, where can I find QuickTimeLib for QT 2.0. I can't link quick-movie with
  3742. the PPC compiler.
  3743.  
  3744. > -----------------------------------------------------------------------
  3745. > Jim Reekes, Polterzeitgeist   |     Macintosh Toolbox Engineering
  3746. >                               |          Sound Manager Expert
  3747. > Apple Computer, Inc.          | "All opinions expressed are mine, and do
  3748. > 2 Infinite Loop  MS 302-3KS   |   not necessarily represent those of my
  3749. > Cupertino, CA 95014           |       employer, Apple Computer Inc."
  3750.  
  3751. Paul C.H. Ho
  3752. Pink Elephant Technologies
  3753. paulcho@io.org
  3754. Paul_C.H._Ho@magic.ca
  3755. 74020.772@compuserve.com
  3756.  
  3757.  
  3758. +++++++++++++++++++++++++++
  3759.  
  3760. >From paulcho@io.org (Paul C. H. Ho)
  3761. Date: Thu, 20 Oct 1994 09:03:13 -0500
  3762. Organization: Pink Elephant Technologies
  3763.  
  3764. In article <1994Oct18.121506@west.cscwc.pima.edu>,
  3765. 103t_english@west.cscwc.pima.edu wrote:
  3766.  
  3767. > In article <jim-1710941525530001@reekes1.apple.com>, jim
  3768. _reekes@quickmail.apple.com (Jim Reekes) writes:
  3769. > > In article <1994Oct17.160700.34288@waikato.ac.nz>, ldo@waikato.ac.nz
  3770. > > (Lawrence D'Oliveiro, Waikato University) wrote:
  3771. > > 
  3772. > >> (sorry for the previous failures, our News system ran out of room...)
  3773. > >> 
  3774. > >> In article <sandvik-1610941318450001@17.255.38.231>, sandvik@apple.com
  3775. > > (Kent San
  3776. > >> dvik) writes:
  3777. > >> > In article <b.kobben-111094164513@kartoserver.frw.ruu.nl>,
  3778. > >> > b.kobben@frw.ruu.nl (Barend Kobben) wrote:
  3779. > >> >
  3780. > >> >> REMARK: I recently was shown that if you have Quicktime 2.0 +
  3781. "QuickTime
  3782. > >> >> Musical Instruments" extension, you have the ability to handle
  3783. MIDI-files.
  3784. > >> >> When openening these Midi files with a QuickTime player (like
  3785. MoviePlayer,
  3786. > [mucho snipto]
  3787. > >> 
  3788. > >> Just one problem: I had to click the "Options..." button before each
  3789. > > file would
  3790. > >> convert properly. If I didn't, I got a garbage movie. Just bringing up
  3791. the
  3792. > >> options dialog and clicking "Cancel" to go back to the save dialog
  3793. was enough.
  3794. > >> 
  3795. > >> By the way, the options dialog is fun: you get to see all the
  3796. instruments that
  3797. > >> are installed, and there's a little keyboard so you can try them out!
  3798. > > 
  3799. > > The file type needs to be set to 'Midi' and then you import them. But
  3800. > > there's a bug and they may get imported as type TEXT. So you get a movie
  3801. > > with a TEXT track and not a Midi track. The workaround, as Lawrence has
  3802. > > found, is to first click the Options button. Then the Import will work.
  3803. > > 
  3804. > > You only need the new and un-tested version of MoviePlayer to change the
  3805. > > instruments *after* importing the Midi file to a movie.
  3806. > > 
  3807. > ON a related question: I know that QT 2.0 has MPEG capabilities also. WHile
  3808. > I'm aware that there's no software-based decompressor, I noticed that when
  3809. I
  3810. > tried to open a .mpg file off of the SIGGRAPH CD, the latest Movie
  3811. Player gave 
  3812. > me the "CONVERT" button, just like when one converts a sound-track off of
  3813. an 
  3814. > audio CD.
  3815. > Unfortunately, it wouldn't actually do anything, saying "this is not a
  3816. movie."
  3817. > Is this a feature that wasn't completely implemented, or am I not
  3818. completing
  3819. > the process correctly?
  3820.  
  3821. It seem QT 2.0 come with 2 MPEG import components and a MPEG media handler
  3822. but don't have any MPEG codec. That's why it try to import with the 'eat '
  3823. component
  3824. and then run into problem later...
  3825.  
  3826. > Thanks in advance.
  3827. > Lawson
  3828. Paul C. H. Ho
  3829. Pink Elephant Technologies
  3830. paulcho@io.org
  3831. Paul_C.H._Ho@magic.ca
  3832. 74020.772@compuserve.com
  3833.  
  3834.  
  3835. +++++++++++++++++++++++++++
  3836.  
  3837. >From sandvik@apple.com (Kent Sandvik)
  3838. Date: Sat, 22 Oct 1994 16:07:14 -0800
  3839. Organization: Apple Computer, Inc. Developer Technical Support
  3840.  
  3841. In article <1994Oct17.160700.34288@waikato.ac.nz>, ldo@waikato.ac.nz
  3842. (Lawrence D'Oliveiro, Waikato University) wrote:
  3843. > No you don't! I was trying this out over the weekend, with MoviePlayer 1.0.
  3844. > The MIDI files were off the CD-ROM that came with the July issue of "Future
  3845. > Music" magazine. I copied them to my hard disk, set their type to "Midi",
  3846. and
  3847. > then did an "Open..." from within MoviePlayer. Sure enough, they showed up,
  3848. > and I was able to convert them.
  3849.  
  3850. Oh, the wonders of the Component Manager. I stand corrected.
  3851.  
  3852. --Kent
  3853.  
  3854. -- 
  3855. Kent Sandvik    sandvik@apple.com            New Media Analyst/Programmer
  3856. Private activities on the net not sponsored by the company I work for.
  3857.  
  3858. ---------------------------
  3859.  
  3860. >From emb121@hearst.cac.psu.edu (Eric Bennett)
  3861. Subject: Software volume locking: HELP!
  3862. Date: 18 Oct 1994 15:32:10 GMT
  3863. Organization: Penn State University
  3864.  
  3865. I have successfully used PBSetVInfo to software-lock a volume as
  3866. described in Inside Mac: Files on page 2-147, which deals with
  3867. PBSetVInfo (call PBGetVInfo, set bit 15 of the ioVAtrb field, and call
  3868. PBSetVInfo).  The only problem is that I cannot UNLOCK these volumes
  3869. using the same method (this time clearing bit 15)--I get the error
  3870. "volume locked" (error -43, I think). Yes, the volume is locked, but
  3871. shouldn't the command which can set the lock be able to unlock it? 
  3872. What toolbox call CAN I use to unlock a software-locked volume?
  3873.  
  3874. Thanks,
  3875. Ericb@psu.edu 
  3876.  
  3877. +++++++++++++++++++++++++++
  3878.  
  3879. >From psadri@sdcc13.ucsd.edu (Pasha Sadri)
  3880. Date: Tue, 18 Oct 1994 16:50:22 -0800
  3881. Organization: ucsd
  3882.  
  3883. In article <380ppq$nep@hearst.cac.psu.edu>, emb121@hearst.cac.psu.edu
  3884. (Eric Bennett) wrote:
  3885.  
  3886.  Yes, the volume is locked, but
  3887. > shouldn't the command which can set the lock be able to unlock it? 
  3888. > What toolbox call CAN I use to unlock a software-locked volume?
  3889.  
  3890. hi,
  3891.  
  3892. Apparantly not. I think you need to clear the bit manually using something
  3893. like Norton Disk Editor. I don't know how exactly but there was a post
  3894. sometime ago about how to do this. 
  3895.  
  3896. I know this isn't much help, but at least you won't try that again and
  3897. know what to look for. : )
  3898.  
  3899. Pasha Sadri
  3900. psadri@ucsd.edu
  3901.  
  3902. +++++++++++++++++++++++++++
  3903.  
  3904. >From emb121@hearst.cac.psu.edu (Eric Bennett)
  3905. Date: 19 Oct 1994 00:59:54 GMT
  3906. Organization: Penn State University
  3907.  
  3908. In article <psadri-1810941650220001@psadri.extern.ucsd.edu>
  3909. psadri@sdcc13.ucsd.edu (Pasha Sadri) writes:
  3910.  
  3911. > In article <380ppq$nep@hearst.cac.psu.edu>, emb121@hearst.cac.psu.edu
  3912. > (Eric Bennett) wrote:
  3913. >  Yes, the volume is locked, but
  3914. > > shouldn't the command which can set the lock be able to unlock it? 
  3915. > > What toolbox call CAN I use to unlock a software-locked volume?
  3916. > hi,
  3917. > Apparantly not. I think you need to clear the bit manually using something
  3918. > like Norton Disk Editor. I don't know how exactly but there was a post
  3919. > sometime ago about how to do this. 
  3920. > I know this isn't much help, but at least you won't try that again and
  3921. > know what to look for. : )
  3922.  
  3923. I know how to clear the bit with Norton Disk Editor--don't worry, I
  3924. haven't
  3925. done any damage to myself.  But clearing the bit with NDE seems like a
  3926. very non-Mac way of doing things.  I'm sure that there has to be a
  3927. toolbox
  3928. call that will do this--I just have no idea what it is (alternatively,
  3929. writing directly to the disk from within my program as NDE does ought
  3930. to
  3931. work, but I don't want to do that--I want to use a standard and SAFE
  3932. toolbox
  3933. call.
  3934.  
  3935. -Ericb@psu.edu
  3936.  
  3937.  
  3938.  
  3939. +++++++++++++++++++++++++++
  3940.  
  3941. >From lebra@cs.concordia.ca (LEBRA olivier)
  3942. Date: 19 Oct 1994 16:05:00 GMT
  3943. Organization: Dept. of Computer Science, Concordia University
  3944.  
  3945. In article <380ppq$nep@hearst.cac.psu.edu>, emb121@hearst.cac.psu.edu (Eric
  3946. Bennett) writes:
  3947. |> I have successfully used PBSetVInfo to software-lock a volume as
  3948. |> described in Inside Mac: Files on page 2-147, which deals with
  3949. |> PBSetVInfo (call PBGetVInfo, set bit 15 of the ioVAtrb field, and call
  3950. |> PBSetVInfo).  The only problem is that I cannot UNLOCK these volumes
  3951. |> using the same method (this time clearing bit 15)--I get the error
  3952. |> "volume locked" (error -43, I think). Yes, the volume is locked, but
  3953. |> shouldn't the command which can set the lock be able to unlock it? 
  3954. |> What toolbox call CAN I use to unlock a software-locked volume?
  3955. |> 
  3956. |> Thanks,
  3957. |> Ericb@psu.edu 
  3958.  
  3959.  
  3960.  
  3961. I will help you !
  3962. I have made a soft called DiskLocker that made what you want.
  3963. Before unlocking the disk with PBSetVInfo, you must update a global variable
  3964. used by the Finder. I do not remember its name and its structure but I will
  3965. check at home and I will reply to you again soon.
  3966.  
  3967.  
  3968. olivier lebra      olebra@aedi.insa-lyon.fr  or lebra@cs.concordia.ca 
  3969.  
  3970. +++++++++++++++++++++++++++
  3971.  
  3972. >From sbryan@maroon.tc.umn.edu (Steve Bryan)
  3973. Date: Fri, 21 Oct 1994 06:24:29 GMT
  3974. Organization: Sexton Software
  3975.  
  3976. > In article <380ppq$nep@hearst.cac.psu.edu>, emb121@hearst.cac.psu.edu
  3977. > (Eric Bennett) wrote:
  3978. >  Yes, the volume is locked, but
  3979. > > shouldn't the command which can set the lock be able to unlock it? 
  3980. > > What toolbox call CAN I use to unlock a software-locked volume?
  3981.  
  3982. I don't know if you already have the response but the trick is to update
  3983. the vcb queue elem before making the unlock toolbox call. You can get the
  3984. vcb queue elem either by "walking the vcb queue" and setting the
  3985. appropriate bit in place (I think it is one of the bits in the attribute
  3986. field) or make a couple of calls to PBGetVInfo and PBSetVInfo. This
  3987. strategy worked for a little control panel I wrote many years ago (ie the
  3988. source code is not handy). Good luck.
  3989.  
  3990. -- 
  3991. Steve Bryan                  InterNet: sbryan@maroon.tc.umn.edu
  3992. Sexton Software            CompuServe: 76545,527
  3993. Minneapolis, MN                   Fax: (612) 929-1799
  3994.  
  3995. +++++++++++++++++++++++++++
  3996.  
  3997. >From lebra@cs.concordia.ca (LEBRA olivier)
  3998. Date: 21 Oct 1994 19:08:39 GMT
  3999. Organization: Dept. of Computer Science, Concordia University
  4000.  
  4001. In article <sbryan-2110940024290001@dialup-3-184.gw.umn.edu>,
  4002. sbryan@maroon.tc.umn.edu (Steve Bryan) writes:
  4003. |> > In article <380ppq$nep@hearst.cac.psu.edu>, emb121@hearst.cac.psu.edu
  4004. |> > (Eric Bennett) wrote:
  4005. |> > 
  4006. |> >  Yes, the volume is locked, but
  4007. |> > > shouldn't the command which can set the lock be able to unlock it? 
  4008. |> > > What toolbox call CAN I use to unlock a software-locked volume?
  4009. |> > 
  4010. |> 
  4011. |> I don't know if you already have the response but the trick is to update
  4012. |> the vcb queue elem before making the unlock toolbox call. You can get the
  4013. |> vcb queue elem either by "walking the vcb queue" and setting the
  4014. |> appropriate bit in place (I think it is one of the bits in the attribute
  4015. |> field) or make a couple of calls to PBGetVInfo and PBSetVInfo. This
  4016. |> strategy worked for a little control panel I wrote many years ago (ie the
  4017. |> source code is not handy). Good luck.
  4018. |> 
  4019. |> -- 
  4020. |> Steve Bryan                  InterNet: sbryan@maroon.tc.umn.edu
  4021. |> Sexton Software            CompuServe: 76545,527
  4022. |> Minneapolis, MN                   Fax: (612) 929-1799
  4023.  
  4024.  
  4025. I think the simplest way to update the vcb queue is :
  4026. DefVCBPtr->vcbAtrb &= 0x7FFF;
  4027.  
  4028.  
  4029. -- 
  4030. *********************************************************************
  4031. *        olivier       * Until July 1996 : olebra@aedi.insa-lyon.fr *
  4032. *         lebra        * Until May 1995  : lebra@cs.concordia.ca    *
  4033. *********************************************************************
  4034. * 1950, Lincoln  App #1707  -  H3H 2N8  Montreal, Quebec  -  CANADA *
  4035. * Phone : (+1) 514-846 9781                                         *
  4036. *********************************************************************
  4037. *     "La simplicite est l'ultime forme de la sophistication."      *
  4038. *********************************************************************
  4039.  
  4040. +++++++++++++++++++++++++++
  4041.  
  4042. >From emb121@hearst.cac.psu.edu (Eric Bennett)
  4043. Date: 24 Oct 1994 16:18:11 GMT
  4044. Organization: Penn State University
  4045.  
  4046. In article <88387349253@jonathan.srcc.msu.su>
  4047. kluev@jonathan.srcc.msu.su (Kluev) writes:
  4048.  
  4049. > Try clear locked flag of vcbAtrb field of VCB describing volume.
  4050. > You can find VCB using GetVCBQHdr call and stepping via dLink
  4051. > field until you find the volume. This method, however, should
  4052. > be treated as modifying internal File Manager structures and
  4053. > should be avoided if possible.
  4054.  
  4055. I know--Inside Mac says DON'T PLAY WITH THE VCB--it is supposed to be
  4056. read only, not written to.  My question was, if I'm not supposed to
  4057. modify the VCB, how do I unlock the volume?  (Incidentally, when I
  4058. tried modifying the VCB, my machine locked up; however, since that's
  4059. the only suggestion I've gotten, I guess I'll try doing it again :).
  4060.  
  4061. -Ericb@psu.edu
  4062.  
  4063. ---------------------------
  4064.  
  4065. >From rang@winternet.com (Anton Rang)
  4066. Subject: Some string routines for the PowerPC
  4067. Date: 15 Oct 1994 21:29:50 GMT
  4068. Organization: Trillium Research, Inc.
  4069.  
  4070. Archive-name: ppc-string-utils.txt
  4071. Submitted-by: rang@winternet.com
  4072.  
  4073. This file implements some basic string routines for both C and Pascal
  4074. strings.  It's written in PowerPC assembly.  I did this mainly as a
  4075. learning experience; I was bored one day, and wanted to play with the
  4076. string instructions.
  4077.  
  4078. Routines implemented here are:
  4079.  
  4080.   strcpy and strcat -- both of these are about 30% faster than those
  4081.                provided by Apple or Metrowerks.
  4082.  
  4083.   pstrcpy and pstrcat -- very fast versions of the above for use with
  4084.              Pascal-style strings; much faster than those
  4085.              provided by Apple (PLstrcpy/PLstrcat).
  4086.  
  4087.   pstreq -- a fast equality test for Pascal-style strings.
  4088.  
  4089. If there's interest, I may develop and post more of these later.
  4090.  
  4091. I've appended a binhexed object library for those without an assembler.
  4092.  
  4093. An open question: Is there interest in developing a complete, or at
  4094. least subset, copyright-free, optimized, ANSI library for the PowerPC?
  4095. I see people complaining about Metrowerks' implementation, and neither
  4096. Metrowerks nor Apple has so far released a highly optimized library.
  4097. I'd rather see them concentrating on compiler technology, anyway.  If
  4098. there's enough interest, surely those of us on the net could compile a
  4099. reasonably complete library.  This would surely benefit all of the Mac
  4100. community.
  4101.  
  4102.   -- Anton
  4103.  
  4104. - -------- mylib.s
  4105. ;
  4106. ; Anton's library of handy string routines and such.
  4107. ;
  4108.  
  4109. ;
  4110. ; char *strcpy(char *, const char *)
  4111. ;
  4112. ; Copy a null-terminated string from one location to another; return the
  4113. first location.
  4114. ; This goes really fast if you use the POWER 'lscbx' instruction.  *sigh*
  4115. ;
  4116.  
  4117.         export  my_strcpy[DS]
  4118.         export  .my_strcpy[PR]
  4119.         
  4120.         toc
  4121.             tc  my_strcpy[TC], my_strcpy[DS]
  4122.         
  4123.         csect   my_strcpy[DS]
  4124.             dc.l    .my_strcpy[PR]
  4125.             dc.l    TOC[tc0]
  4126.             dc.l    0
  4127.         
  4128.         csect   .my_strcpy[PR]
  4129.  
  4130.         ; First, move R3 into R5, so we have a copy we can change.  Bias it
  4131. down by one byte.
  4132.         ; Bias R4 down too.
  4133.  
  4134.         subi    r5, r3, 1
  4135.         subi    r4, r4, 1
  4136.  
  4137.         ; Read a byte, store it, and compare it against zero.  Loop until we
  4138. find the zero.
  4139.         ; By issuing the compare before the store, we save one cycle in
  4140. branch resolution.
  4141.  
  4142. @0:     lbzu    r0, 1(r4)
  4143.         cmpwi   r0, 0
  4144.         stbu    r0, 1(r5)
  4145.         bne     @0
  4146.  
  4147.         ; All done.  Note that R3 has the return value already.
  4148.  
  4149.         blr
  4150.  
  4151. ;
  4152. ; void pstrcpy(unsigned char *, const unsigned char *)
  4153. ;
  4154. ; Copy a byte-counted string from one location to another.
  4155. ;
  4156.  
  4157.         export  pstrcpy[DS]
  4158.         export  .pstrcpy[PR]
  4159.         
  4160.         toc
  4161.             tc  pstrcpy[TC], pstrcpy[DS]
  4162.         
  4163.         csect   pstrcpy[DS]
  4164.             dc.l    .pstrcpy[PR]
  4165.             dc.l    TOC[tc0]
  4166.             dc.l    0
  4167.         
  4168.         csect   .pstrcpy[PR]
  4169.  
  4170.         ; Get the byte count, and add one to it to include the length byte.
  4171.  
  4172.         lbz     r5, 0(r4)
  4173.         addi    r5, r5, 1
  4174.  
  4175.         ; If the length is <= 32, we can complete the move in one pass.  We
  4176. assume that this
  4177.         ; is the most common case, and hence set the branch-predict bit here.
  4178.         ; (Why 32 bytes?  We have 8 non-volatile scratch registers, R5..R12,
  4179. to use.)
  4180.  
  4181. @0:     cmpwi   r5, 32
  4182.         ble+    @1
  4183.  
  4184.         ; OK...more than 32 bytes to move.  We'll move 28 bytes and then see
  4185. if we can finish.
  4186.         ; (Why 28 bytes?  We're holding the length in R5, so we only have 7
  4187. scratch registers.)
  4188.  
  4189.         subi    r5, r5, 28
  4190.  
  4191.         lswi    r6, r4, 28
  4192.         addi    r4, r4, 28
  4193.  
  4194.         stswi   r6, r3, 28
  4195.         addi    r3, r3, 28
  4196.  
  4197.         b       @0
  4198.  
  4199.         ; We complete the move here, mov    b       @0
  4200.  
  4201.         ; We complete the move here, moving between 1 and 32 bytes.
  4202.  
  4203. @1:     mtxer   r5
  4204.  
  4205.         lswx    r5, r0, r4
  4206.         stswx   r5, r0, r3
  4207.  
  4208.         blr
  4209.  
  4210. ;
  4211. ; char *strcat(char *, const char *)
  4212. ;
  4213. ; Concatenate a null-terminated string onto another; return the address of
  4214. the first string.
  4215. ;
  4216.  
  4217.         export  my_strcat[DS]
  4218.         export  .my_strcat[PR]
  4219.         
  4220.         toc
  4221.             tc  my_strcat[TC], my_strcat[DS]
  4222.         
  4223.         csect   my_strcat[DS]
  4224.             dc.l    .my_strcat[PR]
  4225.             dc.l    TOC[tc0]
  4226.             dc.l    0
  4227.         
  4228.         csect   .my_strcat[PR]
  4229.  
  4230.         ; First, move R3 into R5, so we have a copy we can change.  Bias it
  4231. down by one byte.
  4232.         ; Bias R4 down too.
  4233.  
  4234.         subi    r5, r3, 1
  4235.         subi    r4, r4, 1
  4236.  
  4237.         ; Walk down the first string to its end.
  4238.  
  4239. @0:     lbzu    r0, 1(r5)
  4240.         cmpwi   r0, 0
  4241.         bne     @0
  4242.  
  4243.         ; R5 is now one byte past the end of the string.  Go backwards to
  4244. bytes, so that
  4245.         ; it points just before the end of the string.
  4246.         
  4247.         subi    r5, r5, 2
  4248.  
  4249.         ; Read a byte, store it, and compare it against zero.  Loop until we
  4250. find the zero.
  4251.         ; By issuing the compare before the store, we save one cycle in
  4252. branch resolution.
  4253.  
  4254. @1:     lbzu    r0, 1(r4)
  4255.         cmpwi   r0, 0
  4256.         stbu    r0, 1(r5)
  4257.         bne     @1
  4258.  
  4259.         ; All done.  Note that R3 has the return value already.
  4260.  
  4261.         blr
  4262.  
  4263. ;
  4264. ; void pstrcat(unsigned char *, const unsigned char *)
  4265. ;
  4266. ; Concatenate a byte-counted string onto another.  This doesn't do any error
  4267. checking.
  4268. ;
  4269.  
  4270.         export  pstrcat[DS]
  4271.         export  .pstrcat[PR]
  4272.  
  4273.         toc
  4274.             tc  pstrcat[TC], pstrcat[DS]
  4275.  
  4276.         csect   pstrcat[DS]
  4277.             dc.l    .pstrcat[PR]
  4278.             dc.l    TOC[tc0]
  4279.             dc.l    0
  4280.  
  4281.         csect   .pstrcat[PR]
  4282.  
  4283.         ; Get the byte count of both strings.
  4284.  
  4285.         lbz     r6, 0(r3)
  4286.         lbz     r5, 0(r4)
  4287.  
  4288.         ; Note that lswx/stswx are defined to do nothing if the length (in
  4289. XER) is zero.
  4290.         ; If they weren't, we would want the following two lines, to check
  4291. that the
  4292.         ; concatenation is actually doing something.
  4293.  
  4294.         ; cmpwi r5, 0
  4295.         ; beqlr
  4296.  
  4297.         ; Add them together to get the new length; store it.
  4298.  
  4299.         add     r7, r6, r5
  4300.         stb     r7, 0(r3)
  4301.  
  4302.         ; Move destination address past old data (length + 1 bytes).
  4303.         ; Move source address past its length too (1 byte).
  4304.         
  4305.         addi    r3, r3, 1
  4306.         addi    r4, r4, 1
  4307.         add     r3, r3, r6
  4308.  
  4309.         ; If the length is <= 32, we can complete the move in one pass.  We
  4310. assume that this
  4311.         ; is the most common case, and hence set the branch-predict bit here.
  4312.         ; (Why 32 bytes?  We have 8 non-volatile scratch registers, R5..R12,
  4313. to use.)
  4314.  
  4315. @0:     cmpwi   r5, 32
  4316.         ble+    @1
  4317.  
  4318.         ; OK...more than 32 bytes to move.  We'll move 28 bytes and then see
  4319. if we can finish.
  4320.         ; (Why 28 bytes?  We're holding the length in R5, so we only have 7
  4321. scratch registers.)
  4322.  
  4323.         subi    r5, r5, 28
  4324.  
  4325.         lswi    r6, r4, 28
  4326.         addi    r4, r4, 28
  4327.  
  4328.         stswi   r6, r3, 28
  4329.         addi    r3, r3, 28
  4330.  
  4331.         b       @0
  4332.  
  4333.         ; We complete the move here, moving between 1 and 32 bytes.
  4334.  
  4335. @1:     mtxer   r5
  4336.  
  4337.         lswx    r5, r0, r4
  4338.         stswx   r5, r0, r3
  4339.  
  4340.         blr
  4341.  
  4342. ;
  4343. ; void pstrcatchr(unsigned char *dest, unsigned char src)
  4344. ;
  4345. ; Concatenate a single character onto a byte-counted string.
  4346. ;
  4347.  
  4348.         export  pstrcatchr[DS]
  4349.         export  .pstrcatchr[PR]
  4350.  
  4351.         toc
  4352.             tc  pstrcatchr[TC], pstrcatchr[DS]
  4353.  
  4354.         csect   pstrcatchr[DS]
  4355.             dc.l    .pstrcatchr[PR]
  4356.             dc.l    TOC[tc0]
  4357.             dc.l    0
  4358.  
  4359.         csect   .pstrcatchr[PR]
  4360.  
  4361.         ; Get the byte count of the string; add one to it and store it back.
  4362.  
  4363.         lbz     r5, 0(r3)
  4364.         addi    r5, r5, 1
  4365.         stb     r5, 0(r3)
  4366.         
  4367.         ; Store the character we want to concatenate at the end of the
  4368. string, and return.
  4369.  
  4370.         stbx    r4, r3, r5
  4371.         blr
  4372.  
  4373. ;
  4374. ; Boolean pstreq(unsigned char *s1, unsigned char *s2)
  4375. ;
  4376. ; Compare two byte-counted strings for equality; return true (1) if they're
  4377. equal.
  4378. ;
  4379.  
  4380.         export  pstreq[DS]
  4381.         export  .pstreq[PR]
  4382.  
  4383.         toc
  4384.             tc  pstreq[TC], pstreq[DS]
  4385.  
  4386.         csect   pstreq[DS]
  4387.             dc.l    .pstreq[PR]
  4388.             dc.l    TOC[tc0]
  4389.             dc.l    0
  4390.  
  4391.         csect   .pstreq[PR]
  4392.  
  4393.         ; First, get the byte count of both strings.
  4394.  
  4395.         lbz     r5, 0(r3)
  4396.         lbz     r6, 0(r4)
  4397.  
  4398.         ; If the byte counts aren't equal, fail immediately.
  4399.  
  4400.         cmpw    r5, r6
  4401.         bne     @fail
  4402.  
  4403.         ; OK, we have two strings of matching length.  Increment the
  4404. addresses to point to
  4405.         ; the actual text of the strings.
  4406.         
  4407.         addi    r3, r3, 1
  4408.         addi    r4, r4, 1
  4409.  
  4410.         ; If the length is <= 16, we can complete the comparison in one pass. 
  4411. We assume
  4412.         ; that this is the most common case, and hence set the branch-predict
  4413. bit here.
  4414.         ; (Why 16 bytes?  We have 8 non-volatile scratch registers, R5..R12,
  4415. to use.)
  4416.  
  4417. @0:     cmpwi   r5, 16
  4418.         ble+    @1
  4419.  
  4420.         ; OK...more than 16 bytes to compare.  We'll compare 12 bytes and
  4421. then see if we can
  4422.         ; finish.  (Why 12 bytes?  The length is in R5, so we only have 7
  4423. scratch registers,
  4424.         ; and we can only use whole registers for the string-load
  4425. instructions.)
  4426.  
  4427.         lswi    r6, r3, 12
  4428.         lswi    r9, r4, 12
  4429.  
  4430.         addi    r3, r3, 12
  4431.         addi    r4, r4, 12
  4432.         subi    r5, r5, 12
  4433.  
  4434.         ; Compare each of the register pairs R6/R9, R7/R10, R8/R11.  If any
  4435. differs, exit.
  4436.  
  4437.         cmp     0, 0, r6, r9
  4438.         cmp     1, 0, r7, r10
  4439.         cmp     2, 0, r8, r11
  4440.  
  4441.         bne     0, @fail
  4442.         bne     1, @fail
  4443.         bne     2, @fail
  4444.  
  4445.         b       @0
  4446.  
  4447.         ; We complete the comparison here, comparing between 1 and 16 bytes.
  4448.         ; If R5 is zero, we succeed immediately.
  4449.  
  4450. @1:     cmpwi   r5, 0
  4451.         beq     @succ
  4452.  
  4453.         ; Load the strings into R5..R8 and R9..R12.  Save R5 first.
  4454.  
  4455.         mr      r0, r5
  4456.         mtxer   r5
  4457.  
  4458.         lswx    r5, r0, r3
  4459.         lswx    r9, r0, r4
  4460.  
  4461.         ; Compare R5 against R9; if they differ, fail.
  4462.         ; If they're the same, and R0 is <= 4, succeed.
  4463.  
  4464.         cmp     0, 0, r5, r9
  4465.         cmpi    1, 0, r0, 4
  4466.         
  4467.         bne     0, @fail
  4468.         ble     1, @succ
  4469.  
  4470.         ; Compare R6 against R10; fail if different.  Succeed if R0 <= 8.
  4471.  
  4472.         cmp     0, 0, r6, r10
  4473.         cmpi    1, 0, r0, 8
  4474.         
  4475.         bne     0, @fail
  4476.         ble     1, @succ
  4477.  
  4478.         ; Compare R7 against R11; fail if different.  Succeed if R0 <= 12.
  4479.  
  4480.         cmp     0, 0, r7, r11
  4481.         cmpi    1, 0, r0, 12
  4482.         
  4483.         bne     0, @fail
  4484.         ble     1, @succ
  4485.  
  4486.         ; compare R8 against R12; fail if different, succeed if same.
  4487.  
  4488.         cmpw    r7, r11
  4489.         bne     @fail
  4490.  
  4491.         ; Success!
  4492.  
  4493. @succ:  li      r3, 1
  4494.         blr
  4495.  
  4496.         ; Failure
  4497.  
  4498. @fail:  li      r3, 0
  4499.         blr
  4500.  
  4501. - ----- mylib.s.o.hqx
  4502.  
  4503. --
  4504. Anton Rang (rang@winternet.com)
  4505.  
  4506. ---------------------------
  4507.  
  4508. >From blob@apple.com (Brian Bechtel)
  4509. Subject: Tech Notes on the World Wide Web, and History Is Made
  4510. Date: 19 Oct 1994 16:49:23 -0700
  4511. Organization: Apple Computer, Inc., Cupertino, California
  4512.  
  4513. New excitement on the digital traffic jam.  
  4514.  
  4515. Apple has now put all the tech notes (including the four new technotes
  4516. from the November developer CD which is _just_ going into the mail to
  4517. our developers right now as I type) on the Web.  Use Mosaic. Use MacWeb.
  4518. Use NetScape.  Explore.
  4519.  
  4520.  http://www.info.apple.com/dev/technotes/Main.html
  4521.  
  4522. The new tech notes include Jim Luther's "FL 37 Permission to do
  4523. What?!!?" (file permissions), Nitin Ganatra's "PS 02 Background-Only
  4524. Applications" (a revision of how to write faceless background
  4525. applications), Brian Bechtel's "OS 06 Control Strip Modules" (docs for
  4526. writing Control Strip modules, revised and corrected), and...
  4527.  
  4528.   Errata for Inside Macintosh:Networking
  4529.  
  4530. Yeah. That's right.  Rich Kubota and Scott Kuechle put together an
  4531. actual list of known errors in Inside Macintosh:Networking.  We have more
  4532. errata sheets under review, too.  When they get reviewed, we'll put them
  4533. up there as well.
  4534.  
  4535. For some help on getting started programming the Mac (and a desperate
  4536. plea for some feedback on said help), look at
  4537.  
  4538.  http://www.info.apple.com/dev/default.html
  4539.  
  4540. If you find this stuff useful, please let us know.  Thanks to Michelle
  4541. Wyner, ex-intern, and Mark Cookson for doing all the real work.
  4542.  
  4543. --Brian Bechtel     blob@apple.com     "My opinion, not Apple's"
  4544.  
  4545. If you don't know all these buzzwords, go read a different newsgroup
  4546. until you do.  Don't ask me; hell, I made up half of them myself.
  4547.  
  4548. ---------------------------
  4549.  
  4550. End of C.S.M.P. Digest
  4551. **********************
  4552.  
  4553.  
  4554. ---------------------------------------------------------------------
  4555.  
  4556. NOTE:  The following Macintosh file(s) are enclosed with this
  4557. message, in BinHex format.  If your mail system does not convert
  4558. BinHex files automatically, you will need to transfer the message to
  4559. a Mac and run the BinHex application to decode it.
  4560.  
  4561. Filename: mylib.s.o    Size:  1688 bytes
  4562.  
  4563. ---------------------------------------------------------------------
  4564.  
  4565. (This file must be converted with BinHex 4.0)
  4566.  
  4567.  
  4568.