TweetFollow Us on Twitter

Smart Docs
Volume Number:4
Issue Number:2
Column Tag:C Workshop

Smart Documents

By Joel McNamara, Watercourse Software, Bellevue, WA

Forked Tongue Programming: Data Forks, Resource Juggling, and Stand Alone Documents

Most developers are quick to realize that a Macintosh file, whether application or not, could easily be an advertisement for Double Mint Gum. Yes, it’s two, two, two files in one. As “Inside Macintosh” is quick to point out, “Every file has a resource fork and a data fork (either of which may be empty). The resource fork of an application contains not only the resources used by the application but also the application code itself. The data fork of an application can contain anything an application wants to store there.” Big deal. Even most novices know that when an application creates a document, it places the data into the data fork of a file. Pretty basic stuff, even a bit dull and boring for most MacTutor readers.

But let’s step beyond the obvious for a moment, and concentrate on the quote “can contain anything an application wants to store there.” If we can put anything in there, how about data that only the application could access. No reading in other files, but just operating on the information found within its data fork. Think of it as a stand alone document. Perhaps a word processor that generates a file when double clicked will run itself. Or a chart program that makes files you could modem to a business associate without him needing the creator application. Something a little like “Glue,” where you have the ability to view an application’s output without needing the application. Runtime versions of data bases incorporate these features. Even Microsoft is rumored to be considering a version of “Excel” that will create stand alone spreadsheets.

Pretty neat stuff, but probably too tricky for the average programmer, right? Wrong. The secret lies within effectively using the resource and data forks.

Stand Alone Document Theory

The reasons for developing such stand alone documents are quite obvious; the ability to disseminate information without the need of a “mother” application to access it; being able to address larger audiences with your output since not everyone needs the creator; not needing sophisticated knowledge of an application to use the information found in a document. All of these points and more make it worthwhile to consider incorporating the ability to generate stand alone documents in your applications.

In thinking about such a project, there are several things to consider. The first is the functionality you want the document to have. More than likely you’re not going to want the stand alone file to do everything the original application does. Therefore, you’ll need to include some secondary code that will simply display, scroll, print, or do whatever.

But where does one put the code and resources actually needed to run the document? If there is one set of CODE resources that run the main application and another set that will run the stand alone document, won’t they conflict and cause problems? Two theories can be used in developing stand alone document generators. The first espouses putting all the required resources into a template file. The generator then simply copies the template, gives the copied file a new name, and inserts the desired information into the data fork. This is the technique used in the stand alone text generator “Take A Letter.” The second method is cleaner, eliminating the need for template files. The generator program actually contains the code needed to run a stand alone document, although it may masquerade as another resource. The generator creates a new file, copies in the resources, renames them, fills the data fork, and sets the file’s attributes to be an application.

Stand Alone Document Practice

Enough theory, and on to the practice. What will be demonstrated is how to construct a stand alone document generator that works with MacPaint format documents. Three sources are included here. The first (PaintDisplay.c) is code for a program that loads a Paint file stored in its data fork and then shows the upper left hard corner of the bit mapped image. The second listing (PostCard.c) is for an application called PostCard that builds a stand alone Paint document. (The code from PaintDisplay will be inserted into this document generator.) And finally, PostCard.r is the RMaker file. Although the sources are in Lightspeed C, the techniques should be general enough to apply to a different variation of C or even another language. (Lightspeed info: Both projects (PaintDisplay proj and PostCard proj) should include MacTraps plus their own respective source files and be set to build applications. PostCard’s creator type should be ‘PCRD’.)

The first step is to compile PaintDisplay.c. This source contains a standard algorithm for displaying an image from a MacPaint format file. It initializes everything, opens up its data fork, grabs bytes, puts up a window, displays the left corner of the Paint document, and waits for a mouse click to quit. All in one breath. Don’t try to run it quite yet though. If you do, it will be looking in its own data fork for something that isn’t there yet, and your curiosity will be rewarded with a bomb.

The only real item in the code that needs discussing, is how one goes about accessing the data fork. To quote from the source:

if (GetVol(&thisVolume,&vRef) != noErr)
 ErrorRoutine(FALSE,0);
GetAppParms(&thisProgram,&temp,&thisHandle);
if (FSOpen(thisProgram,vRef,&srcFile) != noErr)
 ErrorRoutine(TRUE,srcFile);

The first step is to determine what volume the application is on with a GetVol() call. Next, use GetAppParms() to return the name of the current application. Now pass the application’s name and the volume reference number to FSOpen(). It will oblige by opening up your application’s data fork.

Resource Rascality

Once you’ve compiled PaintDisplay, the next task is to use RMaker on the PostCard.r file. This file contains the resources for the menus, dialogs, bundles, icons, etc. for the PostCard application. It also has the necessary resources to be used in creating the stand alone document.

