dropfromfinder
TYPES
,
FILES

The dropfromfinder statement processes any files or folders that have been dropped on a form from the finder.


Parameters

This statement has two parameters:

types – Specifies types of files that we want to accept. This can be a series of four character type codes, or a series of file extensions. If this parameter is left blank then all files will be accepted. See the description below for more information.

files – Field or variable that will contain a carriage return separated array listing all files and folders (including path) dropped.


Description

This statement processes any files or folders that have been dropped on a form from the finder. It is designed to be used in a procedure triggered by a Drag Receiver object.

This example combines the text from all dropped text files into a single variable named droppedText. If any folders were dropped, any text files nested inside will also be included.

local filesToProcess,droppedText
dropfromfinder "TEXT",filesToProcess
droppedText = ""
looparray filesToProcess,cr(),xfile
    droppedText = droppedText+cr()+fileload(xfile) 
endloop

FILE TYPES

The first parameter specifies what types of files should be processed (you can also specify this in the Drag Receiver object itself).

If the types parameter begins with a period (.), the parameter should include one or more file extensions. If you include multiple extensions, there should be no spaces or punctuation in between the extensions, other than the period. This example will only process .jpg, .gif and .png files, all other types of files will be ignored.

dropfromfinder ".jpg.gif.png",imageFiles

If the types parameter does not begin with a period, it must be 1 or more four character type codes, for example TEXT, PICT, etc. Here is another way to process only these three types of image files:

dropfromfinder "JPEGGIFfPNGf",imageFiles

To learn more about the type codes supported by Panorama, see the filetypecreator( function.

If the types parameter is empty (blank), all dropped files will be included.

dropfromfinder "",allDroppedFiles

HFS vs. UNIX Paths

The dropfromfinder statement returns a carriage return delimited list of all files that were dropped (subject to the file type restrictions described above). For each file, the entire path is returned. If the file type is specified as one or more file extensions (for example .txt.jpg.gif.png), the path will be returned in UNIX format, for example:

/Users/tomfrank/Projects/Library.jpg
/Users/tomfrank/Projects/Gas Mileage.txt

If the file type is specified as 4 character type codes (for example TEXTJPEGGIFfPNGf) the path will be returned in HFS format, for example:

Macintosh HD:Users:tomfrank:Projects:Library.jpg
Macintosh HD:Users:tomfrank:Projects:Gas Mileage.txt

If you want to override the format, you can add a <unix> or <hfs> tag to the file specification. This example uses 4 character codes to specify image files, but generates the output in UNIX format.

dropfromfinder "<unix>JPEGGIFfPNGf",imageFiles

The example shows the <unix> tag at the beginning, but it can be included anywhere in the specification.

EXPANDING FOLDERS

You can also drop folders onto the Drag Receiver object. Normally, these folders will be removed from the list and replaced with the names (and paths) of the actual files in the folder (subject to the file type restrictions specified). This means that you don’t have to worry about folders, the list will only contain files.

If you want to, you can disable folder expansion and deal with folders yourself. To do this, add a <keepfolders> tag to the file specification.

dropfromfinder "<unix><keepfolders>JPEGGIFfPNGf",imageFilesAndFolders

If you do this, you’ll have to check each individual item to see if it is a folder. Usually the best way to do this is with the folderexists( function.

Note: For compatibility with earlier versions of Panorama, folder expansion is also disabled if the filter begins with the ƒ character.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but with new options for specifying files (by either type or extension) and the output format (HFS vs. UNIX).