TweetFollow Us on Twitter

NonStandard File
Volume Number:7
Issue Number:4
Column Tag:Pascal Forum

Related Info: File Manager Standard File

Non-Standard File Dialogs

By Steven Sheets, Herndon, VA

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

Non-Standard File Unit

The SFGetFile and SFPutFile routines are two of the most commonly used calls in the Macintosh. All programmers need methods to select files (old or new ones) from inside their programs. Only old non-Mac programmers and users really appreciate how much Apple improved the user interface by standardizing this file selection process. However, Apple does not have a monopoly on good user interface ideas. Recently, newer programs have improved the Get and Put dialogs. While these new dialogs have the same functionality as the old ones, they have useful enhancements.

The code provided in this article shows how to create enhanced get and put dialogs. The unit NonStandardFile contains four procedures which demonstrate this. The program NonStandardFileTest shows how to use these routines.

NSPutFile()

The Non-Standard File Put procedure is the first routine provided in the Non-Standard File Unit. This procedure, and all other procedures explained in this article, are passed input parameters (passed by value) and return the output parameters (passed as VAR parameter). NSPutFile contains two input parameters (strings thePrompt and theOrigName) and 3 output parameters (boolean theGood, integer theRefNum and string theFileName). ThePrompt is the prompt that appears in the dialog, and theOrigName is the name that initially appears in the editable text field. If the user selects a file name (pressing the Save button or the return key), theGood flag returns TRUE, while the file name and the volume reference number is in theRefNum and theFileName parameters. If the user selects cancel, theGood returns FALSE.

This is the simplest example of using the SFPPutFile ROM call instead of the normal SFPutFile ROM call. I always find that the prompt portion of a normal SFPutFile is much too short to hold any meaningful information. The NSPutFile procedure provides an modified Put dialog, identical to a normal Put dialog, except the prompt text item is physically expanded (longer and 2 lines high). The routine does this by using a Dialog template resource and a Dialog Item List resource that are almost identical the the normal resources (stored at ID number -3999). The only difference in the resources is that the prompt field is larger. The SFPPutFile call that NSPutFile uses is passed the ID number of this modified dialog. Other than having a different layout, the dialog functions identical to the standard form. It is important to note that whenever a dialog item list is modified, all of the standard items are in the identical order (this is important for the SFPPutFile call). New items can be added to the end of the list (following calls are examples of this), but the original items must still exist.

NSSelectPutFile()

The Non-Standard Selection Put File procedure is the first example of a more intelligent Put dialog. This procedure places a Put dialog on the screen that contains, besides the normal features, 2 buttons to indicate if the user wants to save the entire document or only the selected portion of the document. The procedure is passed 3 input parameters (strings thePrompt, theSelectPrompt, theOrigName) and 4 output parameters (boolean theGood, integer theRefNum, string theFileName, Boolean theFlag). As before, theOrigName is the initial name of the file, while theGood flag returns TRUE if the user selects a file (with theRefNum and theFileName containing the volume reference number and file name selected). However, the routine passes 2 prompt strings, thePrompt and theSelectPrompt. How the button is set affects the appearance of the prompt. If the Document button is set, thePrompt string is displayed in the dialog. If the Selection button is set, theSelectPrompt string is displayed. If at any time, the user changes the button settings, the prompt also changes. If the user selects a file with the Selection button set, theFlag parameter returns TRUE. If he selected a file with the Document button set, theFlag returns FALSE. Having the Document button selected is the initial state of the dialog.

The NSSelectPutFile procedure is very useful when working with documents that can be saved as a whole or saved in portions. For example, a drawing program that allows the user to select various graphical objects on the screen could use this procedure. When the user selects Save from the menu, he can save the entire document, or he can save the selected drawing objects.

Similar to NSPutFile, NSSelectPutFile uses SFPPutFile ROM call in order to use a modified Dialog template and Dialog Item List. However, this list has additional items on it, namely the Document and Selection buttons. The SFPPutFile call also passes a dlogHook routine, NSSelectPutDlg. A dlogHook routine is called by the SFPPutFile call immediately after calling ModalDialog. The dlogHook routine is passed the item number returned by ModalDialog, as well as a pointer to the dialog record. All dlogHook routines (as well as File Filter routines and UserItem routines) need to be declared global to the unit.

The NSSelectPutDlg has two purposes. The first time it is called, the correct prompt is placed in the window and the Document and Selection buttons are set appropriately. After that, the routine scans item events to check if the user has selected either button. If he has, the new prompt is placed in the dialog and the buttons checked appropriately. Also, the item number is set to 100, indicating nothing else needs to be done for this event.

NSIconPutFile()

The Non-Standard Icon Put File procedure is one of the best new user interfaces I have seen on the Macintosh. This routine should be used in a program where a document can be saved as more than one file type. When this routine is used, the desktop icons of the file formats to which the document can be saved are shown.

NSIconPutFile allows up to 4 different file formats (icons). The parameters reflect this. NSIconPutFile is passed 14 input parameters (string theOrigName, integer theDefaultNum, handles theIcon1, theIcon2, theIcon3, theIcon4 and strings theName1, theName2, theName3, theName4, thePrompt1, thePrompt2, thePrompt3, and thePrompt4) and passed 4 output parameters (Boolean theGood, integer theRefNum, string theFileName, integer theNum). TheOrigName, theGood, theRefNum and theFileName are all used identically to the previously explained Non-Standard Put File calls. TheIcon parameters should contain up to 4 icon handles. Each handle should contain 256 byte of information of the ‘ICN#” resource format (32 bit by 32 bit image, 128 bytes of image, 128 bytes of mask). Usually, this is the actual ‘ICN#’ resource that is stored in the application (but it does not have to be). Passing NIL in one of the parameter handles indicates that a particular icon position is not used. For example, if only 3 icons need to be displayed, the last handle should be passed as NIL. TheDefaultNum parameter indicates which icon should be initially set. TheName strings are the titles of the icons (which will appear under the icon), while thePrompt strings are the prompt that will appear when that associated icon is selected. Usually the icon titles are the name of that file type (ie. Text, MacPaint, MacWrite), but this does not have to be the case.