An often overlooked feature of RMaker is the ability to copy specific resources from one file to another during the compile stage. By using the “.R” command you could load, let’s say, a font from an existing file into the resource file you’re currently compiling. The format is:

Type FONT = GNRL* the new resource type (FONT)
,8 * the new resource ID
.R * the RMaker directive
Fonts FONT 12  * the file “Fonts” and the resource
 * (FONT 12) to copy into the new resource

RMaker is pretty lax as to letting you get away with things in certain areas. This feature proves beneficial when building program generating applications. As mentioned before, the biggest problem in writing an application that builds another, is where to stick the code that will be spawned off. Obviously you can’t have a program with two CODE 0 resources, at least without the potential for serious problems.

The solution is to build a new resource type of your choosing, and then through RMaker, stuff the CODE into it. For example:

Type FAKE = GNRL * creates a resource type called FAKE...
,0 * with an ID of 0 
.R * tells RMaker to load in something
SuperEdit CODE 0 * else, i.e., the jump table from
 * a file called “SuperEdit”

This is what’s happening in PostCard.r. The previously compiled code from PaintDisplay is being read in, and then assigned a new type and identification. The CODE resource is still the same, but it’s gone into hiding by changing its name. It’s as easy as that. When the resource file is compiled, you’ll have your CODE just sitting there, ready to use, but disguised as something else that won’t conflict with the the program that will be using it to create another application.

Taking a peek with ResEdit at the results. FAKE and DUMY are really code resources, but with their new identities, don’t conflict with code resources found in the application that will use them.

Two words of advice on using RMaker in such a fashion. The first is, RMaker frowns on using a source file with a space in its name. Therefore, “My File” will cause you problems but “MyFile” will not. The second caveat is to be aware of path names. If all of your formats look all right, but RMaker still is complaining, odds are you have an improperly laid out path. Double check it.

You’ll notice in the PostCard.r file, more than just CODE resources are being changed. Remember, all compilers are not created equal. Some will generate just two code segments (for under 32k of code, of course): 0 - the jump table, and 1 - the actual code . Others, Lightspeed C for example, will generate more than two code segments and a variety of other resource types where data is stored. That’s what all the CRELs, DATAs, ZEROs, etc. are all about. When you are transferring and converting code resources, be sure you get everything your particular compiler needs for the application to run. At first put everything in, but after a while try some experimenting. At times you’ll find you don’t need all of the data and support resources.

Resource Moving Without ResEdit

The last step in the process is to compile PostCard.c. The compiled resources from PostCard proj.Rsrc are copied in, and the application is ready to run.

From the Macintosh’s perspective, here’s what happens when the user selects “Make a PostCard...” from the menu:

The SFPut() routine is called to select a name and location for the new file. CreateResFile() is used to create the named file. Finder attributes are then set, and the resource fork of the new file is opened.

Now the fun stuff. The code determines what the resource reference number of the current application is (in this case PostCard). It then makes use of a programmer defined function called ResTransfer().

ResTransfer(sourceRes, sourceID, destRes, destID)
ResType sourceRes, destRes;
intsourceID, destID; 
{
Handle  codeHandle;
 codeHandle = NewHandle(0);
 codeHandle = GetResource(sourceRes,sourceID);
 UseResFile(resRef);
 DetachResource(codeHandle);
 AddResource(codeHandle, destRes, destID, “\p”);
 if (ResError() != noErr) {
   DoMessage(“\pSorry, couldn’t copy the required resource.”);
 myError = 1;
 }
}

ResTransfer() is passed the resource type and ID of the resource to be copied, along with what type of resource and what ID number you want the copy to appear as. GetResource() is used to get a handle to the resource to be copied. UseResFile() is then called with the resource reference file number of the application that will be created. This tells the resource manager to only deal with the resource fork of the new stand alone document.

As per “Inside Macintosh,” the resource to be copied is detached, and then added to the new application with AddResource(). AddResource() is passed the handle to the resource, along with information concerning type and identification. If for some reason it can’t be added, an error handling routine is alerted.

ResTransfer() is called repeatedly for all of the resources needed to be placed in the stand alone document. At first BNDL, FREF, ICN#, etc. are moved in, giving the application its own unique type and icon. Next the FAKE and DUMY resources are copied and then converted back to their original types and IDs.

Once all the resources have been moved and/or changed, UpdateResFile() is used to tell the resource manager the new file needs updating, effectively adding and writing all of the resources. The stand alone document’s resource fork is then closed, and UseResFile() is called to revert the current resource fork back to PostCard.

With the resources in place, SFGet() is called to select the Paint format file to be read in. Its data fork is read and then written to the stand alone document’s data fork. With no errors reported, the stand alone document has now been created and is ready to run!

