Home > Designing and creating databases > Creating scripts to automate tasks > Script examples > If structure examples
If structure examples If, Else If, Else, and End If script steps define a structure that controls whether or not script steps are performed. This control depends upon the result of a testable condition or Boolean calculation. • When the calculation result is any number except zero, the condition evaluates to True, and subsequent script steps are performed. • When the calculation result is zero, blank, or content that does not resolve into a number, then the condition evaluates to False and the subsequent script steps are not performed. Else If steps provide additional Boolean tests. Else steps provide alternative steps to perform if all conditions evaluate to False. Example 1 Performs a find. If no records are found, displays a custom dialog. If records are found, sorts the found set. Perform Find [Restore]If [Get ( FoundCount ) = 0] Show Custom Dialog ["Find Records"; "No records were found."]Else Sort Records [Restore; No dialog]End If Example 2 Performs a find. If no records are found, displays a custom dialog. If one record is found, goes to the Invoice Details layout. If more than one record is found, goes to the Invoices layout. Perform Find [Restore]If [Get (FoundCount) = 0] Show Custom Dialog ["Find Records"; "No record was found."]Else If [Get (FoundCount) = 1] Go to Layout ["Invoice Details"]Else Go to Layout ["Invoices"]End If