[comp.sys.mac.programmer] Adding a filter function to Standard File Dialog

aep@world.std.com (Andrew E Page) (01/19/91)

A "filter" function supplies you with another layer of file 'filtering'
beyond the typelist that you pass to SFGetFile.  What is passed is a
fileParam paraeter block which contains everying you would ever want to
know about the file, or the means to get to it.  The filter function
will return a TRUE (To include file in the list), or FALSE (to exclude it)

for example... if your program wanted to only look at MS Word text files
where the type is TEXT and the creattor is 'MSWD' you would use a 
type list with one type 'TEXT' and inside the filter you would

do a :

pascal boolean MyFilter(fileParam *f)
{

	if( f->ioFlFndrInfo.fdCreator == 'MSWD' )
		return TRUE ;
	else
		return FALSE ;
}

Sorry that it's in C.  Pascal give's me hives when mentioned and I get
convulsions when forced to work with it.

ADVICE:
	If you are serious about Mac programming:

	S P E N D   T H E   M O N E Y   

and buy IM I-IV

or at least the Macintosh Revealed series.

Another great tool is "Programmer's Online Guide" also from addison 
Wessely.


-- 
****************************************************************************
Andrew E. Page (Warrior Poet)   |   Decision and Effort The Archer and Arrow
Concepts Engineering            |     The difference beteween what we are

231b3679@fergvax.unl.edu (CS 231 section 2) (01/20/91)

I must highly recommend Apple's Sample Code Note #18 which _thoroughly_ covers
every aspect one can imagine about the Standard File package.  It covers the
elementary stuff, simple and complex file filters, and such FAQ's like
"How do I get a complete pathname?" and "How do I make the SF open in a
specific diretory?".  FTP over to apple.com or Sumex-aim.stanford.edu and get
a copy.  And while you're at it, scrap some money together and buy Inside Mac,
at least volume I and II!

-- mike gleason