ccc_ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (05/29/90)
Ever found the standard Pascal definition for SFGetFile/SFPGetFile to be a nuisance? I have. An SFTypeList of 4 elements is almost never what I want. Often I just want one type. Several times I've wanted a dynamic list of types, which could be of any length. Also, call me irresponsible, but I think it's inelegant to have an assembly- language glue routine when a short inline will do the trick. So here my alternative declarations of some toolbox calls. First of all, the disk-initialisation package in DiskInit.p: Procedure DILoad; Inline $3F3C, $0002, {move.w #2, -(sp)} $A9E9; {_Pack2} Procedure DIUnload; Inline $3F3C, $0004, {move.w #4, -(sp)} $A9E9; {_Pack2} Function DIBadMount ( where : Point; evtMessage : LongInt ) : Integer; Inline $4267, {clr.w -(sp)} $A9E9; {_Pack2} Function DIFormat ( drvNum : Integer ) : OSErr; Inline $3F3C, $0006, {move.w #6, -(sp)} $A9E9; {_Pack2} Function DIVerify ( drvNum : Integer ) : OSErr; Inline $3F3C, $0008, {move.w #8, -(sp)} $A9E9; {_Pack2} Function DIZero ( drvNum : Integer; volName : Str255 ) : OSErr; Inline $3F3C, $000A, {move.w #10, -(sp)} $A9E9; {_Pack2} And here are new definitions for most of the routines in Packages.p (IUCompString and IUEqualString are a little more complicated, so I leave them as glue). SFGetFile and SFPGetFile have their typeList arguments declared as "Ptr", so you can pass just about anything you like. Oh, and StringToNum is a function, which I've found to be far more convenient, particularly when I only want an integer result. { Standard File Package ----------------------------------------------} Procedure SFPutFile ( where : Point; prompt : Str255; origName : Str255; dlgHook : ProcPtr; var reply : SFReply ); Inline $3F3C, $0001, {move.w #1, -(sp)} $A9EA; {_Pack3} Procedure SFPPutFile ( where : Point; prompt : Str255; origName : Str255; dlgHook : ProcPtr; var reply : SFReply; dlgID : Integer; filterProc : ProcPtr ); Inline $3F3C, $0003, {move.w #3, -(sp)} $A9EA; {_Pack3} Procedure SFGetFile ( where : Point; prompt : Str255; fileFilter: ProcPtr; numTypes : Integer; typeList : Ptr; dlgHook : ProcPtr; var reply : SFReply ); Inline $3F3C, $0002, {move.w #2, -(sp)} $A9EA; {_Pack3} Procedure SFPGetFile ( where : Point; prompt : Str255; fileFilter : ProcPtr; numTypes : Integer; typeList : Ptr; dlgHook : ProcPtr; var reply : SFReply; dlgID : Integer; filterProc : ProcPtr ); Inline $3F3C, $0004, {move.w #4, -(sp)} $A9EA; {_Pack3} { International Utilities Package ------------------------------------} Function IUGetIntl ( theID : Integer ) : Handle; Inline $3F3C, $0006, {move.w #6, -(sp)} $A9ED; {_Pack6} Procedure IUSetIntl ( refNum : Integer; theID : Integer; intlParam : Handle ); Inline $3F3C, $0008, {move.w #8, -(sp)} $A9ED; {_Pack6} Procedure IUDateString ( dateTime : LongInt; longFlag : DateForm; var result : Str255 ); Inline $4267, {clr.w -(sp)} $A9ED; {_Pack6} Procedure IUDatePString ( dateTime : LongInt; longFlag : DateForm; var result : Str255; intlParam : Handle ); Inline $3F3C, $000E, {move.w #14, -(sp)} $A9ED; {_Pack6} Procedure IUTimeString ( dateTime : LongInt; wantSeconds : Boolean; var result : Str255 ); Inline $3F3C, $0002, {move.w #2, -(sp)} $A9ED; {_Pack6} Procedure IUTimePString ( dateTime : LongInt; wantSeconds : Boolean; var result : Str255; intlParam : Handle ); Inline $3F3C, $0010, {move.w #16, -(sp)} $A9ED; {_Pack6} Function IUMetric : Boolean; Inline $3F3C, $0004, {move.w #4, -(sp)} $A9ED; {_Pack6} Function IUMagString ( aPtr, bPtr : Ptr; aLen, bLen : Integer ) : Integer; Inline $3F3C, $000A, {move.w #10, -(sp)} $A9ED; {_Pack6} Function IUMagIDString ( aPtr, bPtr : Ptr; aLen, bLen : Integer ) : Integer; Inline $3F3C, $000C, {move.w #12, -(sp)} $A9ED; {_Pack6} { Binary-Decimal Conversion Package ----------------------------------} Function StringToNum ( theString : Str255 ) : LongInt; Inline $205F, {move.l (sp)+, a0} $3F3C, $0001, {move.w #1, -(sp)} $A9EE, {_Pack7} $2E80; {move.l d0, (sp)} Procedure NumToString ( theNum : LongInt; var theString : Str255 ); Inline $205F, {move.l (sp)+, a0} $201F, {move.l (sp)+, d0} $4267, {clr.w -(sp)} $A9EE; {_Pack7} Lawrence D'Oliveiro Computer Services Dept fone: +64-71-562-889 University of Waikato fax: +64-71-384-066 Hamilton, New Zealand electric mail: ldo@waikato.ac.nz "What makes you say that I'm always answering a question with a question?"