Again imagine this routine is used by a graphic program, but in this case the program is a paint program. The document might be able to be saved as a MacPaint file, or as a StartUp Screen file or as some proprietary file format. Instead of using buttons, the user selects the format he wants by selecting the actual icon. He is used to seeing this icon on the desktop, and associating it with that type of file.

NSIconPutFile uses a number of hooks to function. First the routine calls SFPPutFile in order to use a Dialog template and Dialog item list that have 6 new UserItems on it. Like NSSelectPutFile, NSIconPutFile has a dlogHook routine, NSIconPutDlg. The first time through, NSIconPutDlg sets the prompt and sets the UserItem routine of the 4 new dialog items to NSIconItem. A UserItem routine is a graphic routine that draws some special user interface in a dialog. In this case, NSIconItem draws the 4 icons, with titles and hiliting. NSIconPutDlg handles the mouse down events on the icon. Selecting a previously unselected icon activates the icon, which consists of unhiliting old icon, hiliting new one and setting new prompt.

NSGetFile()

The Non Standard Get File is an example of a modification of the Get File Dialog. This routine should be used in applications that can open 2 or more different types of documents. NSGetFile displays a Get File dialog that contains, along with the normal features, a Popup menu that indicates what file types the routine is currently viewing. The default setting is all documents; all documents of the types passed to the routine will be shown in the dialog. However, the user can select the Popup menu and change the settings so that only 1 type can be viewed.

NSGetFile is passed 4 input parameters (string thePrompt, integer theNumTypes, pointers theTypeListPtr and theNameListPtr) and passes back 4 output parameters (Boolean theGood, integer theRefNum, string theFileName, OStype theType).

This routine is written slightly differently than the NSPutFile procedures. NSGetFile was written so that there is no upper limit to the number of different file types that can be viewed by the dialog. Instead of passing the individual file types and file type name as parameters to the routine, all the file types and all the file names are stored in an array before NSGetFile is called. Then pointers to these two arrays are passed to NSGetFile as parameters. TheNumTypes parameter is the number of different file types the routine can display in the dialog. ThePrompt is the prompt that is displayed on the dialog.

If the user selects a file, theGood is returned TRUE. In this case, theRefNum contains the volume reference number, theFileName contains the file’s name, and theType returns the file’s OStype. If the user selects cancel, theGood returns FALSE.

Just as SFPPutfile ROM call is an variation of the SFPutfile call, there is a SFPGetFile ROM call that provides expanded functionality in comparison to the normal SFGetFile call. In NSGetFile, the SFPGetFile call is passed the ID number of a Dialog template resource and Dialog item list resource that is almost identical to the standard SFGetFile resources (stored at ID -4000). The modified resources contain a text item (for the prompt) and an UserItem (for the Popup menu). The SFPGetFile call is also passed a Dialog hook routine, NSGetDlg. As in the previous examples, the first thing NSGetDlg does is set the prompt and set the UserItem to the NSPopUpItem procedure. NSPopUpItem displays the graphics for a Popup menu. NSGetDlg also takes care of handling the Popup (using call to PopUpMenuSelect) when a user selects the item. The SFPGetFile call is also passed a File Filter routine, NSGetFileFilter. NSGetFileFilter decides which files are displayed in the dialog. Depending on the setting of the Popup menu, the routine either allows only a single type of file to be viewed, or it allows all the types of files it knows about to be viewed. Notice that if a user selects a new setting on the Popup menu, NSGetDlg sets the event item number to 101. This tells the SFPGetFile ROM call to redraw the dialog from scratch, which it does using the NGSGetFileFilter (possibly displaying a new group of files).

Beyond

Hopefully these routines should be easy to modify for your own use. NSIconPutFile could be rewritten to handle more than 4 file types. NSGetFile could be modified to use a simpler parameter method when you know exactly which file types your program can open. NSGetFile could also be modified to use icons instead of a Popup menu. The application I wrote NSGetFile for could read a variable number of file types (depending on configuration of program) that had no upper limits.

All routines could be rewritten so as not to use so much global parameter data. Instead, the global type of data could be stored in a temporary handle. As the start of the routine, the handle is allocated, and the values plugged in. Then this handle is stored in the reference value of the dialog (remember a dialog is a window). This is a location that all the dlogHook, fileFilter and UserItem routines can access. Just before the main routine is done, the handle can be disposed of.

While this method does use less global space, for simplicity and ease of understanding, I stuck with global variables. If you were to use the routine with something that does not have global variables (FKEYs, Drivers, DAs), you might have to use that method.

If anyone comes up with other interesting user interfaces, I would love to see them. I can be contacted on Applelink (SHEETS1) or America Online (Mage Steve).

Listing:  NonStandardFile.p

{****************************}
{}
{Non-Standard File Unit}
{Created by Steve Sheets}
{}
{Provides 4 different new user interfaces for}
{the Get & Put dialogs.}
{}
{****************************}

unit NonStandardFile;

interface

 type
 SFTypeListPtr = ^SFTypeList;

 StrArray = array[1..1] of Str255;
 StrArrayPtr = ^StrArray;

{Four new Put & Get File Routines}
 procedure NSPutFile (thePrompt, theOrigName: Str255;
 var theGood: BOOLEAN;
 var theRefNum: INTEGER;
 var theFileName: Str255);

 procedure NSSelectPutFile (thePrompt, theSelectPrompt, theOrigName: 
Str255;
 var theGood: BOOLEAN;
 var theRefNum: INTEGER;
 var theFileName: Str255;
 var theFlag: BOOLEAN);

 procedure NSIconPutFile (theOrigName: Str255;
 theDefaultNum: INTEGER;
 theIcon1, theIcon2, theIcon3, theIcon4: Handle;
 theName1, theName2, theName3, theName4: Str255;
 thePrompt1, thePrompt2, 
 thePrompt3, thePrompt4: Str255;
 var theGood: BOOLEAN;
 var theRefNum: INTEGER;
 var theFileName: Str255;
 var theNum: INTEGER);

 procedure NSGetFile (thePrompt: Str255;
 theNumTypes: INTEGER;
 theTypeListPtr: SFTypeListPtr;
 theNameListPtr: StrArrayPtr;
 var theGood: BOOLEAN;
 var theRefNum: INTEGER;
 var theFileName: Str255;
 var theType: OSType);

