TweetFollow Us on Twitter

Summer 91 - MACINTOSH Q & A

MACINTOSH Q & A

MACINTOSH DEVLOPER TECHNICAL SUPPORT

Q Why would using OpenResFile(fileName) cause a crash when I try to open a Macintosh font file that's already open?

A The problem stems from the fact that OpenResFile doesn't deal effectively with cases where the resource file is already open. Luckily, there are some relatively new Resource Manager calls that you can and should use instead. They're all documented in the Resource Manager chapter of Inside Macintosh Volume VI and in Macintosh Technical Note #214, New Resource Manager Calls.

The call of interest in your case is HOpenResFile. To use it, break down the vRefNum (actually WDRefNum) returned by Standard File into a real vRefNum and dirID by calling PBGetWDInfo, and pass those to HOpenResFile along with the file name. The important part, however, is the permissions byte. If you expect to modify the file, pass fsRdWrPerm in that field. If there's an error of any kind, expect HOpenResFile to return -1, which should serve as a signal that you need to call ResError to find out what went wrong.

Q My application, which has several units and objects, compiles under MPW 3.1 but not under MPW 3.2. Do forward references to objects work differently with MPW 3.2?

A MPW 3.2 has a new syntax for forward references to objects. Objects must be declared as externals, as follows:

TYPE
    TObjB = OBJECT; external; { MPW 3.2 requires this }
    TObjA = OBJECT(TObject)
        fFwdRef: TObjB;

        {methods}
END;

Note that by default the Pascal compiler includes information such as USES in its symbol table resources, so simply using the correct USES and external declarations may not be sufficient; you may find it necessary to invoke the Pascal compiler with the -rebuild option to force it to reconstruct its symbol table resources from scratch.

Q With the System 7.0 version of the LaserWriter driver, when the user selects Envelope from the Page Setup dialog, the page size returned by the driver is still a standard page: 8.5 x 11. How do you recommend that applications display the page size when the user has chosen a nonstandard page size?

A We recommend that you have the page preview show a full page instead of an envelope-sized page. The LaserWriter® driver supports a large number of PostScript ® devices, and it can't be sure whether the envelope will be fed on the right, left, or center of the paper tray. If you show the full page, a user can print on any device by putting the text in the correct location for that device.

Manufacturers of PostScript printers can add custom page sizes to the LaserWriter driver. If they do, the representation on the screen will be whatever they decide to define. Applications should not try to interpret custom page sizes. If your application ignores the results returned by the driver, you risk incompatibility down the road.Q Why is my Macintosh driver receiving a positive drive number under System 7.0 upon notification of an _Eject call?

A When the "driver wants a call on eject" bit is set in the flag bytes preceding a drive queue element, _Eject will issue a _Control call with a csCode of 7 to the driver. This _Control call is supposed to inform the driver which disk the OS is attempting to eject, by passing the drive number in the ioVRefNum field of the parameter block.

However, there's a bug in the ROM that only manifests itself when _Eject is given a volume reference number for a disk that has both the "nonejectable" and "driver wants a call on eject" bits set in the drive flag bytes. This bug causes the driver to receive the negative of the drive number, rather than the positive drive number.

The System 7.0 Finder has reversed the order of its calls to _UnmountVol and _Eject, causing it to pass the drive number to _Eject, which then passes it on to the driver correctly. Unfortunately, under previous systems, the Finder passed the volume reference number to _Eject, forcing developers to work around the bug by accepting negative drive numbers; however, a problem could occur now under System 7.0 if positive drive numbers weren't accepted as well.

A number of driver writers have notified us of this problem, but few (so far) have been adversely affected. As it has always been possible for utilities or applications to make _Eject calls with either a volume reference number or a drive number, the proper workaround is to handle both positive and negative drive numbers.

Q How many active ranges can a Macintosh application have on a shared file? If the answer is more than one, is the limit per application or per machine? If two ranges overlap, are they joined into one range? Can an application nest ranges? For example, if an application's user performs an action that forces a record to be locked and later the application locks the full range of the file, does the initial record lock disappear?

