Go to Contents
Previous
Page
Next
Page
Contents > Creating a database > Using variables

Using variables
In FileMaker Pro, you can use variables in:
file paths. See Creating file paths.
scripting. See Set Variable script step.
calculations. See Let function.
Variables add flexibility and portability to your database, and can be used instead of global fields in your database schema.
Using the Set Variable script step or the Let function, you can create local and global variables. The scope of local and global variables is limited to the current file.
A local variable can only be used in script steps in the currently executing script. The value in a local variable is cleared when the script exits. Local variables are prefixed with $.
A global variable can be used in a calculation or script anywhere in a file, for example, other scripts or file path. The value of a global variable is not cleared until the file is closed. Prefix global variables with $$.
Local and global variables (or even two local variables in different scripts) can have the same name but they are treated as different variables and can store different values.
Anywhere that you specify a path to a file or folder, you can use variables separated by "/", ":", or carriage return.
Variables let you specify file or folder paths dynamically in the following script steps:
Insert Picture
Insert QuickTime
Insert File
Export Field Contents
Import Records
Export Records
Save Records as PDF
Save Records as Excel
Save a Copy as
Recover File
Convert File
Send Mail (Attach File option)
Send Event
Send DDE Execute
Examples of using variables in file paths
Assume the following variables:

$fileName = "test.xls"
$username = "JohnSmith"
$searchList = "file:old results.txt
               file:../archived/old results.txt"
To Path list entry Resolved path list
Specify one or more directories in a path
file:$username/$fileName
file:JohnSmith/test.xls
Specify one or more complete paths
$searchList
file:old results.txt
file:../archived/old results.txt
Notes
Variables are only supported in script steps that use stored file paths.
Variables are not supported in file paths that are stored in container fields.
Variables are not supported in FileMaker data source references.
The data type of a variable is determined dynamically based on the assigned data. The default data type is Text.

Contents > Creating a database > Using variables
Previous
Page
Next
Page