{************************************}
{External references to these procedures.}
{Do not call them outside this unit}

 function NSSelectPutDlg (item: INTEGER;
 theDialog: DialogPtr): INTEGER;

 procedure NSIconItem (theWindow: WindowPtr;
 itemNo: INTEGER);

 function NSIconPutDlg (item: INTEGER;
 theDialog: DialogPtr): INTEGER;

 procedure NSPopUpItem (theWindow: WindowPtr;
 itemNo: INTEGER);

 function NSGetFileFilter (paramBlock: ParmBlkPtr): BOOLEAN;

 function NSGetDlg (item: INTEGER;
 theDialog: DialogPtr): INTEGER;

implementation
 const
 kNSGetID = 500;
 kNSPutID = 501;
 kNSSelectPutID = 502;
 kNSIconPutID = 503;

 kGetPopUpID = 254;
 kGetPopUpItem = 11;
 kGetPopUpPrompt = 12;

 kPutPrompt = 3;
 kPutNoSelectSwitch = 9;
 kPutSelectSwitch = 10;
 kPutIcon1 = 9;

 kMaxIcons = 4;

 type
 IconStrPtrArray = array[1..kMaxIcons] of StringPtr;

 var
 gNSCurNum, gNSMaxNum: INTEGER;
 gNSTypeListPtr: SFTypeListPtr;
 gNSPromptListPtr: IconStrPtrArray;
 gNSNameListPtr: IconStrPtrArray;
 gNSFirst, gNSSelect: BOOLEAN;
 gNSMenuHdl: MenuHandle;
 gNSBoxs: array[1..kMaxIcons] of Rect;
 gNSIcons: array[1..kMaxIcons] of Handle;
 gNSPrompt, gNSAltPrompt: Str255;

{************************************}

{NSPutFile routines}
 procedure NSPutFile (thePrompt, theOrigName: Str255;
 var theGood: BOOLEAN;
 var theRefNum: INTEGER;
 var theFileName: Str255);
 var
 tempPt: Point;
 tempReply: SFReply;
 begin
 tempPt.v := 40;
 tempPt.h := 60;
 theGood := FALSE;

 SFPPutFile(tempPt, thePrompt, theOrigName, nil, tempReply, kNSPutID, 
nil);

 with tempReply do
 if good then
 begin
 theGood := TRUE;
 theRefNum := vRefNum;
 theFileName := fName;
 end;
 end;

{************************************}
{NSSelectPutFile routines}
 function NSSelectPutDlg (item: INTEGER;
 theDialog: DialogPtr): INTEGER;

 procedure SetPrompt;
 var
 tempNum, tempV1, tempV2: INTEGER;
 tempHdl: Handle;
 tempRect: Rect;
 begin
 GetDItem(theDialog, kPutPrompt, tempNum, tempHdl, tempRect);
 if tempHdl <> nil then
 begin
 if gNSSelect then
 SetIText(tempHdl, gNSAltPrompt)
 else
 SetIText(tempHdl, gNSPrompt);
 end;

 if gNSSelect then
 begin
 tempV1 := 0;
 tempV2 := 1;
 end
 else
 begin
 tempV1 := 1;
 tempV2 := 0;
 end;

 GetDItem(theDialog, kPutNoSelectSwitch, tempNum, tempHdl, tempRect);
 if tempHdl <> nil then
 SetCtlValue(ControlHandle(tempHdl), tempV1);
 GetDItem(theDialog, kPutSelectSwitch, tempNum, tempHdl, tempRect);
 if tempHdl <> nil then
 SetCtlValue(ControlHandle(tempHdl), tempV2);
 end;

 begin
 if gNSFirst then
 begin
 SetPrompt;
 gNSFirst := FALSE;
 end;

 if item = kPutSelectSwitch then
 begin
 gNSSelect := TRUE;
 SetPrompt;
 item := 100;
 end
 else if item = kPutNoSelectSwitch then
 begin
 gNSSelect := FALSE;
 SetPrompt;
 item := 100;
 end;

 NSSelectPutDlg := item;
 end;

 procedure NSSelectPutFile (thePrompt, theSelectPrompt, theOrigName: 
Str255;
 var theGood: BOOLEAN;
 var theRefNum: INTEGER;
 var theFileName: Str255;
 var theFlag: BOOLEAN);
 var
 tempPt: Point;
 tempReply: SFReply;
 begin
 theGood := FALSE;

 tempPt.v := 40;
 tempPt.h := 60;

 gNSFirst := TRUE;
 gNSSelect := FALSE;
 gNSPrompt := thePrompt;
 gNSAltPrompt := theSelectPrompt;
 SFPPutFile(tempPt, thePrompt, theOrigName, @NSSelectPutDlg, tempReply, 
kNSSelectPutID, nil);

 with tempReply do
 if good then
 begin
 theGood := TRUE;
 theRefNum := vRefNum;
 theFileName := fName;
 theFlag := gNSSelect;
 end;
 end;

