dbhill Posted August 25, 2006 Posted August 25, 2006 I want to advance my skill level in using Script Variables in a variety of situations. FileMaker has only minimal references to using script variables. Can anyone recommend any books or videos that cover this topic in some depth? Any suggestions are greatly appreciated. ~Dennis
Ender Posted August 26, 2006 Posted August 26, 2006 (edited) You might find more details in various FM8 how-to books out there. In general, you deal with script variables in a similar way as you deal with fields. The main difference is their scope and the syntax used for script variable names. There are two types of script variables representing the two possible scopes: Local variables are available only to the current script. Once the script completes or halts, the local variables defined within go away. Local variables are named beginning with a singe dollar sign, like '$myVariable'. Global variables are available throughout the entire file even after the scripts complete or halt. Global variables are named beginning with two dollar signs, like '$$someGlobal'. In both cases, the scope of the variable is limited to the file that they are defined in. To define or change either variable, there are a couple ways: 1. Set Variable[] script step. This explicitly sets a specified variable with a specified value (or calculated value). 2. Let() statement. A Let() statement can be used in any place where a calculation dialog is used. Though a Let() statement is usually used for defining temporary values that are only used for the purposes of the calc they are defined in, you can also define a script variable in the same manner, and those variables have the same scope as they would if they were defined with the Set Variable[] step. As an example, you could have a New Contact Note button that calls a general New Record script, and for a script parameter you send this calc: Let( $$recordID = Table::RecordID; "Add Contact Note" ) Then in the New Record script, the variable(s) can be used in addition to the text part of the script parameter, allowing you to go to the right table based on the parameter, and fill in the right foreign key on the new record that gets created. Script variables can also be used to build a file path that can then be used in the specify File Path dialog in a number of different script steps, like Insert Picture[], Import Records[], and Export Records[]. Edited August 26, 2006 by Guest
Søren Dyhr Posted August 26, 2006 Posted August 26, 2006 I think once again I need to contribute to the confusion :/ although variables prefixed with $ or $$ often are used in scripts, would it leed to a too narrow or tightly fixed definition of the deployment. Similarly could layout-events be utilized, such as tooltips or unstored calc'fields with a presence on a rendered layout: http://www.kevinfrank.com/download/county-highlight-in-portal.zip --sd
dbhill Posted August 27, 2006 Author Posted August 27, 2006 Thank you Ender, for an insightful discussion and examples of script variable usage. I bought the Cue book, "FM8: Functions and Scripts Desk Reference," but was disappointed to find only a page of summary description for Set Variable. I will work with your thoughts to get more experience with the Set Variable and Let possibilities, which is what I need. Gratefully, ~Dennis
Recommended Posts
This topic is 6662 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now