FMPRO Session 5 Conditional Branching
- Tell the script that if something happens to go in one direction or if something else happens to go in another direction. It is a transfer like a railroad switch (thousands of combinations of commands to have it do are possible.)
- Control script steps control the progression of the script by letting you tell FileMaker Pro exactly what to do when and if specific conditions occur.
Use these script steps to:
- call scripts and sub-scripts
- pause and resume a script, based on defined conditions
- conditionally perform script steps using if/then/else logic
- stop a script before it's finished, if a specific condition is met
- create loops that repetitively carry out a sequence of steps in a script, until a condition is met
If Control Step
- Evaluates a Boolean calculation and performs a conditional action based on that evaluation. If the calculation result is not zero, the calculation evaluates to True and the subsequent script steps are executed. If the calculation result is zero, the calculation evaluates to False and the subsequent script steps are not executed.
- Every If step must have a corresponding End If step somewhere after the If step and at the same indentation level. Whenever you use an If script step, ScriptMaker enters an End If step automatically.
- You can also add an additional condition by using the Else step.
Note If you do not specify a calculation or if the calculation is unsuccessful, an error occurs.Options
- Click Specify to define the Boolean calculation. In the Specify Calculation dialog box, type the calculation you want evaluated, or use the field list (on the left), the functions list (on the right), with the mathematical and text operators to build the calculation.
Example
If
("Status (CurrentUserName) = "Jim Davis")
Go to Layout
(Refresh: "Jim's Layout")
Perform Find
(Restore)
End If
Status Function
- Analyzes the monitor, system version, user name, etc. Status functions analyze and display current status information, such as the name of the host, the number of users accessing a file, the monitor, system version, user name, or the current time.
- Status functions are particularly useful when combined with control structures in scripts. They allow access to detailed information, including error checking.
- When viewing all functions by name, use the Status (Status flag) function as a place holder in the calculation formula. Replace the "Status flag" with the status function you will use. For example, you could place Status (Status flag) and then later replace it with Status (CurrentDate).
- An office could have several monitors (B&W, gray scale, color) Utilize color and B&W (with gray scale) layouts for different monitors. "Final Invoice B&W"
Tip: Click on the text tool. Choose Select All
[it will select everything that is text.]
Tip: Click on the line tool. Choose Select All
[it will select all the lines.]
This script checks the value of the Status function CurrentDate to see if an account is past due. If the account is past due, the script performs an action based on which button the user selected in the dialog box that was presented with the Show Message step.
Enter Browse Mode
[]
Go to Layout
["Layout #1"]
Go to Record/Request/Page
[First]
Loop
If
["Date : Status (CurrentDate)-30"]
Show Message
["30 or more days late"]
If
["Status (CurrentMessageChoice) = 1"]
Halt Script
End IfIf
["Status (CurrentMessageChoice) = 2"]
Go to Layout
["Late Notice"]
Print
[ ]
End If
If
["Status (CurrentMessageChoice) = 3"]
Go to Layout
["original layout"]
Dial Phone
[ ]
End If Go to Layout
["original layout"]
Go to Record/Request/Page
[Next]
End Loop
Set Opening LayoutIf
[Status(CurrentScreenDepth) = 1]
[1 bit = B & W]
Go to Layout
["Final Invoice B&W"]
[8 bit = color monitor = lots of density]
Else
Go to Layout
["Final Invoice"]
End If
Tip: Set the "Monitor" control panel to "Black and White" to see how a B&W layout will appear.
Invoice ScreenCould be used as the opening script whenever a Database file is opened.Enter Browse Mode
[]
Perform Script
[Sub Script: "Set Opening Layout"]
Page Setup
[Restore: No Dialogue]
Creative ScriptingUse the Claris Help Viewer for FileMaker Pro (under the Apple Menu) and type in "scripts". It is nicely written and a quick reference as to how to script. There is lots of detailed information on scripts with specific examples and lots of main and sub articles (e.g. see how conditional branching works.)