Final Thoughts

Needless to say, PostCard ain’t very fancy. If one was to do it right, scrolling, desk accessory support, more error handling, perhaps even printing and the ability to save a full MacPaint format document out of it should be included in the PaintDisplay code. Did I just hear the basis for a shareware product?

Also keep in mind that PostCard just demonstrates the idea of stand alone documents. Although application generators like it are useful, stand alone documents would really be best created by say a “WriteNow” or “SuperPaint.” Ideally, the entire process would be incorporated as a function in an actual, full blown program where the user would simply select a menu item to create the stand alone file.

One potential argument to the idea of stand alone documents is more code overhead in the original program. However, with a little thought and planning this can easily be avoided by segmenting the program so the main application and the one to be generated would share some common code. Even if an extra 15 or 20k went into the final product, users would likely justify the size increase because of the benefits.

As you can see, creating stand alone documents isn’t that difficult. The problems with data and resources can easily be overcome, with the end result being things like self running documentation, double clickable desktop presentations, or stand alone spreadsheets. Hopefully in the near future we’ll be seeing more of stand alone documents. But for now, why don’t you give your own a try.

/* 
 * PostCard, version 1.0, Lightspeed C
 * demonstrates using data forks and resource tricks
 * Copyright 1987 by Joel McNamara - All Rights Reserved
 * for MacTutor Magazine
 * initial coding - October 12, 1987
 */
#include“MacTypes.h”
#include“QuickDraw.h”
#include“WindowMgr.h”
#include“EventMgr.h”
#include“MenuMgr.h”
#include“FileMgr.h”
#include“MemoryMgr.h”
#include“ResourceMgr.h”
#include“StdFilePkg.h”
#include“OSUtil.h”
#include“DialogMgr.h”

/* defines... */
#define MessageDLOG255
#define AboutDLOG256
#define HelpDLOG 257
#define AppleMENU1
#define About    1
#define FileMENU 255
#define Quit1
#define CommandMENU256
#define MakeCard 1
#define Help3

/* globals... */
Boolean done;
char    theString[256];
MenuHandleAppleMenuHndl, FileMenuHndl, CommandMenuHndl;
EventRecord theEvent;
DialogPtr theDialog;
int     resRef,dummy,myError;

/* main */
main()
{
 Initialize();
 do{
 MainLoop();
 }while(!done);
} 
/* as always... */
Initialize()
{
 InitGraf(&thePort);
 InitFonts();
 InitWindows();
 InitMenus();
 TEInit();
 InitDialogs(0);
 InitCursor();
 FlushEvents(everyEvent, 0);
 SetUpMenus();
 done = FALSE;
 myError = 0;
}

/* make the menus */
SetUpMenus()
{
 AppleMenuHndl = GetMenu(AppleMENU);
 AddResMenu(AppleMenuHndl, ‘DRVR’);
 InsertMenu(AppleMenuHndl, 0);
 FileMenuHndl = GetMenu(FileMENU);
 InsertMenu(FileMenuHndl, 0);
 CommandMenuHndl = GetMenu(CommandMENU);
 InsertMenu(CommandMenuHndl, 0);
 DrawMenuBar();
}
/* generic dialog displayer */
DoDialog(theDLOG)
inttheDLOG;
{
 theDialog = GetNewDialog(theDLOG, 0, -1);
 DoButton(theDialog);
 ModalDialog(0, &dummy);
 DisposDialog(theDialog);
}
/* message display routine */
DoMessage(theMessage)
Str255  theMessage;
{
 theDialog = GetNewDialog(MessageDLOG, 0, -1);
 ParamText(theMessage, “\p”, “\p”, “\p”);
 DoButton(theDialog);
 ModalDialog(0, &dummy);
 DisposDialog(theDialog); 
}
/* loop until we’re done */
MainLoop()
{
 SystemTask();
 if (GetNextEvent(everyEvent,&theEvent)) {
 switch (theEvent.what) {
 case mouseDown:
 DoMouseDown();  
 break;
 default:
 break;
 }
 }
}
/* if we have a mouse down */
DoMouseDown()
{
WindowPtr whichWindow;
intthePart;
 thePart = FindWindow(theEvent.where,&whichWindow);
 switch(thePart) {
 case inMenuBar:
 DoMenu();
 break;
 case inSysWindow:
 SystemClick(&theEvent, whichWindow);
 break;
 default:
 break;
 }
}