{************************************}
{NSIconPutFile routines}
 procedure DrawNSIcon (theNum: INTEGER;
 theHiliteFlag: BOOLEAN);
 var
 tempBitMap: BitMap;
 tempPort: GrafPtr;
 tempRect, tempRect2: Rect;
 tempFont, tempSize, tempLen, tempCenter: INTEGER;
 begin
 if (theNum > 0) and (theNum <= kMaxIcons) then
 if gNSIcons[theNum] <> nil then
 begin
 GetPort(tempPort);

 with gNSBoxs[theNum] do
 begin
 tempCenter := ((right + left) div 2);
 tempRect.top := top;
 tempRect.bottom := top + 32;
 tempRect.left := tempCenter - 16;
 tempRect.right := tempRect.left + 32;
 end;

 PlotIcon(tempRect, gNSIcons[theNum]);

 if gNSNameListPtr[theNum]^ <> ‘’ then
 begin
 tempFont := tempPort^.txFont;
 tempSize := tempPort^.txSize;

 TextFont(1);
 TextSize(10);

 tempLen := StringWidth(gNSNameListPtr[theNum]^);
 with gNSBoxs[theNum] do
 begin
 tempRect2.top := bottom - 14;
 tempRect2.bottom := bottom;
 tempRect2.left := tempCenter - (tempLen div 2) - 4;
 tempRect2.right := tempRect2.left + tempLen + 8;
 end;

 TextBox(POINTER(@gNSNameListPtr[theNum]^[1]), Length(gNSNameListPtr[theNum]^), 
tempRect2, teJustCenter);

 TextFont(tempFont);
 TextSize(tempSize);
 end;

 if theHiliteFlag then
 begin
 Hlock(gNSIcons[theNum]);
 tempBitMap.baseaddr := POINTER(ORD4(gNSIcons[theNum]^) + $80);
 tempBitMap.rowbytes := 4;
 SetRect(tempBitMap.bounds, 0, 0, 32, 32);

 BitClr(Ptr($938), 0);
 CopyBits(tempBitMap, tempPort^.portBits, tempBitMap.bounds, tempRect, 
srcXor, nil);

 HUnlock(gNSIcons[theNum]);

 if gNSNameListPtr[theNum]^ <> ‘’ then
 begin
 BitClr(Ptr($938), 0);
 InvertRect(tempRect2);
 end;
 end;
 end;
 end;

 procedure NSIconItem (theWindow: WindowPtr;
 itemNo: INTEGER);
 begin
 itemNo := itemNo - kPutIcon1 + 1;
 if (itemNo >= 1) and (itemNo <= kMaxIcons) then
 DrawNSIcon(itemNo, itemNo = gNSCurNum);
 end;

 function NSIconPutDlg (item: INTEGER;
 theDialog: DialogPtr): INTEGER;
 var
 tempNum, tempCount: INTEGER;
 tempHdl: Handle;
 tempRect: Rect;

 procedure SetPrompt;
 begin
 GetDItem(theDialog, kPutPrompt, tempNum, tempHdl, tempRect);
 if tempHdl <> nil then
 SetIText(tempHdl, gNSPromptListPtr[gNSCurNum]^);
 end;

 begin
 if gNSFirst then
 begin
 SetPrompt;

 for tempCount := 1 to kMaxIcons do
 begin
 GetDItem(theDialog, tempCount - 1 + kPutIcon1, tempNum, tempHdl, gNSBoxs[tempCount]);
 tempHdl := @NSIconItem;
 SetDItem(theDialog, tempCount - 1 + kPutIcon1, tempNum, tempHdl, gNSBoxs[tempCount]);
 end;

 gNSFirst := FALSE;
 end;

 tempNum := item - kPutIcon1 + 1;
 if (tempNum >= 1) and (tempNum <= kMaxIcons) then
 begin
 item := 100;
 if (gNSIcons[tempNum] <> nil) and (tempNum <> gNSCurNum) then
 begin
 DrawNSIcon(gNSCurNum, FALSE);
 DrawNSIcon(tempNum, TRUE);
 gNSCurNum := tempNum;
 SetPrompt;
 end;
 end;

 NSIconPutDlg := item;
 end;

 procedure NSIconPutFile (theOrigName: Str255;
 theDefaultNum: INTEGER;
 theIcon1, theIcon2, theIcon3, theIcon4: Handle;
 theName1, theName2, theName3, theName4: Str255;
 thePrompt1, thePrompt2, thePrompt3, thePrompt4: Str255;
 var theGood: BOOLEAN;
 var theRefNum: INTEGER;
 var theFileName: Str255;
 var theNum: INTEGER);
 var
 tempPt: Point;
 tempReply: SFReply;
 begin
 theGood := FALSE;

 if (theDefaultNum >= 1) and (theDefaultNum <= kMaxIcons) then
 begin
 tempPt.v := 40;
 tempPt.h := 60;

 gNSFirst := TRUE;
 gNSCurNum := theDefaultNum;
 gNSNameListPtr[1] := @theName1;
 gNSNameListPtr[2] := @theName2;
 gNSNameListPtr[3] := @theName3;
 gNSNameListPtr[4] := @theName4;
 gNSPromptListPtr[1] := @thePrompt1;
 gNSPromptListPtr[2] := @thePrompt2;
 gNSPromptListPtr[3] := @thePrompt3;
 gNSPromptListPtr[4] := @thePrompt4;
 gNSIcons[1] := theIcon1;
 gNSIcons[2] := theIcon2;
 gNSIcons[3] := theIcon3;
 gNSIcons[4] := theIcon4;

 SFPPutFile(tempPt, ‘’, theOrigName, @NSIconPutDlg, tempReply, kNSIconPutID, 
nil);

 with tempReply do
 if good then
 begin
 theGood := TRUE;
 theRefNum := vRefNum;
 theFileName := fName;
 theNum := gNSCurNum;
 end;
 end;
 end;

