If Action Icon

If Last Step

Declaration

<AMIF LASTSTEP="text(options)" RESULTCODE="number">

See Also

Else | End If | End Select/Case | Goto | If | If Compare Files | If File Exists | If Folder Exists | If Last Step | If Pixel Exists | If Process Running | If Text Contains | If Windows Exists | Label | Select/Case

Description

Controls task flow depending on whether the last step was a success, general failure, or failed because of a specific error. Causes the steps following this action to execute if the previous step meets the specified condition. If not, execution follows the next Else or End If action, whichever comes first.

Practical Usage

Mainly used to provide custom error handling on steps that are set to ”continue on error”. This action introduces conditional steps depending on the outcome of the previous step. It is commonly used to introduce a block of steps to be carried out if the previous step fails.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

If last step

Text (Options)

Yes

Succeeded

LASTSTEP="failed"

Specifies the condition to be met. The available options are:

  • Succeeded (default): the IF block will be executed if the last step succeeded

  • Failed: the IF block will be executed if the last step failed in general (with or without any error message generated).

  • Failed with specific error code(s): the IF block will be executed if the last step failed with one of the error codes specified in the Error codes parameter.

Error Codes

Text

Yes if last step failed with specific error code was selected

(Empty)

RESULTCODE="24007,30098"

Specifies the error codes to match. Multiple error codes can be entered by delimiting each with a comma (i.e. 24007, 30098, 20074). This parameter is available only if the option selected in the If last step parameter is Failed with specific error code(s).

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties lets you instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Description: Determines if last step returned one of these error codes: 20074, 20089. If so, a message box displays a message stating "Last step failed with one of the error codes specified." If not, a message box will display "Last step did not fail."

 

<AMIF LASTSTEP="failedwithcode" RESULTCODE="20074, 20089">

     <AMSHOWDIALOG MESSAGE="Last step failed with one of the error codes specified." />

<AMELSE />

     <AMSHOWDIALOG MESSAGE="Last step did not fail." />

</AMIF>

 

↑ Top of Page