Nov 92 Tips
|Column Tag:||Tips & Tidbits
Tips & Tidbits
By Neil Ticktin, Editor-in-Chief
This column is your opportunity to spread the word about little bits of information that you find out about. These tidbits can be programming related or they can be user tips that are particularly useful to programmers.
MacTutor will credit, in subscriptions or orders, $25 for every tip used, and $50 for the Tip of the Month. To submit a tip, send in a letter to the magazine.
Remember, AppleLink is our preferred communication method, but feel free to send something via America Online, GEnie or US Mail. If you do send snail mail, enclose a printed copy and a disk copy of the letter so that it does not have to be retyped.
Let us know what you think. Remember, this is your magazine. Try em out and let us know...
Tip of the Month
If your application heap is getting trashed and you're not sure where it's happening, instruct your code to break on certain routines and perform the MacsBug heap check periodically like:
BR MyRoutine ';hc;g'
This will break on MyRoutine each time, perform a heap check, and will then continue as long as the heap is ok. When the heap goes bad, MacsBug will stay visible and you can then figure out where you came from and "home in" on the culprit.
Another useful technique is to include a debugging statement directly in your code. If I know my heap is being trashed I usually insert the following line of code around one or more of my routines or Toolbox calls:
BlockMove(sourcePtr, destPtr, GetPtrSize(sourcePtr));
This example will check the heap before and after my call to _BlockMove. If the heap is bad either time MacsBug will stay visible and allow me to examine the heap. This is a useful technique since I can see exactly which routine caused the heap to go bad.
- Joe Zobkiw, Forum Leader
America Online Macintosh Music & Sound Forum
PICT vs. PICT?
Many users ask what the difference between a PICT resource and a PICT file is. The answer is, 512 bytes. Really!
A PICT file is exactly the same format as a PICT resource except the file has a 512 byte header attached and is stored in the data fork as opposed to as a resource in the resource fork. Many times this header is filled with zeros but it is there and available for use by the program that saves the PICT file in the first place. You don't have to take advantage of it but you do have to include it.
So, if you want to save a PICT resource as a PICT file, add a 512 byte header of zeros before it and FSWrite it to a file of type PICT. To convert a PICT file into a PICT resource (or for use with the DrawPicture() Toolbox routine) simply strip the 512 byte header from the file!
- Joe Zobkiw
Forum Leader, America Online
Macintosh Music & Sound Forum