Database Reference
In-Depth Information
Figure 17-14. The “Set Variable” Options dialog box lets you create a variable by giving it a name
and assigning it a value. Since you can use variables inside calculations, their naming rules are
similar to those of field names. Don't use characters like a comma, +, -, *, or any other symbol that
has a mathematical meaning and might confuse a calculation. You should also avoid names like
Date or List that are also the names of functions. It's common to use camel case and no spaces in
variable names.
The Set Script Variable script step has three options:
Name . Choose a short, descriptive name. All script variable names require a $ prefix. If
you forget to type the prefix, FileMaker adds it for you. But get in the habit of typing the
prefix, since it determines how long the value in the variable is available. A single $
means the variable is local and lasts only while your script is running. Local variables
aren't sent to subscripts. A double $$ prefix creates a global variable, and its value per-
sists through subscripts and even after all scripts have finished running. Global variables
are cleared when you close the database.
Value . The value you want to store in the variable. Values can be static text or the dy-
namic result of a calculation.
Repetition . A variable can store multiple values, like a repeating field does. Repetitions
are optional, and not common. But if you know what a data array is, and want to create
one, variable repetitions are one way to get that job done.
Since you can pass the value in a local variable with either a script result or a script paramet-
er, some programmers consider global variables sloppy housekeeping, because once the
script finishes running, variables just lie around your database full of values that have no
meaning outside a script. One good reason to use a global variable is when you're using a
merge variable to display a message on a layout after the script has finished running ( Show-
ing Feedback with a Merge Variable ) . In that case, you have to use a global variable.
Search WWH ::




Custom Search