/* if a menu hit then... */
DoMenu()
{
long menuChoice;
 menuChoice = MenuSelect(theEvent.where);
 DoMenuItem(menuChoice);
}
/* which menu was selected? */
DoMenuItem(menuChoice)
long menuChoice;
{
int theMenu,theItem;
 if (menuChoice != 0 ) {
 theItem = menuChoice;
 theMenu = (menuChoice >> 16);
 switch (theMenu) {
 case AppleMENU:
 DoDA(theItem);
 break; 
 case FileMENU:
 done = TRUE;
 break;
 case CommandMENU:
 DoCommands(theItem);
 default:
 break;
 }
 HiliteMenu(0);
 }
}
/* the apple menu was hit */
DoDA(theItem)
int theItem;
{
int accNumber;
 if (theItem == About)
 DoDialog(AboutDLOG);
 else{
 GetItem(AppleMenuHndl,theItem,theString);
 accNumber = OpenDeskAcc(theString);
 }
}
/* the commands menu was hit */
DoCommands(theItem)
int theItem;
{
 switch(theItem) {
 case MakeCard:
 ConvertFile();
 break;
 case Help:
 DoDialog(HelpDLOG);
 break;
 default:
 break;
 }
}
/* make a postcard */
ConvertFile()
{
char*   buffer;
long    theEOF;
intcurrentResRef,refNum,destRef;
Handle  codeHandle;

Point   myPoint;
SFReply paintReply, myReply;
SFTypeListmyTypes;
FInfo   myFInfo;
OSErr   myErr;   
 myTypes[0] = ‘PNTG’;
 myPoint.h = 90;
 myPoint.v = 90;

 /* first we create the application */ 
 DoMessage(“\pFirst name the PostCard you want to create.”);
 SFPutFile(myPoint, “\pEnter PostCard name:”, “\pMy PostCard”, 0,
 &myReply);
 if (myReply.good)
 {
 SetVol(0, myReply.vRefNum);
 CreateResFile(myReply.fName);
 /* make it what we want... */
 myFInfo.fdType = ‘APPL’;
 myFInfo.fdCreator = ‘PDIS’;
 myFInfo.fdFlags = fHasBundle;
 myFInfo.fdLocation.h = 0;
 myFInfo.fdLocation.v = 0;
 SetFInfo(myReply.fName, myReply.vRefNum, &myFInfo);
 /* open its resource fork */
 resRef = OpenResFile(myReply.fName);
 if (resRef != -1)
 {
 /* get PostCard’s resource ref number and then
 start moving the resources */
 currentResRef = CurResFile();
 /* first the obvious ones */
 ResTransfer(‘BNDL’,129, ‘BNDL’,128);
 ResTransfer(‘PDIS’,0,’PDIS’,0);
 ResTransfer(‘FREF’,128,’FREF’,128);
 ResTransfer(‘ICN#’,129,’ICN#’,128);
 /* now grab the FAKEs and make them CODE */
 ResTransfer(‘FAKE’,0,’CODE’,0);
 ResTransfer(‘FAKE’,1,’CODE’,1);
 ResTransfer(‘FAKE’,2,’CODE’,2);
 /* finally get the DUMYs and convert them */
 ResTransfer(‘DUMY’,0,’CREL’,2);
 ResTransfer(‘DUMY’,1,’DATA’,0);
 ResTransfer(‘DUMY’,2,’DREL’,0);
 ResTransfer(‘DUMY’,3,’STRS’,0);
 ResTransfer(‘DUMY’,4,’ZERO’,0);

 /* update the new application, close it, make PostCard
 the current open resource fork */
 UpdateResFile(resRef);
 CloseResFile(resRef);
 UseResFile(currentResRef);
 
 /* see if we have any errors - open the application */
 if ( (FSOpen(myReply.fName, myReply.vRefNum, &destRef) != noErr) || 
(myError == 1) ) {
 DoMessage(“\pSorry a resource error prevented the PostCard from being 
created.”); 
 FSDelete(myReply.fName,myReply.vRefNum);
 myError = 0;    
 }
 else
 { 
 /* here we select the paint file we want to convert */
 DoMessage(“\pNow select the Paint file you want to display.”);
 SFGetFile(myPoint, “\p”, 0, 1, myTypes, 0, &paintReply);
 if (paintReply.good)
 { 
 /* open, read, and write into the document */
if (FSOpen(paintReply.fName, paintReply.vRefNum, &refNum) == noErr)
 {
 if ( GetEOF(refNum, &theEOF) != noErr)
 myError = 1;
 buffer = NewPtr(theEOF);
 if ( FSRead(refNum, &theEOF, buffer) != noErr)
 myError = 1;
 if ( FSWrite(destRef, &theEOF, buffer) != noErr)
 myError = 1;
 myErr = FSClose(refNum);
 myErr = FSClose(destRef);
 if (myError != 1)
 DoMessage(“\pYour PostCard has been created!”);
 } 
 }
 else
 {
 /* get rid of file we’ve created */
 FSDelete(myReply.fName,myReply.vRefNum);    
 }
 }
 
 }
 else
 myError = 1;
 
 if (myError == 1) {
 /* opps, problems - blitz the file */
 DoMessage(“\pSorry an error prevented the PostCard from being created.”); 

 FSDelete(myReply.fName,myReply.vRefNum);
 }
 }
}

/* grab a resource and rename it routine */
ResTransfer(sourceRes, sourceID, destRes, destID)
ResType sourceRes, destRes;
intsourceID, destID; 
{
Handle  codeHandle;
 codeHandle = NewHandle(0);
 
 /* get the source resource */
 codeHandle = GetResource(sourceRes,sourceID);
 /* set the current res file to the stand alone document */
 UseResFile(resRef);
 /* detach the source resource... */
 DetachResource(codeHandle);
 /* and add it to the document */
 AddResource(codeHandle, destRes, destID, “\p”);
 if (ResError() != noErr) {
 DoMessage(“\pSorry, couldn’t copy the required resource.”);
 myError = 1;
 }
}


/* fancy button for the modals */
DoButton(myDialog)
DialogPtr myDialog;
{
short   myType;
Handle  myHandle;
Rect    myBox;
GrafPtr dummyPort;

 GetPort(&dummyPort);
 SetPort(myDialog);
 GetDItem( myDialog, 1, &myType, &myHandle, &myBox );
 InsetRect(&myBox, -4, -4);
 PenSize(3, 3);
 FrameRoundRect(&myBox, 16, 16);
 PenNormal();
 SetPort(dummyPort);
}


/*
 * PaintDisplay.c
 *
 * This program supplies the code needed for the PostCard application
 * to generate a stand alone Paint file.
 *
 * copyright 1987, Joel McNamara - All Rights Reserved
 * for MacTutor Magazine
 *
 * initial coding - October 12, 1987
 *
 */
  
#include<MacTypes.h>
#include<QuickDraw.h>
#include<WindowMgr.h>
#include<EventMgr.h>
#include<MemoryMgr.h>
#include<SegmentLdr.h>

/* setup the world, display the image, and wait for a click */
main()
{
 InitGraf(&thePort);
 InitFonts();
 InitWindows();
 InitMenus();
 TEInit();
 InitDialogs(0L);
 InitCursor();
 FlushEvents(everyEvent,0);
 displayPaint();
 while (!Button());
}

/* the guts of the paint display program */
displayPaint()
{
char    *srcPtr, *dstPtr, *saveDstPtr, *skipPtr;
intsrcFile, scanLine, vRef, temp;
long    srcSize, paintSize;
Str255  thisProgram;
StringPtr thisVolume;
GrafPortaPort;
BitMap  theBitMap;
Rect    myRect;
WindowPtr myWind;
Handle  thisHandle;

 /* we’ll be sloppy with the nonrelocatable pointers and let them all 
get cleaned up upon exiting */
    
 /* the first 512 header bytes to skip */
 srcSize = 512;  
 skipPtr = NewPtr(512);
 if (srcPtr == 0L)
        ErrorRoutine(FALSE,0);
     /* the biggest it can be */  
 srcPtr = NewPtr(51840);
 if (srcPtr == 0L)
        ErrorRoutine(FALSE,0);
 /* see who and where we are... */
 if (GetVol(&thisVolume,&vRef) != noErr)
 ErrorRoutine(FALSE,0);
 GetAppParms(&thisProgram,&temp,&thisHandle);
    /* then open our data fork and read past the header */
    if (FSOpen(thisProgram,vRef,&srcFile) != noErr)
 ErrorRoutine(TRUE,srcFile);
 if (FSRead(srcFile,&srcSize,skipPtr) != noErr)
        ErrorRoutine(TRUE,srcFile);
 /* see how big we really are... */
 if (GetEOF(srcFile,&paintSize) != noErr)
        ErrorRoutine(TRUE,srcFile);
 paintSize -= 512;
 /* now read the rest of the bytes and close */
 if (FSRead(srcFile,&paintSize,srcPtr) != noErr)
        ErrorRoutine(TRUE,srcFile);  
 if (FSClose(srcFile) != noErr)
        ErrorRoutine(TRUE,srcFile);
 /* get a destination pointer... */
 dstPtr = NewPtr(51840);
 if (dstPtr == 0L)
        ErrorRoutine(FALSE,0); 
 saveDstPtr = dstPtr;
 scanLine = 1; 
 /* and start unpacking the compressed Paint data */
 for (scanLine = 1; scanLine <= 720; scanLine++)
 UnpackBits(&srcPtr,&dstPtr,72);
 /* make a window */      
 SetRect(&myRect,12,35,500,325);
   myWind = NewWindow(0L,&myRect,”\p”,TRUE,1,-1L,FALSE,99);

 /* configure our bitmap */
 theBitMap.baseAddr = saveDstPtr;
 theBitMap.rowBytes = 72;  
 theBitMap.bounds.top = 0;
 theBitMap.bounds.left = 0;
 theBitMap.bounds.bottom = 72 * 8;
 theBitMap.bounds.right = 720;
 /* and copy the Paint bits into our window */  
 CopyBits(&theBitMap, &myWind->portBits, &myWind->portRect, &myWind->portRect, 
srcCopy, 0L);    
}


/* simple no frills, beep and quit */
ErrorRoutine( closeFile, fileNum )
Boolean closeFile;
intfileNum; 
{
 SysBeep(5);
 if (closeFile)
 FSClose(fileNum); 
 ExitToShell();
}

* resource file for PostCard.c
* by Joel McNamara
* for MacTutor Magazine
* October 12, 1987

Development:MacTutor:PostCard proj.Rsrc
* you’ll probably want to change the pathname

* the bundles, first for PostCard then PaintDisplay
Type BNDL
,128
PCRD 0
ICN#
0 128
FREF
0 128

* this BNDL will be renumbered by the application
,129
PDIS 0
ICN#
0 128
FREF
0 128

* we’ll use the same FREF for both
Type FREF
,128
APPL 0

* PostCard file type
Type PCRD = STR 
,0
PostCard Version 1.0 - 12 Oct 87

* PaintDISplay file type
Type PDIS = STR 
,0
PaintDisplay Version 1.0 - 12 Oct 87

* der menu
Type MENU
,1
\14
About PostCard...
(-

,255
File
Quit

,256
Commands
Make a PostCard...
(-
Help...

* the dialog items
Type DITL
,255 (4)
2

button
48 272 66 349
OK

staticText Disabled
6 11 43 350
^0

,256 (4)
5
button
171 86 190 178
OK

staticText Disabled
2 86 20 177
PostCard 1.0

staticText Disabled
24 13 87 263
PostCard creates an application and then places a Paint file into the 
data fork, thus creating a stand alone viewer.

staticText Disabled
124 24 158 241
Copyright 1987, Joel McNamara\0D         All Rights Reserved

staticText Disabled
100 50 118 208
for MacTutor Magazine

,257 (4)
4
button
166 295 184 406
OK

staticText Disabled
3 4 38 423
PostCard takes a MacPaint document and turns it into a stand alone application 
that displays the upper left corner.

staticText Disabled
42 4 91 423
When the Paint document is selected a new file is created with CODE resources 
(FAKE and DUMY - stored within the PostCard application) copied and renamed 
into the new file.


staticText Disabled
95 4 161 423
These resources drive the new application by reading its own data fork 
(copied in from the Paint file) and then displaying the bit mapped image.


* the dialogs
Type DLOG
,255 (4)
message
60 68 136 438
Visible NoGoAway
1
0
255

,256 (4)
about
52 122 252 394
Visible NoGoAway
1
0
256

,257 (4)
help
46 48 242 474
Visible NoGoAway
1
0
257


* here’s the trickery - we create new resources of type FAKE, and read
* the CODE resources from PaintDisplay into them.
Type FAKE = GNRL
,0
.R
Development:MacTutor:PaintDisplay CODE 0
* you’ll need to specify a different pathname above

,1
.R
Development:MacTutor:PaintDisplay CODE 1
* you’ll need to specify a different pathname above

,2
.R
Development:MacTutor:PaintDisplay CODE 2
* you’ll need to specify a different pathname above


* now get the rest of the resources we need (as required by Lightspeed 
C) -
* creating dummy resources named DUMY.
Type DUMY = GNRL
,0
.R
Development:MacTutor:PaintDisplay CREL 2
* you’ll need to specify a different pathname above

,1
.R
Development:MacTutor:PaintDisplay DATA 0
* you’ll need to specify a different pathname above

,2
.R
Development:MacTutor:PaintDisplay DREL 0
* you’ll need to specify a different pathname above

,3
.R
Development:MacTutor:PaintDisplay STRS 0
* you’ll need to specify a different pathname above

,4
.R
Development:MacTutor:PaintDisplay ZERO 0
* you’ll need to specify a different pathname above

* now the application icon
Type ICN# = GNRL
,128
.H
00000000
00000000 
1FFFF800
20003C00 
20007C00
27FFFC00 
2401FC00
2553FC00 
2402F400
2545E400 
2409C400
25428400 
24010400
25420400 
24003F00
25084080 
24108040
23F13020 
2039C814
201E7F8F 
20023007
261F0007 
26008007
20006007 
3FFFFFE7
2000021F 
1FFFFC07
00000000 
00000000
00000000 
00000000
00000000
* next the mask
00000000
00000000 
1FFFF800
3FFFFC00 
3FFFFC00
3FFFFC00 
3FFFFC00
3FFFFC00 
3FFFFC00
3FFFFC00 
3FFFFC00
3FFFFC00 
3FFFFC00
3FFFFC00 
3FFFFF00
3FFFFF80 
3FFFFFC0
3FFFFFE0 
3FFFFFF4
3FFFFFFF 
3FFFFFFF
3FFFFFFF 
3FFFFFFF
3FFFFFFF 
3FFFFFFF
3FFFFE1F 
1FFFFC07
00000000 
00000000
00000000 
00000000
00000000 

* now the stand alone file’s icon
,129
00000000
00000000 
00000000
00000000 
00000000
00000000 
00000000
00000000 
00000000
FFFFFFFF 
81D00001
81D000FD 
81F000AD
811000D5 
811000AD
811000D5 
811000FD
81100001 
80E00001
81F00001 
81F00001
81F80001 
81F80001
81E85FFF 
81F80BFF
80D03FFF 
80F0FFFF
80703FFF 
8019FFFF
80000001 
FFFFFFFF
00000000
* next the mask
00000000
00000000 
00000000
00000000 
00000000
00000000 
00000000
00000000 
00000000
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
FFFFFFFF 
FFFFFFFF
00000000 
 
AAPL
$117.60
Apple Inc.
-1.03
MSFT
$47.47
Microsoft Corpora
-0.12
GOOG
$541.08
Google Inc.
+1.81

MacTech Search:
Community Search:

Software Updates via MacUpdate

MacUpdate Desktop 6.0.3 - Discover and i...
MacUpdate Desktop 6 brings seamless 1-click installs and version updates to your Mac. With a free MacUpdate account and MacUpdate Desktop 6, Mac users can now install almost any Mac app on macupdate.... Read more
SteerMouse 4.2.2 - Powerful third-party...
SteerMouse is an advanced driver for USB and Bluetooth mice. It also supports Apple Mighty Mouse very well. SteerMouse can assign various functions to buttons that Apple's software does not allow,... Read more
iMazing 1.1 - Complete iOS device manage...
iMazing (was DiskAid) is the ultimate iOS device manager with capabilities far beyond what iTunes offers. With iMazing and your iOS device (iPhone, iPad, or iPod), you can: Copy music to and from... Read more
PopChar X 7.0 - Floating window shows av...
PopChar X helps you get the most out of your font collection. With its crystal-clear interface, PopChar X provides a frustration-free way to access any font's special characters. Expanded... Read more
Carbon Copy Cloner 4.0.3 - Easy-to-use b...
Carbon Copy Cloner backups are better than ordinary backups. Suppose the unthinkable happens while you're under deadline to finish a project: your Mac is unresponsive and all you hear is an ominous,... Read more
ForeverSave 2.1.3 - Universal auto-save...
ForeverSave auto-saves all documents you're working on while simultaneously doing backup versioning in the background. Lost data can be quickly restored at any time. Losing data, caused by... Read more
Voila 3.8.1 - Capture, annotate, organiz...
Voila is a screen-capture, recording, and annotation tool that is a full-featured replacement for Mac's screen-capture and screen-recording capabilities. It has a large and robust set of editing,... Read more
SyncTwoFolders 2.0.6 - Syncs two user-sp...
SyncTwoFolders simply synchronizes two folders. It supports synchronization across mounted network drives and it is a possibility to run a simulation showing in a log what will be done. Please visit... Read more
Duplicate Annihilator 5.1.1 - Find and d...
Duplicate Annihilator takes on the time-consuming task of comparing the images in your iPhoto library using effective algorithms to make sure that no duplicate escapes. Duplicate Annihilator detects... Read more
HandBrake 0.10.0 - Versatile video encod...
HandBrake is a tool for converting video from nearly any format to a selection of modern, widely supported codecs. Supported Sources: VIDEO_TS folder, DVD image or real DVD (unencrypted -- CSS is... Read more

Latest Forum Discussions

See All

Tilt to Live Bundle Set to Arrive This T...
Tilt to Live Bundle Set to Arrive This Thanksgiving Posted by Ellis Spice on November 25th, 2014 [ permalink ] One Man Left has unveiled an upcoming Tilt to Live bundle, allowing players to get the series for a di | Read more »
BattleLore: Command (Entertainment)
BattleLore: Command 1.0 Device: iOS Universal Category: Entertainment Price: $9.99, Version: 1.0 (iTunes) Description: ***NOTE: Compatible with iPad 2/iPad mini, iPod touch 5 and up and iPhone 4S and up – WILL NOT RUN ON EARLIER... | Read more »
Weather Or Not Review
Weather Or Not Review By Jennifer Allen on November 25th, 2014 Our Rating: :: STYLISH WEATHER REPORTINGiPhone App - Designed for the iPhone, compatible with the iPad Check the weather quickly and conveniently with Weather or Not... | Read more »
The All-New Football Manager Handheld 20...
The All-New Football Manager Handheld 2015 is Available Now Posted by Jessica Fisher on November 25th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Six iOS Games to Get You Ready for Thank...
Image Source: Friends Wiki At this point in the month, you or at least a few people you know are probably getting ready to scramble around (or are already scrambling around) for Thanksgiving Dinner. It’s a hectic day of precise oven utilization, but... | Read more »
Call of Duty: Heroes: Tips, Tricks, and...
Hello Heroes: What’d we think of Call of Duty‘s take on Clash of Clans? Check out our Call of Duty: Heroes review to find out! Just downloaded Call of Duty: Heroes and need some handy tips and tricks on how to get ahead of the rest? As we often do,... | Read more »
Call of Duty: Heroes Review
Call of Duty: Heroes Review By Jennifer Allen on November 25th, 2014 Our Rating: :: CLASH OF FRANCHISESUniversal App - Designed for iPhone and iPad Mix Clash of Clans with Call of Duty, and this is what you get.   | Read more »
Slider Review
Slider Review By Jordan Minor on November 25th, 2014 Our Rating: :: SLIDE TO PLAYUniversal App - Designed for iPhone and iPad Slider has all the excitement of unlocking your phone screen.   | Read more »
oh my giraffe (Games)
oh my giraffe 1.0.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.0 (iTunes) Description: Eat fruits while being chased by lions. Cut the vines to send fruit plummeting onto the lions. Don't worry, your flexible... | Read more »
One of 2000’s Most Loves Adventure Games...
One of 2000’s Most Loves Adventure Games, The Longest Journey, has Come to iOS Posted by Jessica Fisher on November 25th, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

Early Black Friday MacBook Pro sale: 15-inch...
 Best Buy has posted early Black Friday prices on 15″ Retina MacBook Pros, with models on sale for $300 off MSRP on their online store for a limited time. Choose free local store pickup (if available... Read more
A9 Chips Already?
It’s barely more than a couple of months since Apple got the first A8 systems-on-chip into consumer hands, but rumor and news focus is already turning to the next-generation A9 SoC. Apple Daily... Read more
NewerTech Announces NuGuard KXs Impact X-Orbi...
NewerTech has announced updates to its family of Impact X-Orbing Screen Armor bringing military grade, triple layer protection to Apple’s new iPhone 6 and 6 Plus. Like all models in the NuGuard KXs... Read more
13-inch 1.4GHz MacBook Air on sale for $889,...
 B&H Photo has the 13″ 1.4GHz/128GB MacBook Air on sale for $889 including free shipping plus NY tax only. Their price is $110 off MSRP. B&H will also include free copies of Parallels Desktop... Read more
Save up to $300 on Macs and iPads with your A...
Purchase a new Mac or iPad at The Apple Store for Education and take up to $300 off MSRP. All teachers, students, and staff of any educational institution qualify for the discount. Shipping is free,... Read more
Apple refurbished Mac Pros available for up t...
The Apple Store is offering Apple Certified Refurbished Mac Pros for up to $600 off the cost of new models. An Apple one-year warranty is included with each Mac Pro, and shipping is free. The... Read more
Jumptuit Launches One-Tap Windows 8.1 iTunes...
Jumptuit has launched Windows 8.1 support for One-Tap iTunes Sync. with which Windows 8.1 users can now easily sync their iTunes libraries with Microsoft OneDrive. Jumptuit provides easy access from... Read more
Apple restocks refurbished 13-inch 2014 Retin...
The Apple Store has restocked Apple Certified Refurbished 2014 13″ 2.6GHz Retina MacBook Pros for up to $230 off the cost of new models. An Apple one-year warranty is included with each model, and... Read more
CEA Study Finds More People Recycling Electro...
A new study by the Consumer Electronics Association (CEA) finds that electronics recycling receives the continued and growing support of consumers. According to the CEA,s Recycling and Reuse Study,... Read more
15″ 2.2GHz Retina MacBook Pro on sale for $17...
 B&H Photo has the 2014 15″ 2.2GHz Retina MacBook Pro on sale today for $1749. Shipping is free, and B&H charges NY sales tax only. B&H will also include free copies of Parallels Desktop... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant (ASC)- Retail S...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Project Manager, *Apple* Financial Services...
**Job Summary** Apple Financial Services (AFS) offers consumers, businesses and educational institutions ways to finance Apple purchases. We work with national and Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.