A The only way to determine the limit is to hit the limit and get a NoMoreLocks error. The number of range locks supported is a limit of the server platform, and that limit is shared by all users of the server (at least it is with Apple's AppleShare ® server software). With Apple's server- based version of AppleShare, approximately 40 locks per user are allowed (for example, if the server allows 25 users, there are 1000 locked ranges total; if the server allows 50 users, there are 2000 locked ranges total; and with File Sharing running under System 7.0, approximately 20 locks are allowed per user). Other vendors may allow more or fewer locked ranges on their implementations of an AppleTalk ® Filing Protocol (AFP) server. Notice that the numbers given are per user, not per application. It's assumed that a user probably won't need more than a few locks at a time on a single file.

You cannot have range locks that overlap. You'll get a RangeOverlap error from AFP. All the rules for range locking can be found in the AFP chapter of Inside AppleTalk (page 13-56). Additional information on AppleShare limits is available in the Dev Tech Answers library on AppleLink and on the Developer Essentials disc.

The February 1991 revision of Macintosh Technical Note #186 covers several important details about PBLockRange and PBUnlockRange that are not in Inside Macintosh .

Q Where can we get our hands on a fix to the ROM bug in the Macintosh IIci and Macintosh IIfx Memory Manager? Word has it that Apple wrote an INIT (MMInit) to fix this problem. Because we're using our application on both the Macintosh IIci and the IIfx, and the application uses many handles, this fix would be appreciated.

A Under System 6.0.x, Apple had identified a minor problem with the Memory Manager in the Macintosh IIfx, IIci, IIsi, and LC. This problem resulted in a performance degradation in an extremely small number of applications and did not cause system crashes. We believe this was an insignificant problem that affected few applications and very few customers. The problem was not new and was not caused by the introduction of System Software 6.0.5 or 6.0.7.

Based on developer feedback, customer feedback, and extensive in-house testing, Apple has identified very few affected applications. Because the problem affects only an extremely small number of developers, Apple is working with those developers to fix their applications. The best solution, however, is to upgrade to System 7.0, as it includes an enhancement to the Memory Manager to address this issue.

During extensive testing and research, Apple investigated a variety of solutions to enhance the Memory Manager performance. One area researched was a software solution called the Memory Manager INIT (a software "patch"), or MMInit as it's most often called. Through testing we discovered that this patch did not enhance Memory Manager performance and introduced risks such as decreased performance in some mainstream applications.

An unofficial version of the Memory Manager INIT has surfaced. This INIT should not be used, because it has been modified from Apple's experimental version and could cause data corruption, data loss, and crashes. Apple strongly urges that you discard the INIT if you have obtained a copy, and not use it. If any version of this INIT is used under System 7.0, it defeats the enhanced Memory Manager and reintroduces the bugs that were present in the System 6.0.x Memory Manager.

You may still wonder if you have been affected by this problem and how to avoid it under 6.0.x. The problem is most severe when allocating pointers in a heap with a rather large number of handles (on the order of tens of thousands). It's helpful to allocate enough master pointers (via MoreMasters) during initialization. If the Memory Manager has to call MoreMasters later on, not only could it fragment memory, but it could take an exceedingly long time. It's also helpful not to allocate thousands of handles. Besides requiring lots of master pointers, it takes the Memory Manager a long time to crunch through them during heap compaction.

Q Does setting the is32BitCompatible bit in the 'SIZE' resource have any effect in System 7.0?

A The alert box that was to be shown for applications with the 'SIZE' resource's is32BitCompatible flag disabled was found to be too confusing for an end user, so the is32BitCompatible flag is not used and the alert box is not displayed in the final System 7.0. (It is, however, displayed in A/UX 2.0 and 2.0.1.) This could change in the future.

Q Can you describe a procedure for extracting TrueType character outline data directly from the Macintosh system software?

A Future releases of Macintosh system software probably will include calls for accessing TrueType character outline data. In the meantime, sample code showing how to parse the 'sfnt' outline font resource is available on the Developer Essentials disc and on AppleLink in the Developer Support: Developer Services:Developer Technical Support:Developer Essentials:Sample Code folder.

Q Where can I find information on manipulating TrueType fonts under System 6.0.7?

A The System 6.0.7 TrueType INIT includes all the outline calls in System 7.0, so everything you need is in Inside Macintosh Volume VI. Use Gestalt's gestaltFontMgrAttr selector (described in the "Compatibility Guidelines" chapter of Volume VI, and available in System 6.0.4 and later) to determine whether TrueType is available on the machine in question, and then use outline calls freely and with abandon. The latest MPW release has the header files, called OutlineCalls. Use version 4.1 of Font/DA Mover to move outline fonts under System 6.0.7. Both the TrueType INIT and Font/DA Mover 4.1 are available on AppleLink and on the Developer Essentials disc, and you can license Font/DA Mover to include it with your product release by contacting Apple's Software Licensing group.

Q Why doesn't the StyleWriter ® like the SetLineWidth PicComment (182)? It prints the line at a 1-point weight.

A Most of Apple's QuickDraw printers do not support the SetLineWidth PicComment. Because there's no feedback as to whether the PicComment was successful, use of the comment is problematic. It's not regularly handled, except in PostScript printers.

The best way to make full use of a Macintosh printer's resolution is through the PrGeneral trap. You'll find it thoroughly described in the article "Meet PrGeneral, the Trap That Makes the Most of the Printing Manager" in Issue 3 of develop , and also covered in Inside Macintosh Volume V. PicComments are discussed in Macintosh Technical Notes #91 and #175.

Q How can a Macintosh in 24-bit addressing mode read from disk into a GWorld? If the GC card is installed, sometimes the GWorld is a 32-bit one cached on the card. How do we ensure the GWorld will be in main memory?

A When you create your GWorld, set the keepLocal flag in the flags field of the NewGWorld call. This ensures that the newly created GWorld will be in main memory where you can access it. Read your data into the GWorld and then clear the keepLocal flag with a call to SetPixelState. This will issue a "GWorld has been updated" type of message, causing the GWorld to be cached off to the GC card, giving you the best performance. When you want to load another image, call SetPixelState again, setting the keepLocal flag to bring the GWorld back to main memory. Using this technique you'll be able to load your GWorld and cache it too, and you won't need to recreate the GWorld each time you want to load more data into it.

Q What are the effects of InitCM, InitCRM, InitCRMUtilities, and similar calls to the Macintosh Communications Tools by nonapplications such as INITs or background processes? What effect do multiple INIT calls have on Communications Tools operations and any existing connections? What do these calls do, and when (and how many times) is it safe to call them?

A All these initialization calls deal with the process of loading the 'cmtb' resource into the system heap, putting entries into the Communications Toolbox (CTB) dispatch table with references to the current heap zone, and setting up various things having to do with resource management for the operation of the CTB. You can call them over and over again without damaging existing information.

With this new perspective, you can see that a synergy exists between operations of the CTB and the Resource Manager. The CTB needs to be in the appropriate heap zone when a ConnHandle is generated or referenced for it to operate as desired. If you're writing a background process that maintains its own persistent heap zone, you shouldn't have any difficulties using the CTB.

If you're writing an INIT, matters are more complex. You must SetZone(SystemZone) while performing all CTB operations (including initialization, CMGetProcID, and CMNew) to be sure the heap zone will persist after the INIT has completed. Possibly the reason for doing this at INIT time is to create ConnHandles that will persist for CTB access at a later time. It seems reasonable that ConnHandles thus created require a SetZone(SystemZone) by any routine that needs to access them for Read/Write/Status/Delete operations.

Q Is there some kind of bug with the Macintosh Balloon Help feature in System 7.0? It goes into the application and uses the text from the 'STR#' resource ID 4001 instead of the 'STR#' resource ID 4001 of Finder Help.

A The System 7.0 Help Manager stores its balloon strings in the Finder TM Help resource file. Under certain circumstances, the Help Manager will access the string resources in your application before it accesses the resources of the Finder Help file. Consequently, problems will occur if your application contains certain 'STR#' and 'STR ' resources. There are only two circumstances in which your application may be affected. First, if your application uses a 'STR#' resource with ID 4001, the Help Manager will use the first string resource of the list instead of the corresponding resource in Finder Help. When the pointer is placed over your application icon's text on the desktop, the default text, "Change the icon's name by clicking on the name and typing," will be changed to the text stored in 'STR#' 4001 of your application.

Second, if your application has a 'STR ' resource with ID 17251, the Help Manager will use that string resource instead of the corresponding string resource in Finder Help. The default text, "This is an application--a program with which you . . . " will be changed to the text stored in 'STR ' 17251 of your application.

To avoid these problems, you have a few options. You can create your own 'hfdr' resource to override 'STR ' 17251, or you can avoid using 'STR ' 17251 and 'STR#' 4001. If you must use 'STR#' 4001, paste the text "Change the icon's name by clicking on the name and typing" into the first string and use the rest of the strings for your application's use.

Q How can I determine the intrinsic styles supported by a particular PostScript font?

A To find the styles that are supported by a particular font, you need to access one of two tables. To find the screen fonts that are available, you can use the font association table, shown on page 38 of Inside Macintosh Volume IV. Each entry in the table contains the size and style of the font, as well as the resource ID. Each font in this table should be available for the screen.

When you print a font to a PostScript printer, the Font Manager uses the style-naming table in the family record to create a PostScript name for the font. The table has a list of strings, followed by an entry for each style supported by that particular font. A table for Times might look like this:

ValueDescriptionHex Dump
9Number of Strings <INTEGER>09
"Times"Basename of font05, 54, 69, 6D, 65, 73
6, 7Suffix index for style 102, 06, 07
Pascal String that looks like:
String[0] := CHR(2);
String[1] := CHR(6);
String[2] := CHR(7);
6,8Suffix index for style 202, 06, 08
6,9Suffix index for style 302, 06, 09
6,8, 9Suffix index for style 403, 06, 08, 09
"-"Suffix 101, 2D
"Roman"Suffix 205, 52, 6F, 6D, 61, 6E
"Bold"Suffix 304, 42, 6F, 6C, 64
"Italic"Suffix 406, 49, 74, 61, 6C, 69, 63

Except for the first entry, all entries in the table are stored as Pascal strings with a length byte followed by one byte for each character in the string.

The table is used to build the PostScript font name for a particular style. This is a little complicated, so hang on. Let's look at the table again, with each line numbered, and without all the hex:

0: 9
1: "Times"
2: 6, 7
3: 6, 8
4: 6, 9
5: 6, 8, 9 6: "-"
7: "Roman"
8: "Bold"
9: "Italic"

Entry #0 is the number of strings in this table. Entry #1 is the basename of the font. Entries #6- 9 are the suffixes that will be appended to the basename for particular styles. Entries #2-5 are the indexes of the suffixes required to create the PostScript names for the different styles (entry 2 = plain, 3 = bold, 4 = italic, and 5= bold+italic).

Let's use entry #2 to build a name: 1. Always start with the basename: "Times" 2. Append the first suffix, #6 in this case: "Times-" 3. Append the second and last suffix, #7: "Times-Roman"

The style-naming table is not documented in the Font Manager chapter of Inside Macintosh because it's too specific to PostScript. Instead, it's documented in the LaserWriter Reference (Addison-Wesley) on pages 28-35. The manual's description doesn't include examples, so the above example makes things easier to understand.

Q What is the easiest way to reset a Macintosh color map or palette to the default system color map?

A Use RestoreDeviceClut(gd:GDHandle). You pass the handle to the device in question, or nil if you want all devices reset. The call is described in the Palette Manager chapter ofInside Macintosh Volume VI.

Q If System 7.0 were the Seven Dwarfs, which dwarf would Virtual Memory be?

A Sneezy.




Kudos to our readers who care enough to ask us terrific and well thought-out questions. The answers are supplied by our teams of technical gurus; our thanks to all. Special thanks to Pete "Luke" Alexander, Mark Baumwell, Jim "Im" Beninghaus, Neil Day, Tim Dierks, Godfrey DiGiorgi, Steve Falkenburg, Bill Guschwan, C. K. Haun, Pete Helme, Dave Hersey, Dennis Hescox, Mark Johnson, Jim Luther, Jim Mensch, Bill Mitchell, Guillermo Ortiz, Greg Robbins, Jack Robson, Kent Sandvik, Gordon Sheridan, Paul Snively, Bryan Stearns, Forrest Tanaka, Vincent Tapia, and Scott "Zz" Zimmerman for the material in this Q & A column. *

Have more questions? Need more answers? Take a look at the Dev Tech Answers library on AppleLink (updated weekly) or at the Q & A stack on the Developer Essentials disc.*

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »

Price Scanner via MacPrices.net

Amazon is offering a $100 discount on every M...
Amazon is offering a $100 instant discount on each configuration of Apple’s new 13″ M3 MacBook Air, in Midnight, this weekend. These are the lowest prices currently available for new 13″ M3 MacBook... Read more
You can save $300-$480 on a 14-inch M3 Pro/Ma...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer new Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more

Jobs Board

Relationship Banker - *Apple* Valley Financ...
Relationship Banker - Apple Valley Financial Center APPLE VALLEY, Minnesota **Job Description:** At Bank of America, we are guided by a common purpose to help Read more
IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.