• Who: Beginner
  • What: How to Use a Script Like a Complex Variable
  • With: All Versions
  • Why: It can be helpful to use the power of a script to obtain a resulting value

When I’m creating a script and I need to set up a complex variable with all kinds of “internal variables”, the “Let” function is usually all I need.  But every once in a while, you run into a scenario where a full on script would work better than a “Let” function.

As a beginning FileMaker developer, I used to use a Perform Script step within a “parent” script and just save the final result of the “child” script into a global variable.  Then I would use that global variable back in the “parent” script.  It worked fine, but I had to remember to manually set a step to clear that global variable when I didn’t need it anymore or it would persist for the rest of my session using FileMaker.

It turns out that you can simply use the Exit Script step in the “child” script along with Get (ScriptResult) in the parent script to assign and get your result without having to manage your global variable lifespan.  Here’s a simple (and maybe silly) example:

Parent Script:

Child Script: