Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Archive » net.micro.mac » Sample SFGetFile filter (Re: ascii.question 3)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Sample SFGetFile filter (Re: ascii.question 3) [message #155951] Wed, 16 October 1985 14:06
guido is currently offline  guido
Messages: 50
Registered: May 2013
Karma: 0
Member
Article-I.D.: boring.6654
Posted: Wed Oct 16 14:06:39 1985
Date-Received: Fri, 18-Oct-85 21:23:17 EDT
References: <1034@ttds.UUCP>
Reply-To: guido@mcvax.UUCP (Guido van Rossum)
Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam
Lines: 47
Apparently-To: rnews@mcvax.LOCAL

Here is a sample filter procedure for SFGetFile that will work with SUMacC.
This particular filter makes that SFGetFile will only display files whose
resource fork is not empty.  The last few lines contain an application
in the "ascii" program that prompted this reply.

The following comments apply to all cases where a Toolbox routine calls
on a Pascal routine (this is also explained shortly in the SUMacC
documentation but a working example really helps):

The SUMacC library routine getpargs must be used to get access to the
arguments for the filter, since the Toolbox calls it in Pascal style.
In general, the "struct pargs" must contain declarations for all arguments
IN REVERSE ORDER.  Pascal INTEGERs must be mapped to C shorts, and the usual
transformation for structs, arrays and VAR parameters to pointers apply.
Getpargs returns a pointer where the return value should be stored if
the Pascal routine is a function.  Boolean function results should be
stored as if they were a character.  (The SFGetFile filter must return
TRUE (= 1) to skip a file!)

(On the original wish to check for files with FONT resources: I believe
this can be done by calls to OpenResFile, CountResources and CloseResFile;
however OpenResFile also preloads all resources whose preload bit
is on, so this may cause memory full conditions if there are many such
resources.  Also I see no easy way to restrict CountResources to only
the just opened file, so you must subtract the result of CountResources
before the OpenResFile.)

	Guido van Rossum, CWI, Amsterdam (guido@mcvax.UUCP)

file_filter()
{
	struct pargs {
		FileParam *paramBlock;
	} pargs;
	char *retval= (char *) getpargs(&pargs, sizeof pargs);
	if (pargs.paramBlock->ioFlRLgLen == 0)
		*retval= 1; /* TRUE => skip this file */
	else
		*retval= 0; /* FALSE => show this file*/
}

open_file (){
    Point top_left;

    SetPt (&top_left, 50, 50);
    SFGetFile (&top_left, "", file_filter, -1, "", (ProcPtr) 0, &file_record);
    ...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Submenus: Are they really that good?
Next Topic: Need vt-220 emulator
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Nov 24 22:17:57 EST 2024

Total time taken to generate the page: 0.06364 seconds