Media_SetDefaultFolder ( path )
Media_SetDefaultFolder sets the default folder for all MediaManager functions that depend upon a file path.
Parameter | Description |
---|---|
path | Any absolute path or path relative to the current default folder. See also special values below. |
Special values for path
Value | Meaning |
---|---|
.A | Applications (Mac) or Program Files (Windows) folder |
.D | Desktop |
.F | The folder containing the currently active FileMaker Pro application |
.O | Documents folder |
.P | Preferences folder |
.R | The root folder of the boot disk |
.S | System folder |
.T | Temporary folder |
.U:prompt | user selects a folder from the folder dialog |
.V:prompt | user selects a file from the file dialog. Returns filename, sets default folder to the file’s enclosing folder. |
.W | Windows folder (Windows only) |
.X | Trash folder |
.@ | Downloads folder |
.d | Documents folder |
.m | Music folder |
.p | Pictures folder |
.v | Movies folder (Mac), Videos folder (Windows) |
The above codes can be used anywhere a file path is expected. Special values can be combined with relative paths. For example, “.D/foobar/image.jpg” refers to the file image.jpg inside the images folder on the desktop.
At startup, the default folder is set to the root disk.
Path Syntax
All paths to files and folders used by MediaManager follow the conventions of FileMaker Pro. An absolute path starts with slash; relative paths do not. A path to a folder ends in slash; a path to a file ends with the file name. Here are some examples:
An absolute path to a user directory named “Frank” on the Mac:
/Macintosh HD/Users/Frank/
An absolute path to a user directory named “Frank” on Windows Vista and newer:
/c:/Users/Frank/
A relative path to a file named “MyFile.txt” located on the desktop:
.D/MyFile.txt
The Default Folder
MediaManager uses the convention of the “default folder”. This path is set either by using the Media_SetDefaultFolder function or by Set Default Folder script step and is automatically prepended to every file or folder path specified in MediaManager functions. In other words, you can set the default path to any folder, and then simply set all paths to be relative to that default location.
For example, suppose the default path is set to the Desktop folder, with either one of the following:
Set Field [ MyTable::Response ;
Media_SetDefaultFolder (
"/Macintosh HD/Users/Frank/Desktop/"
) ]
Set Field [ MyTable::Response ;
Media_SetDefaultFolder ( ".D" ) ]
If you then use a MediaManager function like Media_ExportField or Export Field script step, you can simply list the file name in the path parameter, and the file will be exported to the desktop (the default folder):
Set Field [ MyTable::Response ;
Media_ExportField (
MyTable::Picture 1 ;
"image.jpg" ;
False
) ]
Similarly, if you want to specify a folder within the default folder, you only need to list the folder and file name, and MediaManager understands that you are specifying a location relative to the default folder (again, the desktop):
Set Field [ MyTable::Response ;
Media_ExportField (
MyTable::Picture 1 ;
"MyPictures/image.jpg" ;
False
) ]
Of course, you can specify a full path at any time and the default path is ignored.
Other Special Notations
../
refers to the enclosing or “parent” folder. It is the equivalent of going “up one level” in the current default path.
For example, if you set the default path is set to a user directory like this–
Set Field [ MyTable::Response ;
Media_SetDefaultFolder (
"/c:/Documents and Settings/Frank/"
) ]
–you can then specify the Users directory with “../”, such as in a Export Field script step like:
Set Field [ MyTable::Response ;
Media_ExportField (
MyTable::Picture 1 ;
"../image.jpg" ;
False
) ]
Returns
An empty string if successful. Otherwise, returns an error message.
With either of the user prompt options (.U and .V), if a user clicks on the Cancel button, MediaManager returns “$0:Cancel”.
Examples
To set the default folder to the desktop:
Set Field [ MyTable::Response ;
Media_SetDefaultFolder ( ".D" ) ]
To set the default folder to the boot disk:
Set Field [ MyTable::Response ;
Media_SetDefaultFolder ( ".R" ) ]
To allow the user to select the default folder with the message “Select a default folder”:
Set Field [ MyTable::Response ;
Media_SetDefaultFolder (
".U:Select a default folder"
) ]