{************************************}
{NSGetFile routines}
 procedure DrawNSPopup;
 var
 tempStr: Str255;
 begin
 FrameRect(gNSBoxs[1]);
 MoveTo(gNSBoxs[1].left, gNSBoxs[1].bottom);
 LineTo(gNSBoxs[1].right, gNSBoxs[1].bottom);
 LineTo(gNSBoxs[1].right, gNSBoxs[1].top);

 MoveTo(gNSBoxs[1].left + 4, gNSBoxs[1].bottom - 6);
 if gNSCurNum = 0 then
 DrawString(‘All Files’)
 else
 begin
 GetItem(gNSMenuHdl, gNSCurNum + 2, tempStr);
 DrawString(tempStr);
 end;
 end;

 procedure NSPopUpItem (theWindow: WindowPtr;
 itemNo: INTEGER);
 begin
 if itemNo = kGetPopUpItem then
 DrawNSPopup;
 end;

 function NSGetFileFilter (paramBlock: ParmBlkPtr): BOOLEAN;
 var
 tempFlag: BOOLEAN;
 tempType: OSType;
 tempCount: INTEGER;
 begin
 tempFlag := TRUE;

 tempType := paramBlock^.ioFlFndrInfo.fdType;
 if gNSCurNum = 0 then
 begin
 for tempCount := 0 to gNSMaxNum - 1 do
 if tempFlag then
 if gNSTypeListPtr^[tempCount] = tempType then
 tempFlag := FALSE;
 end
 else
 begin
 if gNSTypeListPtr^[gNSCurNum - 1] = tempType then
 tempFlag := FALSE;
 end;

 NSGetFileFilter := tempFlag;
 end;

 function NSGetDlg (item: INTEGER;
 theDialog: DialogPtr): INTEGER;
 var
 tempType: INTEGER;
 tempHdl: Handle;
 tempNum, tempNewNum: INTEGER;
 tempLong: LongInt;
 tempRect: Rect;
 tempPt: Point;

 begin
 if gNSFirst then
 begin
 GetDItem(theDialog, kGetPopUpPrompt, tempNum, tempHdl, tempRect);
 if tempHdl <> nil then
 SetIText(tempHdl, gNSPrompt);

 GetDItem(theDialog, kGetPopUpItem, tempType, tempHdl, gNSBoxs[1]);
 tempHdl := @NSPopUpItem;
 SetDItem(theDialog, kGetPopUpItem, tempType, tempHdl, gNSBoxs[1]);
 with gNSBoxs[1] do
 begin
 bottom := bottom - 1;
 right := right - 1;
 end;
 gNSFirst := FALSE;
 end;

 if item = kGetPopUpItem then
 begin
 if gNSCurNum = 0 then
 tempNum := 1
 else
 tempNum := gNSCurNum + 2;

 CheckItem(gNSMenuHdl, tempNum, TRUE);
 InsertMenu(gNSMenuHdl, -1);
 tempPt := gNSBoxs[1].topleft;
 LocalToGlobal(tempPt);
 BitClr(Ptr($938), 0);
 InvertRect(gNSBoxs[1]);
 tempLong := PopUpMenuSelect(gNSMenuHdl, tempPt.v, tempPt.h, tempNum);
 BitClr(Ptr($938), 0);
 InvertRect(gNSBoxs[1]);
 DeleteMenu(kGetPopUpID);
 CheckItem(gNSMenuHdl, tempNum, FALSE);

 if tempLong <> 0 then
 begin
 tempNewNum := LoWord(tempLong);
 if tempNewNum <> tempNum then
 begin
 if tempNewNum = 1 then
 gNSCurNum := 0
 else
 gNSCurNum := tempNewNum - 2;

 item := 101;
 EraseRect(gNSBoxs[1]);
 DrawNSPopup;
 end;
 end;
 end;

 NSGetDlg := item;
 end;

 procedure NSGetFile (thePrompt: Str255;
 theNumTypes: INTEGER;
 theTypeListPtr: SFTypeListPtr;
 theNameListPtr: StrArrayPtr;
 var theGood: BOOLEAN;
 var theRefNum: INTEGER;
 var theFileName: Str255;
 var theType: OSType);
 var
 tempPt: Point;
 tempReply: SFReply;
 tempCount: INTEGER;
 begin
 theGood := FALSE;
 theRefNum := -1;
 theFileName := ‘’;
 theType := ‘    ‘;

 if (theNumTypes > 0) and (theTypeListPtr <> nil) then
 begin
 gNSCurNum := 0;
 gNSMaxNum := theNumTypes;
 gNSTypeListPtr := theTypeListPtr;
 gNSPrompt := thePrompt;
 gNSFirst := TRUE;
 gNSMenuHdl := NewMenu(kGetPopUpID, ‘NS’);
 AppendMenu(gNSMenuHdl, ‘All Files;(-’);
 for tempCount := 1 to theNumTypes do
 AppendMenu(gNSMenuHdl, theNameListPtr^[tempCount]);

 tempPt.v := 40;
 tempPt.h := 60;
 SFPGetFile(tempPt, ‘’, @NSGetFileFilter, theNumTypes, theTypeListPtr^, 
@NSGetDlg, tempReply, kNSGetID, nil);

 DisposeMenu(gNSMenuHdl);

 with tempReply do
 if good then
 begin
 theGood := TRUE;
 theRefNum := vRefNum;
 theFileName := fName;
 theType := fType;
 end
 end;
 end;
end.
Listing NonStandardFileTest.p

{****************************}
{}
{Non-Standard File Test}
{Created by Steve Sheets}
{}
{Examples of using NonStandardFile unit.}
{}
{****************************}

program NonStandardFileTest;
 uses
 NonStandardFile;
 var
 gGood: BOOLEAN;
 gRefNum: INTEGER;
 gFileName: Str255;
 gType: OSType;
 gTypeList: SFTypeList;
 gNameList: array[0..1] of Str255;
 gFlag: BOOLEAN;
 gNum: INTEGER;
 gIcon1, gIcon2, gIcon3: Handle;
begin
 NSPutFile(‘Please enter the name of the file you wish to save:’, ‘File 
Name’, gGood, gRefNum, gFileName);

 NSSelectPutFile(‘Save copy of Document to disk:’, ‘Save copy of Selection 
to disk:’, ‘File Name’, gGood, gRefNum, gFileName, gFlag);

 gTypeList[0] := ‘TEXT’;
 gNameList[0] := ‘Text files’;
 gTypeList[1] := ‘PNTG’;
 gNameList[1] := ‘MacPaint files’;
 NSGetFile(‘Please select a file:’, 2, @gTypeList, @gNameList, gGood, 
gRefNum, gFileName, gType);

 gIcon1 := GetResource(‘ICN#’, 1000);
 gIcon2 := GetResource(‘ICN#’, 1001);
 gIcon3 := GetResource(‘ICN#’, 1002);
 NSIconPutFile(‘Name’, 1, gIcon1, gIcon2, gIcon3, nil, ‘MacPaint’, ‘Text’, 
‘PICT’, ‘’, ‘Save copy file to MacPaint document:’, ‘Save file as Text 
document:’, ‘Save copy file to PICT document:’, ‘’, gGood, gRefNum, gFileName, 
gNum);
 ReleaseResource(gIcon1);
 ReleaseResource(gIcon2);
 ReleaseResource(gIcon3);
end.
Listing:  NonStandardFile.r

/*--------------------------------------------------------
#
#Non-Standard File Resources
#Created by Steve Sheets
#
#Provides 4 different new user interfaces for
#the Get & Put dialogs.
#
#This resource file contains resource needed
#for the Unit as well as the resources needed
#for the test program, Non-Standard File Test.
#
#Compile this file into resource file with command:
#
#Rez ‘NonStandard File.r’ -o ‘NonStandard File Resources’
#
----------------------------------------------------------*/

#include “Types.r”

/* Dialog Template & Dialog item list resources */
/* required for the Unit. */

resource ‘DLOG’ (500, purgeable) {
 {0, 0, 256, 348},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 500,
 “”
};

resource ‘DLOG’ (501, purgeable) {
 {0, 0, 200, 304},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 501,
 “”
};

resource ‘DLOG’ (502, purgeable) {
 {0, 0, 220, 304},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 502,
 “”
};

resource ‘DLOG’ (503, purgeable) {
 {0, 0, 268, 304},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 503,
 “”
};

resource ‘DITL’ (500, purgeable) {
 { /* array DITLarray: 13 elements */
 /* [1] */
 {138, 256, 156, 336},
 Button {
 enabled,
 “Open”
 },
 /* [2] */
 {0, 699, 80, 717},
 Button {
 enabled,
 “Hidden”
 },
 /* [3] */
 {163, 256, 181, 336},
 Button {
 enabled,
 “Cancel”
 },
 /* [4] */
 {39, 232, 59, 347},
 UserItem {
 disabled
 },
 /* [5] */
 {68, 256, 86, 336},
 Button {
 enabled,
 “Eject”
 },
 /* [6] */
 {93, 256, 111, 336},
 Button {
 enabled,
 “Drive”
 },
 /* [7] */
 {39, 12, 185, 230},
 UserItem {
 enabled
 },
 /* [8] */
 {39, 229, 185, 246},
 UserItem {
 enabled
 },
 /* [9] */
 {124, 252, 125, 340},
 UserItem {
 disabled
 },
 /* [10] */
 {0, 660, 101, 756},
 StaticText {
 disabled,
 “”
 },
 /* [11] */
 {227, 62, 247, 246},
 UserItem {
 enabled
 },
 /* [12] */
 {200, 12, 218, 336},
 StaticText {
 disabled,
 “”
 },
 /* [13] */
 {227, 12, 247, 61},
 StaticText {
 disabled,
 “Show:”
 }
 }
};

resource ‘DITL’ (501, purgeable) {
 { /* array DITLarray: 8 elements */
 /* [1] */
 {132, 218, 150, 288},
 Button {
 enabled,
 “Save”
 },
 /* [2] */
 {158, 218, 176, 288},
 Button {
 enabled,
 “Cancel”
 },
 /* [3] */
 {136, 14, 168, 197},
 StaticText {
 disabled,
 “Save as:”
 },
 /* [4] */
 {29, 198, 49, 302},
 UserItem {
 disabled
 },
 /* [5] */
 {56, 218, 74, 288},
 Button {
 enabled,
 “Eject”
 },
 /* [6] */
 {82, 218, 100, 288},
 Button {
 enabled,
 “Drive”
 },
 /* [7] */
 {173, 17, 189, 194},
 EditText {
 enabled,
 “”
 },
 /* [8] */
 {29, 14, 127, 197},
 UserItem {
 disabled
 }
 }
};

resource ‘DITL’ (502, purgeable) {
 { /* array DITLarray: 10 elements */
 /* [1] */
 {132, 218, 150, 288},
 Button {
 enabled,
 “Save”
 },
 /* [2] */
 {158, 218, 176, 288},
 Button {
 enabled,
 “Cancel”
 },
 /* [3] */
 {136, 14, 168, 197},
 StaticText {
 disabled,
 “Save as:”
 },
 /* [4] */
 {29, 198, 49, 302},
 UserItem {
 disabled
 },
 /* [5] */
 {56, 218, 74, 288},
 Button {
 enabled,
 “Eject”
 },
 /* [6] */
 {82, 218, 100, 288},
 Button {
 enabled,
 “Drive”
 },
 /* [7] */
 {173, 17, 189, 194},
 EditText {
 enabled,
 “”
 },
 /* [8] */
 {29, 14, 127, 197},
 UserItem {
 disabled
 },
 /* [9] */
 {199, 17, 217, 103},
 RadioButton {
 enabled,
 “Document”
 },
 /* [10] */
 {199, 113, 217, 194},
 RadioButton {
 enabled,
 “Selection”
 }
 }
};

resource ‘DITL’ (503, purgeable) {
 { /* array DITLarray: 12 elements */
 /* [1] */
 {132, 218, 150, 288},
 Button {
 enabled,
 “Save”
 },
 /* [2] */
 {158, 218, 176, 288},
 Button {
 enabled,
 “Cancel”
 },
 /* [3] */
 {136, 14, 168, 197},
 StaticText {
 disabled,
 “Save as:”
 },
 /* [4] */
 {29, 198, 49, 302},
 UserItem {
 disabled
 },
 /* [5] */
 {56, 218, 74, 288},
 Button {
 enabled,
 “Eject”
 },
 /* [6] */
 {82, 218, 100, 288},
 Button {
 enabled,
 “Drive”
 },
 /* [7] */
 {173, 17, 189, 194},
 EditText {
 enabled,
 “”
 },
 /* [8] */
 {29, 14, 127, 197},
 UserItem {
 disabled
 },
 /* [9] */
 {209, 10, 258, 81},
 UserItem {
 enabled
 },
 /* [10] */
 {209, 81, 258, 152},
 UserItem {
 enabled
 },
 /* [11] */
 {209, 152, 258, 223},
 UserItem {
 enabled
 },
 /* [12] */
 {209, 223, 258, 294},
 UserItem {
 enabled
 }
 }
};

/* Icon resources (MacPaint, Text & PICT) used in */
/* the Test program with the NSGetFile call. */

resource ‘ICN#’ (1002) {
 { /* array: 2 elements */
 /* [1] */
 $”0F FF FE 00 08 00 03 00 08 00 02 80 08 00 02 40"
 $”08 00 02 20 08 00 02 10 08 7F C3 F8 08 40 40 08"
 $”08 40 40 08 08 40 40 08 08 40 40 08 08 40 78 08"
 $”08 41 04 08 08 42 02 08 08 7C 01 08 08 04 01 08"
 $”08 04 01 08 08 04 01 08 08 02 02 08 08 01 04 08"
 $”08 00 F8 08 08 00 00 08 08 04 00 08 08 0A 00 08"
 $”08 11 00 08 08 20 80 08 08 40 40 08 08 80 20 08"
 $”09 FF F0 08 08 00 00 08 08 00 00 08 0F FF FF F8",
 /* [2] */
 $”0F FF FE 00 0F FF FF 00 0F FF FF 80 0F FF FF C0"
 $”0F FF FF E0 0F FF FF F0 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 }
};

resource ‘ICN#’ (1001) {
 { /* array: 2 elements */
 /* [1] */
 $”0F FF FC 00 08 00 06 00 08 00 05 00 08 00 04 80"
 $”08 F8 04 40 08 00 04 20 08 1F E7 F0 08 00 00 10"
 $”08 1F E0 10 08 00 00 10 08 03 FC 10 08 00 00 10"
 $”08 1F 00 10 08 00 00 10 08 1F FE 10 08 00 00 10"
 $”08 FF E0 10 08 00 00 10 08 3C 00 10 08 00 00 10"
 $”08 0F C0 10 08 00 00 10 08 0F F8 10 08 00 00 10"
 $”08 FC 00 10 08 00 00 10 08 3F E0 10 08 00 00 10"
 $”08 07 FE 10 08 00 00 10 08 00 00 10 0F FF FF F0",
 /* [2] */
 $”0F FF FC 00 0F FF FE 00 0F FF FF 00 0F FF FF 80"
 $”0F FF FF C0 0F FF FF E0 0F FF FF F0 0F FF FF F0"
 $”0F FF FF F0 0F FF FF F0 0F FF FF F0 0F FF FF F0"
 $”0F FF FF F0 0F FF FF F0 0F FF FF F0 0F FF FF F0"
 $”0F FF FF F0 0F FF FF F0 0F FF FF F0 0F FF FF F0"
 $”0F FF FF F0 0F FF FF F0 0F FF FF F0 0F FF FF F0"
 $”0F FF FF F0 0F FF FF F0 0F FF FF F0 0F FF FF F0"
 $”0F FF FF F0 0F FF FF F0 0F FF FF F0 0F FF FF F0"
 }
};

resource ‘ICN#’ (1000) {
 { /* array: 2 elements */
 /* [1] */
 $”0F FF FE 00 08 00 03 00 09 D0 02 80 09 D0 02 40"
 $”09 D0 02 20 09 D0 02 10 09 D0 03 F8 09 D0 00 08"
 $”09 D0 00 08 09 D0 00 08 09 D0 00 08 09 D0 00 08"
 $”09 F0 00 08 09 10 00 08 09 10 00 08 09 10 00 08"
 $”09 10 00 08 09 10 00 08 08 E0 00 08 09 F0 00 08"
 $”09 F0 00 08 09 F8 00 08 09 F8 00 08 09 E8 5F E8"
 $”09 F8 0B E8 08 D0 3F E8 08 F0 FF E8 08 70 3F E8"
 $”08 19 FF E8 08 00 00 08 08 00 00 08 0F FF FF F8",
 /* [2] */
 $”0F FF FE 00 0F FF FF 00 0F FF FF 80 0F FF FF C0"
 $”0F FF FF E0 0F FF FF F0 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 $”0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
 }
};

 
AAPL
$526.19
Apple Inc.
+7.18
MSFT
$40.15
Microsoft Corpora
-0.26
GOOG
$541.40
Google Inc.
-15.14

MacTech Search:
Community Search:

Software Updates via MacUpdate

PDFpenPro 6.2 - Advanced PDF toolkit for...
PDFpenPro allows users to edit PDF's easily. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Create... Read more
PDFpen 6.2 - Edit and annotate PDFs with...
PDFpen allows users to easily edit PDF's. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Features... Read more
Monolingual 1.5.9 - Remove unwanted OS X...
Monolingual is a program for removing unnecesary language resources from OS X, in order to reclaim several hundred megabytes of disk space. It requires a 64-bit capable Intel-based Mac and at least... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
Starcraft II: Wings of Liberty 1.1.1.180...
Download the patch by launching the Starcraft II game and downloading it through the Battle.net connection within the app. Starcraft II: Wings of Liberty is a strategy game played in real-time. You... Read more
Sibelius 7.5.0 - Music notation solution...
Sibelius is the world's best-selling music notation software for Mac. It is as intuitive to use as a pen, yet so powerful that it does most things in less than the blink of an eye. The demo includes... Read more
Typinator 5.9 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more
MYStuff Pro 2.0.16 - Create inventories...
MYStuff Pro is the most flexible way to create detail-rich inventories for your home or small business. Add items to MYStuff by dragging and dropping existing information, uploading new images, or... Read more
TurboTax 2013.r17.002 - Manage your 2013...
TurboTax guides you through your tax return step by step, does all the calculations, and checks your return for errors and overlooked deductions. It lets you file your return electronically to get... Read more
TrailRunner 3.8.769 - Route planning for...
Note: While the software is classified as freeware, it is actually donationware. Please consider making a donation to help support development. TrailRunner is the perfect companion for runners,... Read more

Latest Forum Discussions

See All

Unpossible Review
Unpossible Review By Carter Dotson on April 17th, 2014 Our Rating: :: RALPH WIGGUM APPROVESUniversal App - Designed for iPhone and iPad Unpossible is much better than its English!   | Read more »
Hitman GO Review
Hitman GO Review By Carter Dotson on April 17th, 2014 Our Rating: :: GO HITMAN, GO!Universal App - Designed for iPhone and iPad Hitman GO is not the obvious way to do a mobile version of the Hitman series, but it’s an incredibly... | Read more »
Monster High Ghouls and Jewels is a Frea...
Monster High Ghouls and Jewels is a Freaky Fashion-Forward Match-3 Puzzler Posted by Rob Rich on April 17th, 2014 [ permalink ] | Read more »
Dinosaur Train A to Z Review
Dinosaur Train A to Z Review By Amy Solomon on April 17th, 2014 Our Rating: :: DINO DETAILSUniversal App - Designed for iPhone and iPad Dinosaur Train A to Z is an educational app about dinosaurs that includes In-App Purchases... | Read more »
Easter Comes to Junk Jack X – Bringing N...
Easter Comes to Junk Jack X – Bringing New Crafts, Chemistry, and More Posted by Rob Rich on April 17th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Call of Cookie Review
Call of Cookie Review By Jordan Minor on April 17th, 2014 Our Rating: :: COOKIE CRUMBLESUniversal App - Designed for iPhone and iPad Call of Cookie proves that plants aren’t the only fighting foods out there.   | Read more »
Corel Launches Video Editing App Pinnacl...
Corel Launches Video Editing App Pinnacle Studio for iPhone, Updates iPad Version for iOS 7 Posted by Tre Lawrence on April 17th, 2014 [ | Read more »
Bad Vamp Review
Bad Vamp Review By Jennifer Allen on April 17th, 2014 Our Rating: :: BASIC VAMPIRIC ADVENTURESUniversal App - Designed for iPhone and iPad Run or destroy the vampires in this simple, single-screen game that lacks real bite.   | Read more »
The Shadow Sun gets a New Update, Goes o...
The Shadow Sun gets a New Update, Goes on Sale for the First Time Since its Release Posted by Tre Lawrence on April 17th, 2014 [ permalink ] | Read more »
Bullet Pea Review
Bullet Pea Review By Jordan Minor on April 17th, 2014 Our Rating: :: PEA SHOOTERUniversal App - Designed for iPhone and iPad Bullet Pea’s “jumps only” gameplay is novel in theory, but has problems in practice.   | Read more »

Price Scanner via MacPrices.net

Hyundai Brings Apple CarPlay To The 2015 Sona...
Hyundai Motor America has announced it will bring Apple CarPlay functionality to the 2015 Sonata. CarPlay is pitched as a smarter, safer and easier way to use iPhone in the car and gives iPhone users... Read more
Updated iPads Coming Sooner Than We Had Thoug...
MacRumors, cites KGI securities analyst Ming Chi Kuo, well-respected as an Apple product prognisticator, saying that Apple will introduce an upgraded iPad Air and iPad mini in 2014/Q3, meaning the... Read more
Toshiba Unveils New High And Low End Laptop M...
Toshiba has announced new laptop models covering both the high-end and low-end of the notebook computer spectrum. Toshiba 4K Ultra HD Laptop Toshiba’s new Satellite P55t features one of the world’s... Read more
Save up to $270 with Apple refurbished 13-inc...
The Apple Store has Apple Certified Refurbished October 2013 13″ Retina MacBook Pros available starting at $1099, with models up to $270 off MSRP. Apple’s one-year warranty is standard, and shipping... Read more
Apple now offering refurbished iPad mini with...
The Apple Store has Certified Refurbished 2nd generation iPad minis with Retina Displays now available starting at $339. Apple’s one-year warranty is included with each model, and shipping is free.... Read more
Microsoft Blinks – Drops Microsoft Office 365...
Microsoft has dropped the annual subscription fee for Microsoft Office 365 Personal – which is needed in order to create and edit documents in Microsoft Office for iPad. However, Apple’s iOS and OS X... Read more
New AVG Vault Apps for iOS and Android Help K...
AVG Technologies N.V. an online security company for 177 million active users, has announced the launch of its latest mobile application, AVG Vault. The free app introduces an innovative user... Read more
Free Local Carrot iPhone App Helps Find Fresh...
I love fresh vegetables. I’m not a vegan, although I was for several years in the 1980s, but fresh vegetables and other whole foods are still my dietary mainstays as a matter of taste rather than... Read more
CarSO Pro – Car Service and Finance Manager/O...
Lviv, Ukraine-based BM-Studios’ CarSO Pro is a tool to manage operations concerning your car. Never forget to change the oil or prolong the insurance for your car. Remember when you’ve done the car... Read more
Apple refurbished iPad Airs available startin...
Apple is now offering Certified Refurbished iPad Airs for up to $140 off MSRP. Apple’s one-year warranty is included with each model, and shipping is free. The following Airs are available today: -... Read more

Jobs Board

*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* Retail - Manager - Holyoke - Apple I...
Job Summary Keeping an Apple Store thriving requires a diverse set of leadership skills, and as a Manager, you’re a master of them all. In the store’s fast-paced, Read more
*Apple* Retail - Manager - Apple (United Sta...
Job SummaryKeeping an Apple Store thriving requires a diverse set of leadership skills, and as a Manager, you're a master of them all. In the store's fast-paced, dynamic 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* Retail - Market Leader - Cincinnati...
…challenges of developing individuals, building teams, and affecting growth across Apple Stores. You demonstrate successful leadership ability - focusing on excellence Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.