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"
 }
};

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but 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 MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
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
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.