CountAppFiles
CountAppFiles Count selected files; determine Open or Print
#include <SegLoad.h> Segment Loader
void CountAppFiles(doWhat, fileCnt );
short *doWhat ; receives action code: 0=open, 1=print
short *fileCnt ; receives number of files to process
Call CountAppFiles to determine how many files the user had selected in the
Finder. This is the first step in determining which file or files the user wants
you to process and what the user wants you to do with it (them).
doWhat is the address of a short. Upon return, it contains one of the
following action codes ( defined in SegmentLdr.h):
appOpen 0 Open the file(s)
appPrint 1 Print the file(s)
fileCnt is the address of a short. Upon return, it contains the number of
files the user selected in the Finder before selecting Open or Print.
If the user double-clicked a document, fileCnt will return containing
a 1.
Returns: none

Notes: After initializing the various managers, most applications will want to
follow these steps to determine what files the user wishes to open or print:
Call CountAppFiles. If fileCnt =0, open a blank, un titled document.
Otherwise...
Call GetAppFiles indexing from 1 through fileCnt. Use the returned
information to open or print each file. If you can't or don't want to process
the file, issue a CautionAlert.
After opening or printing the file, call ClrAppFiles with the same index.
This system lets a user open one or more documents automatically.
Example
#include <SegLoad.h>
#include
short fileCnt, doWhat, index;
AppFile fileStuff;
char *cp = (char *)&fileStuff.ftype; /* ease handling of file type */
CountAppFiles( &doWhat, &fileCnt );
for (index = 1; index <= fileCnt; index++ ) {
GetAppFiles( index, &fileStuff );
/* --- normally you'd open or print the file here ---
*/
PtoCstr( fileStuff.fName ); [TOKEN:12074] convert p-string for printf */
printf("Index: %d, Type: '%c%c%c%c'; name: '%s' \n",
index, cp[0],cp[1],cp[2],cp[3], fileStuff.fName );
ClrAppFiles( index );
}