Exit Script
 
Purpose 
Forces the running script, sub-script, or external script to stop immediately.
See also 
Format 
Exit Script [Result: <value or formula>]
Options 
<value or formula> specifies a value to pass back to the parent script. The value is typically based on the state of the current script.
Compatibility 
 
Where the script step runs 
Supported 
FileMaker Pro 
Yes 
FileMaker Server scheduled script 
Yes 
FileMaker Go 
Yes 
Custom Web Publishing 
Yes 
FileMaker WebDirect 
Yes 
Runtime solution 
Yes 
Originated in 
FileMaker Pro 6.0 or earlier
Description 
If Exit Script is used in a sub-script, returns to the main script with or without an optional script result. If the optional script result is specified, the script result is returned and stored in the main script until another sub-script that returns a value is called. The script result gets deleted when you exit the main script. The script result can be stored in a local or global variable for later use.
Example 1 
Performs a find and prints. If no records are found, displays all records and exits the script.
Perform Find [Restore]
If [Get ( FoundCount ) = 0]
Show All Records
Exit Script [ ]
End If
Print [No dialog]
Example 2 
Prints unpaid invoices. In the Print sub-script, users can choose whether they want to print invoices. If users choose to print, then Exit Script uses a script result to enter “Printed on <current date>” in the Status field.
Main script: Print Unpaid Invoices
New Window [Name: "Invoice List"; Style: Document]
Go to Layout ["Print Invoices"]
Perform Find [Restore]
#Calls the "Print" sub-script defined below
Perform Script ["Print"]
#Continues after the sub-script is completed
If [Get ( ScriptResult ) = 1]
Replace Field Contents [No dialog; Invoices::Status; "Printed on " & Get ( CurrentDate )]
Else
Show All Records
Sort Records [Restore; No dialog]
End If
Sub-script: Print
Show Custom Dialog ["Print Unpaid Invoices"; "Do you want to print unpaid invoices?"]
If [Get ( LastMessageChoice ) = 1]
Print [No dialog]
Else
Close Window [Current Window]
End If
#Uses the Result parameter to pass the user’s choice to the main script
Exit Script [Result: Get ( LastMessageChoice )]
Related topics 
Get(ScriptResult) function
Halt Script script step
Script steps reference (alphabetical list)
Script steps reference (category list)
About formulas