Database Reference
In-Depth Information
THINK LIKE A DEVELOPER: TESTING MULTIPLE CONDITIONS REDUX
Back on Testing Multiple Conditions , you learned how to write a script that tested multiple condi-
tions. Now it's time to learn how to take a more advanced approach to the same problem. Instead of
calling three different custom dialog boxes that are each hard-coded, you can set your message in a
local variable and then call a single custom dialog box that changes based on which condition tested
as true.
Why go to all that trouble? It's certainly not because FileMaker gives you a limited number of Show
Custom Dialog boxes and makes you ration their use.
The rationale behind this exercise is to give you a taste of the software engineer's approach to
FileMaker's variables. By thinking in terms of storing data that doesn't need to last inside a local
variable (which lives only as long as the script that created it is running), instead of as an option in a
dialog box, you're well on the way to solving more advanced problems as they arise. And if you've
come from another programming background, you'll be glad to see that FileMaker handles variable
storage like some of the big boys in the programming world.
Here's how it looks:
If [ Get ( CurrentTime ) > Time(4 ; 0 ; 0)
and
Get ( CurrentTime ) < Time(12 ; 0 ; 0) ]
Set Variable [ $customMessage ; Value:
"Good Morning!" ]
Else If [ Get ( CurrentTime ) > Time(12 ;
0; 0) and Get ( CurrentTime ) < Time(18 ;
0
; 0)
]
Set Variable [ $customMessage ; Value:
"Good Afternoon!" ]
Else
Set Variable [ $customMessage ; Value:
"Go To Bed" ]
End If
Show Custom Dialog [ Title: "Greetings" ;
Message: $customMessage ; Buttons:
"Thanks" ]
Context is important, too. You can't just show a dialog box with input fields and expect
FileMaker to be able to put the data in the right record. You must craft your script carefully
so it goes to the right layout and the right record. This technique is useful for controlling data
input when a new record is created. In that case, input fields appear blank in your custom
dialog box. But if the input fields you specify already have data in them, the data appears in
Search WWH ::




Custom Search