FutureBasic Logo

<<    Index    >> FutureBasic 5

on FinderInfo   statement

on FinderInfo {fn userFunction|gosub{lineNumber|"stmtLabel"}}

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.
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.
A boolean value that is zero if the file is to be opened and non-zero if it is to be printed.
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 @ count, action, j
   dim as OSType @ fType
   count = 0 // set to ask "How many?"
   action = FinderInfo( count, fs, fType ) // FSSpec &
   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 )
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
until 0

See Also:
FinderInfo; open; Appendix A - File Object Specifiers; Appendix H - Printing; resources