Reference > Script steps reference > Control script steps > Exit Script
 

Exit Script

Forces the running script, sub-script, or external script to stop immediately.

See also 

Options 

Text Result specifies a text value to pass back to the parent script. The value is typically based on the state of the current script.

Compatibility 

 

Product 

Supported 

FileMaker Pro Advanced 

Yes 

FileMaker Go 

Yes 

FileMaker WebDirect 

Yes 

FileMaker Server 

Yes 

FileMaker Cloud products 

Yes 

FileMaker Data API 

Yes 

Custom Web Publishing 

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.

In scripts run by certain script triggers, you can use this script step to return True or False to determine whether the triggering event is processed. See Script triggers reference.

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 [Text Result: ]
End If
Print [With dialog: Off]

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 [Style: Document; Name: "Invoice List"; Using layout: "Print Invoices" (Invoices)]
Perform Find [Restore]
#Calls the "Print" sub-script defined below
Perform Script [Specified: From list; "Print" ; Parameter: ]
#Continues after the sub-script is completed
If [Get ( ScriptResult ) = 1]
Replace Field Contents [With dialog: Off; Invoices::Status; "Printed on " & Get ( CurrentDate )]
Else
Show All Records
Sort Records [Restore; With dialog: Off]
End If

Sub-script: Print

Show Custom Dialog ["Print Unpaid Invoices"; "Do you want to print unpaid invoices?"]
If [Get ( LastMessageChoice ) = 1]
Print [With dialog: Off]
Else
Close Window [Current Window]
End If
#Uses the Result parameter to pass the user's choice to the main script
Exit Script [Text Result: Get ( LastMessageChoice )]

Related topics 

Get(ScriptResult) function

Halt Script script step

Script steps reference (alphabetical list)

Script steps reference (category list)

About formulas