Task Functions

Overview

AutoMate has a new way of organizing and structuring tasks with the use of task functions. In programming, functions allow the structuring of programs in segments of code to enable performance of individual tasks. A function normally performs a calculation and returns a value. The same holds true for task functions in AutoMate. Each task function performs an operation and optionally returns a value.

Task functions, variables and events are created and managed through a drop-down UI display that is accessible from the Steps panel of Task Builder (as shown below).

NOTE: Task Functions are additional features aimed for advanced users. You can build tasks without the use of Task Functions and may choose to use these features at your own pace.

Scope & Accessibility

The power of task functions comes from their ability to provide variable modularity and protection and their capability to arrange a collection of task steps into a logical structure. This is accomplished through two distinct yet complimentary standards; scope and accessibility. Scope and accessibility are primary building blocks used to construct a solid foundation and to enable a rich object-oriented approach to tasks. They provide distinct capabilities and serve different but complimentary roles necessary to distinguish the benefits of task functions.

Scope

A scope in any programming is a region of the program where a defined variable can have its existence and beyond that variable can not be accessed. In AutoMate, scope limits a task function's visibility within a task. Without proper scoping, some of the primary advantages of function-oriented design would not be possible, including information-protection, modularity, maintainability and recursion. Scoping helps take large, unruly tasks and enforce logical restrictions to their structure to provide greater readability and maintainability. Scoping also helps avoid unintentional and confusing data changes leading to easier debugging as well as construction of cleaner and more reliable tasks.

Accessibility

Accessibility provides the fundamentals of information-protection, encapsulation and interfacing, all of which are essential for an object-oriented approach to a language. 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. Task functions exist at the root of a task structure, thus, their scope is to the entire task. However, their accessibility, which defines whether or not the function is accessible and visible to an external task, can be defined in the following manners:

The ability to set task functions as public or private give developers greater control over how a task is used by another task.

Sub-Tasks

Sub-tasks are task files that are executed within another task by using the Start sub-task activity. In this situation, the parent task’s (i.e. the task executing the Start sub-task step) basic functions, extended functions, public task functions, public task variables, and any local variables (not marked as private), created up to point where the Start sub-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 sub-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 & Defining Task functions

Calling Task functions