Task Functions

Overview


AutoMate has a new way of organizing and structuring tasks with the use of functions. In programming, a function normally performs a calculation and returns a value. For example, the SUM function adds the sum of a range of values. The same holds true for functions in AutoMate. Each function does its thing and returns a value. The power of functions comes from their ability to provide logical structure to an otherwise disorganized collection of task steps or statements and supply variable protection and modularity. This is accomplished through two distinct yet complimentary standards; Scoping and Accessibility.

NOTE: Users can continue to build tasks as they did before and may choose to use these new features at their own pace.

Scoping & Accessibility


Scoping and Accessibility provide two different capabilities to AutoMate and serve two different but complimentary roles necessary to realize the full benefits of task functions and task variables. They are primary building blocks that can be used to build a solid foundation for a rich object-oriented approach to tasks.

Scoping limits a task variable’s visibility within a task (i.e. using a variable from “the inside”). Without proper scoping, it would not be possible to provide some of the best advantages to function-oriented design, including information-protection, modularity, maintainability and recursion. helps take large, unruly tasks and enforce logical restrictions to their structure to provide greater readability and maintainability. They can help optimize and enhance task execution speed by reducing the amount of variables that are present in the system at a given time. Scoping also helps avoid unintentional and confusing data changes and variables accesses, leading to easier debugging, and cleaner and more reliable tasks.

Similarly, accessibility provides the fundamentals of information-protection, encapsulation and interfacing, all of which are essential for an object-oriented approach to a language. The ability to set task variables and functions as public or private gives a task developer greater control over how a task is used by another task. It makes tasks more portable, manageable and documentable by providing outside access only to those parts of the task that are meant to be used, while providing the user full flexibility of functions.

AutoMate supports two levels of accessibility:

Public - The variable or function is visible and accessible to external tasks.

Private - The variable or function is not visible or accessible to external tasks.

Sub-Tasks

Sub-tasks are task files that are executed within another task by using the Start Task action.  In this situation, the parent task’s (i.e. the task executing the Start Task step)  public functions, public extended functions, public task variables, and any local variables marked as public created up to point where the Start Task step is encountered, are accessible to the sub-task.  All other variables and functions are not accessible to the sub-task.  Conversely, because the Start Task action is a synchronous operation, the sub-task’s public functions and public task variables are not accessible from the parent task.  This is fully backward compatible with previous versions of AutoMate, since in the past there was only one “function” (what is now called “main”), no task variables, and all (local) variables and extended functions were considered public.

Creating & Managing Task Functions


Task functions exist at the root of a task structure, and thus their scoping is to the entire task. Their accessibility, however, can be either public or private (accessibility defines whether or not the function is accessible and visible to an external task). This is done by setting the ACCESS attribute of the AMFUNCTION element to either public or private. By default task functions have public accessibility.

To create a new Task Function:

  1. From the Task Builder's Steps pane, click the Make new Function button. This expands the panel and where specific parameters can be set.

  2. Enter the name, access type and return type of the function. By default a newly created function is named NewFunction.

  3. Click the Click to add new line button to add a new line of parameters for the function. Multiple parameters can be added for a single function.

  4. Click the Expand/Collapse button after completion.

To edit an existing Task Function:

  1. From the Task Builder's Steps pane, click the drop-down button that displays existing functions.

  2. Select the function you wish to edit.

  3. Make the desired modifications.

  4. Click the Expand/Collapse button after completion.

To delete an existing Task Function:

  1. From the Task Builder's Steps pane, click the drop-down button that displays existing functions.

  2. Select the function you wish to delete.

  3. Click the Delete Function button.

↑ Top

Parameters


The following table describes the parameters available during task function creation/modification.

Property

Type

Description

Name

Text

The name of the function to create. This parameter defaults to the name NewFunction.

Access Type

Text (options)

The task function's access type. The available options are:

  • Public - The function is visible and accessible to external tasks.

  • Private - The function is not visible or accessible to external tasks.

Return

Text (options)

The return value. The available options are:

  • Nothing

  • Variable

  • Array

  • Dataset

 

The following table describes the parameters available when adding new parameters to a task function.

Property

Type

Description

Name

Text

The name of the parameter to create.

Type

Text (options)

The parameter type. The available options are:

  • Variable

  • Array

  • Dataset

Optional

Yes/No

Whether the variable is optional or required. Set to NO by default.

Default Value

Text

The variable's default value.

See Also

Variables

Task Variables

Datasets

Arrays

Expressions

Create Variable Action

Managed and Unmanaged Tasks

↑ Top