Futurebasic/Language/Reference/on finderinfo

From Wikibooks, open books for an open world
Jump to navigation Jump to search

ON FINDERINFO[edit | edit source]

Statement[edit | edit source]

(+) Appearance (+) Standard Console

Syntax[edit | edit source]

ON FINDERINFO {FN userFunction|GOSUB{lineNumber|"stmtLabel"}}

Revised[edit | edit source]

February, 2002 (Release 6)

Description[edit | edit source]

You establish this vector before entering your event loop. When a file is dropped onto your application's icon or one of your applications files is double-clicked from the Finder, the specified routine is called with information on how to open the file.

The routines are set up to handle up to 1024 files at a time. If this number is insufficient, you will need to change the DIM statement in the header file named "Subs Files.Incl". There are three global values maintained for this vector.

gFBFndrInfoCount

The number of files pending in the queue.

gFBInfoSpec(1024) as FSSpec

An array of file spec records. There is one file spec record for each file that needs to be opened or printed.

gFBInfoAction%(1024)

A boolean value that is zero if the file is to be opened and non-zero if it is to be printed.

Example:
This routine establishes a function that is called when a file is dropped onto the compiled version of the application. It also shows how to determine if a file is to be printed or opened.

/*
   Build the application,
   then drop a text file on to it

LOCAL FN MyOpenFile ( fs as ^FSSpec )
   PRINT "FileName: ";fs.name
END FN

LOCAL FN MyFinderInfo
   DIM AS FSSpec fs
   DIM AS SHORT<spacer type="horizontal" size="21">@ count, action, j
   DIM AS OSTYPE @ fType
   count = 0 // set to ask "How many?"
   action = FINDERINFO( count, fs, fType ) // FSSpec &
OSType
   LONG IF ( count > 0 ) // at least one file wants in
FOR j = 1 TO count // process them all
count = -j
// FSSpec & OSType
action = FINDERINFO( count, fs, fType )
IF ( action == _finderInfoOpen ) AND ¬
( fType == _"TEXT" ) ¬
THEN FN MyOpenFile( fs )
NEXT
FN ClearFinderInfo // in Subs Common.Incl
   END IF
END FN

ON FINDERINFO FN MyFinderInfo

MENU 1,0,1, "File"
MENU 1,1,1, "Quit/Q"
WINDOW 1
DO
   HANDLEEVENTS
UNTIL 0

See Also[edit | edit source]

FINDERINFO; OPEN; Appendix A: Specifying Files and Directories; Appendix H: File Spec Records; Appendix I: Printing; USR SCANFOLDER; RESOURCES