This is a little trick I’ve just learned, and I’d love to know who has been using this trick.
Each If or Else If script step in FileMaker is evaluated to determine whether its true or false. This means that you can define global or local variables in a Let ( ) statement in the very first IF statement, and those variables will be available for the rest of the script, or in the case of a global variable, until FileMaker is closed, or until the variable is given another value.
[Click here to see a movie demonstrating this idea]. Watch the data viewer to see when the variable gets defined:
- The variable starts out defined from the previous test
- It gets cleared by the first script step
- It gets set by the falsely evaluating first If script step
- It skips the result of the first If statement, now with the variable $$Test defined as “Hey!”
- The value of the variable validates the Else-If step, and fires the “True!” dialog.
This could really help reduce your code load, and the places you have to edit that code later.