AWE provides a library of additional functions that extend the functionality of the AWE Scripting Engine beyond the capabilities that the basic VBA-compatible engine provides. These functions, collectively referred to as Extended Functions, provide operations in several areas to provide more functionality and make formulating AWE scripts even easier. These functions provide a more straightforward approach to file-related operations, date/time manipulation, and viewing or modifying attributes of a running task. The extended functions can be used from within any AWE Action just like the normal VBA-compatible functions.
AWE extended functions can be extremely useful because they provide added functionality to a given task. The extended functions are capable of returning multiple attributes regarding the task currently being executed, such as returning the path and filename of the presently running task, returning the amount of time the task or particular step within the task took to execute in minutes, seconds or milliseconds or returning the last error generated by a task step. They can supply system information, such as returning the computer name that AWE is running on, returning the IP address of the specified host name or local machine or returning the amount of space remaining on a specific drive. The extended functions can perform extensive date/time and file related procedures as well, such as returning the first or last day of the specified month, quarter or year, returning the number of files found in the specified folder or extracting the file name or the path within a particular string.
The general format of a function is its name followed by any arguments contained between parenthesis. For example:
FunctionName (arguments)
Similar to the regular VBA-compatible functions, some extended functions may or may not require other parameters to properly complete a procedure or routine. A function without arguments must include an empty set of parentheses ().
For more details regarding the use of functions, see Using Functions.
A full library of pre-defined AWE extended functions can be found in the lower left pane of the Expression Builder under the Extended Functions folder. Help regarding each extended function can be accessed by first clicking the Extended Functions folder, then clicking the desired extended function from the lower right pane and pressing the F1 key, or right-clicking the extended function and clicking Help.
Extended Function Name |
Description |
ArrayAvg |
Syntax: ArrayAvg(array) Description: Calculates the average of the values in an array. Return Value: Number. If the array parameter value is an empty array, returns zero. |
ArrayMax
|
Syntax: ArrayMax(array) Description: Array maximum function. Returns the largest numeric value in an array. If the array parameter value is an empty array, returns zero. Parameters: Array—Name of an array |
ArrayMin
|
Syntax: ArrayMin(array) Description: Array minimum function. The smallest numeric value in an array. If the array parameter value is an empty array, returns zero. Parameters: Array—Name of an array |
ArraySum
|
Syntax: ArraySum(array) Description: Array sum function. Returns the sum of values in an array. If the array parameter value is an empty array, returns zero. Parameters: Array—Name of an array Example: Dim arr As Integer() = {3, 7, 8, 2, 0, 9} MessageBox.Show(ArraySum(arr)) |
ArrayToList |
Syntax: ArrayToList(array [, delimiter ]) Description: Converts a one-dimensional array to a list. Returns delimited list, as a string. Parameters: Array—Name of an array Delimiter—Character or multicharacter string to separate list elements. The default value is comma. |
CreateGUID
|
Syntax: ArraySum(array) Description: Array sum function. Returns the sum of values in an array. If the array parameter value is an empty array, returns zero. Parameters: array—Name of an array Example: Dim arr As Integer() = {3, 7, 8, 2, 0, 9} MessageBox.Show(ArraySum(arr)) |
CreateODBCDate
|
Syntax: CreateODBCDate(dateexpr) Description: In order to use dates in a SQL language query, the date must be formatted properly. CreateODBCDate converts a BASIC date type to a string of text that is valid for use in a SQL Query through ODBC or OLEDB. Parameters: dateexpr—A valid data type or variant that can be converted to a date. Example: Sub Main |
CreateODBCDateTime
|
Syntax: CreateODBCDateTime(dateexpr) Description: In order to use dates in a SQL language query, the date must be formatted properly. CreateODBCDateTime converts a BASIC datetime type to a string of text that is valid for use in a SQL Query through ODBC or OLEDB. Parameters: dateexpr—A valid data + time type or variant that can be converted to a date + time value Example: Sub Main |
CreateODBCTime
|
Syntax: CreateODBCTime(dateexpr) Description: In order to use dates in a SQL language query, the date must be formatted properly. CreateODBCTime converts a BASIC time type to a string of text that is valid for use in a SQL Query through ODBC or OLEDB. Parameters: dateexpr—A valid time type or variant that can be converted to a time value. Example: Sub Main |
DaysInMonth
|
Syntax: DaysInMonth(dateexpr) Description: Returns the number of days in the month of the date specified. Parameters: dateexpr—A valid time type or variant that can be converted to a date value. Example: Sub Main 'display the number of days in next month 'display the number of days in month of a custom date |
DaysInYear |
Syntax: DaysInYear(dateexpr) Description: Returns the number of days in the year of the date specified. Parameters: dateexpr—A valid time type or variant that can be converted to a date value. Example: Sub Main 'display the number of days in next year 'display the number of days in a year of a custom date |
DriveAvailableSpace |
Syntax: DriveAvailableSpace(Str) Description: Returns, in megabytes (MB), the amount of space remaining on the specified drive letter. Parameters: Str—A text string containing the drive letter to be checked for available space. Example: Sub Main MsgBox DriveAvailableSpace("c:") End Sub |
DriveExists |
Syntax: DriveExists(Str) Description: Returns true if the specified drive letter exists and false if it does not. Parameters: Str—A text string containing the drive letter to check for existence. Example: Sub Main End Sub |
ExtractFileName |
Syntax: ExtractFileName(Str) Description: Extracts the name and extension parts of a file name. The resulting string is the rightmost characters of FileName, starting with the first character after the colon or backslash that separates the path information from the name and extension. The resulting string is equal to FileName if FileName contains no drive and folder parts. Parameters: Str—A text string containing the full path from which the filename should be extracted. Example: Sub Main End Sub |
ExtractFilePath |
Syntax: ExtractFilePath(Str) Description: Returns the drive and folder portions of a file name. The resulting string is the leftmost characters of FileName, up to and including the colon or backslash that separates the path information from the name and extension. The resulting string is empty if FileName contains no drive and folder parts. Parameters: Str—A text string containing the full path from which the path should be extracted. Example: Sub Main MsgBox ExtractFilePath("c:\foldername\filename.txt") End Sub |
FileCount |
Syntax: FileCount(Str) Description: Returns the number of files found in the specified folder. Parameters: Str—A text string containing the folder that should be scanned for number of files. Example: Sub Main End Sub |
FileExists |
Syntax: FileExists(Str) Description: Returns true if the specified file exists and false if it does not. Parameters: Str—A text string containing the path and filename of the file to check for existence. Example: Sub Main End Sub |
FirstDateOfDayInMonth |
Syntax: FirstDateOfDayInMonth(dateexpr, NumZ{day}) Description: Returns the date of the first instance of the specified day in the month of the date specified. For example, this function could return the date of the first Monday of next month. Parameters: dateexpr—The date to be used when determining the first instance of the day. NumZ{day}—Value—Description
Example: Sub Main 'return the date of the first Monday of next month. End Sub |
FirstDateOfDayInQuarter |
Syntax: FirstDateOfDayInQuarter(dateexpr, NumZ{day}) Description: Returns the date of the first instance of the specified day in the quarter of the date specified. For example, this function could return the date of the first Monday of the next quarter. Parameters: dateexpr—The date to be used when determining the first instance of the day. NumZ{day}—Value—Description
Example: Sub Main 'return the date of the first Monday of next quarter. End Sub |
FirstDateOfDayInYear |
Syntax: FirstDateOfDayInYear(dateexpr, NumZ{day}) Description: Returns the date of the first instance of the specified day in the year of the date specified. For example, this function could return the date of the first Monday of next year. Parameters: dateexpr—The date to be used when determining the first instance of the day. NumZ{day}—Value—Description
Example: Sub Main 'return the date of the first Monday of next year. End Sub |
FolderCount |
Syntax: FolderCount(Str) Description: Returns the number of subfolders found in the specified folder. Parameters: Str—A text string containing the folder that should be scanned for number of sub-folders. Example: Sub Main End Sub |
FolderExists |
Syntax: FolderExists(Str) Description: Returns true if the specified folder exists and false if it does not. Parameters: Str—A text string containing the path of the folder to check for existence. Example: Sub Main End Sub |
GetAutoMateDirectory |
Syntax: GetAutoMateDirectory() Description: Returns folder of the current installation. Parameters: (No parameters needed) Example: Sub Main End Sub |
GetAutoMateLogfile |
Syntax: GetAutoMateLogfile() Description: Returns the path and name of the AWE text log file. Events are logged to this text file when the logging preferences are set to "Text file" or "Both" in the AWE Configuration Manager logging options. Parameters: (No parameters needed) Example: Sub Main End Sub |
GetAutoMateVersion
|
Syntax: GetAutoMateVersion() Description: Returns the version of the current installation. Parameters: (No parameters needed) Example: Sub Main |
GetComputerName
|
Syntax: GetComputerName() Description: Returns the name of the computer that AWE is running on. Example: Sub Main End Sub |
GetCurrentLineNumber
|
Syntax: GetCurrentLineNumber() Description: Returns the step number of the currently running task. The step number returned is in the context of the Task not the BASIC script (if any). Parameters: (No parameters needed) Example: Sub Main |
GetCurrentTagText |
Syntax: GetCurrentTagText() Description: Returns the AML tag currently being executed. Parameter: (no parameters) Example: Sub Main End Sub |
GetDesktopDirectory |
Syntax: GetDesktopDirectory() Description: Returns folder of the Windows Desktop. Parameter: (No parameters needed) Example: Sub Main End Sub |
GetEnvironmentVariable
|
Syntax: GetEnvironmentVariable(Str) Description: GetEnvironmentVariable returns the value of the EnvVar environment variable. If the specified variable does not exist or EnvVar is empty, an empty string is returned. This function can retrieve either a system environment variable or a user environment variable. Example: Dim variable As String Dim returnValue As String returnValue = Environment.GetEnvironmentVariable(variablename) |
GetErrorText
|
Syntax: GetErrorText(ErrorNumber) Description: Returns the error message corresponding to the specified error ID or number. |
GetFileAttr
|
Syntax: GetFileAttr(Str) Description: Returns a string representing the attributes of the specified file. Although the standard BASIC language contains the GetAttr function to retreive file attributes, this function is superior because the attributes are returned in a format that is human readable and may be used directly in any AML action parameter that supports attribute filters. Examples of such actions include Copy File and Delete File. Parameters: Str—A text string containing the full path and filename from which the attributes should be extracted. The return value string is comprised of any combination of the following attribute indicators: Attribute—Indicators
Example: Sub Main End Sub |
GetFocusedWindowHandle
|
Syntax: GetFocusedWindowHandle() Description: Returns the "handle" of the currently focused Window. A "handle" is a unique number assigned by the operating system to every window on the system. The return value may be used in either the GetWindowCaption extEnded function or in any of the actions that have a" handle" parameter to identify a window. Parameter: (No parameters needed) Example: Sub Main End Sub |
GetFontDirectory
|
Syntax: GetFontDirectory() Description: Returns the folder path of the Windows "fonts" folder. Parameter: (no parameters) Example: Sub Main End Sub |
GetIPAddress
|
Syntax: GetIPAddress (hostname) Description: Returns the IP address of the machine specified by hostname. Use an empty string to return the IP address of the local machine. Parameters: Hostname (optional)—The hostname of the machine for which to return the IP address. If this parameter is an empty string, the IP address of the current machine is returned. Example: Sub Main End Sub |
GetLastError |
Syntax: GetLastError() Description: Returns the last error generated by a task step in the AML language. The error is returned as a number that uniquely identifies the error. This is very important function as it allows conditional execution based on the error generated by a step. If the last step did not generate an error GetLastError returns 0. NOTE: This function returns errors for AML only - it does not work with BASIC functions or methods. Parameters: (No parameters needed) Example: Sub Main End Sub |
GetLastErrorText |
Syntax: GetLastErrorText() Description: Returns a text string describing the last error encountered by the task (the error string corresponds to the error code returned by GetLastError) Parameter: (No parameters) Example: Sub Main End Sub |
GetLastStepExecutionTimeMin
|
Syntax: GetLastStepExecutionTimeMin() Description: Returns the amount of time the last step took to execute in minutes. If the step took less than one minute the function returns 0 Parameters: (no parameters needed) Example: Sub Main End Sub |
GetLastStepExecutionTimeMS
|
Syntax: GetLastStepExecutionTimeMS() Description: Returns the amount of time the last step took to execute in milliseconds. Parameters: (no parameters) Example: Sub Main End Sub |
GetLastStepExecutionTimeSec |
Syntax: GetLastStepExecutionTimeSec() Description: Returns the amount of time the last step took to execute in seconds. If the step took less than one second the function returns 0 Parameters: (no parameters) Example: Sub Main End Sub |
GetMousePosX |
Syntax: GetMousePosX() Description: Returns the x coordinate of the current mouse position. The very left of the screen is 0. Parameters: (No parameters needed) Example: Sub Main End Sub |
GetMousePosY |
Syntax: GetMousePosY() Description: Returns the y coordinate of the current mouse position. The very top of the screen is 0. Parameters: (No parameters needed) Example: Sub Main End Sub |
GetParentTaskName |
Syntax: GetParentTaskName() Description: Returns the name of the task that launched the current task. The function returns a blank string if the task was not started by another task. Parameters: (no parameters) Example: Sub Main End Sub |
GetProgramsDirectory |
Syntax: GetProgramsDirectory() Description: Returns the folder path of the Windows "Program Files" folder. Parameters: (No parameters needed) Example: Sub Main End Sub |
GetStartupDirectory |
Syntax: GetStartupDirectory() Description: Returns the folder path of the Windows "Startup" folder. The startup folder is a special folder in Windows. Any program files located in this folder are automatically started when the user logs on. Parameters: (No parameters needed) Example: Sub Main End Sub |
GetSystemDirectory |
Syntax: GetSystemDirectory() Description: Returns the folder path of the Windows "System" folder. Parameters: (No parameters) Example: Sub Main |
GetTaskExecutionTimeMin |
Syntax: GetTaskExecutionTimeMin() Description: Returns the amount of time the task took to execute in minutes. If the task took less than one minute the function returns 0 Parameter: (no parameters) Example: Sub Main End Sub |
GetTaskExecutionTimeMS |
Syntax: GetTaskExecutionTimeMS() Description: Returns the amount of time the task took to execute in milliseconds. Parameter: (No parameters) Example: Sub Main End Sub |
GetTaskExecutionTimeSec |
Syntax: GetTaskExecutionTimeSec() Description: Returns the amount of time the task took to execute in seconds. If the task took less than one second the function returns 0 Parameter: (No parameters) Example: Sub Main End Sub |
GetTaskName |
Syntax: GetTaskName() Description: Returns the path and filename of the currently running task. Parameter: (no parameters) Example: Sub Main |
GetTasksDirectory |
Syntax: GetTasksDirectory() Description: Returns the folder path of the default location for new AWE task files. Parameters: (No parameters) Example: Sub Main End Sub |
GetUsername |
Syntax: GetUsername() Description: Returns the user name of the currently logged on Windows user. Parameter: (No parameters) Example: Sub Main |
GetVar |
Syntax: GetVar (iIndex) Description: Returns the name of the variable at enumerated variable list index iIndex. (Note: this function returns valid results only from within a running task). Parameters: index—The index number of the variable name to return from the list of enumerated variable names. Example: Sub Main |
GetVarCount |
Syntax: GetVarCount() Description: Returns the total number of variables created by the current task. (Note: this function returns valid results only from within a running task). Parameters: (No parameters needed) Example: Sub Main End Sub |
GetVarValueByVarName |
Syntax: GetVarValueByVarName (strVarName) Description: Returns the contents of the variable whose name is strVarName. strVarName is a string of the Autoate variable name, and not the variable name itself. (Note: this function returns valid results only from within a running task) Parameters: strVarName—String of the name of the variable whose contents are to be returned. Example: Sub Main Sub Main |
GetWindowCaption |
Syntax: GetWindowCaption(Num) Description: Returns the caption from the Window title bar) of the Window with the handle specified. To obtain the handle of the current top level window use the GetFocusedWindowHandle function. The Run action can also return a Window handle. Parameters: (No parameters) Example: Sub Main End Sub |
GetWindowsDirectory |
Syntax: GetWindowsDirectory() Description: Returns the folder path of the Windows folder. Parameter: (no parameters) Example: Sub Main |
GetWindowsVersion |
Syntax: GetWindowsVersion() Description: Returns a string with the version number of Windows. Parameter: (no parameters) Example: Sub Main IsDefined |
IsDefined |
Syntax: IsDefined (Str) Description: Tests a Str expression to determine whether it is the name of a product or platform constant at run time. IsDefined returns TRUE (-1) if Str is the name of a product or platform constant at run time. Otherwise IsDefined returns FALSE (0). Parameters: Str—Name of variable to test for. Notes: The constants can define platforms at different levels and are not mutually exclusive. For example, on WinNT, the platform returned can be WIN32_X86, WINNT, WIN32, or WINDOWS. Product constants are defined by, and are specific to, the host product, for example Notes, 1-2-3, ESB, and so on. Refer to the product's documentation for a list of product-defined constants. |
IsLeapYear
|
Syntax: IsLeapYear(date) Description: Returns true if date is in a leap year, and false otherwise. Parameters: date—A valid date string or date variable. Example: Sub Main |
IsLocked
|
Syntax: IsLocked(Str) Description: Returns a true if the file is locked and/or currently in use by another application, and false otherwise. Parameters: Str—A text string containing the full path and filename to be checked. Example: Sub Main End Sub |
LastDateOfDayInMonth
|
Syntax: LastDateOfDayInMonth(dateexpr, NumZ{day}) Description: Returns the date of the last instance of the specified day in the month of the date specified. For example, this function could return the date of the last Monday of next month. Parameters: dateexpr—The date to be used when determining the last instance of the day in the month. NumZ{day}—The day to check for. NumZ{day}—Value—Description vbSunday—1—Sunday vbMonday—2—Monday vbTuesday—3—Tuesday vbWednesday—4—Wednesday vbThursday—5—Thursday vbFriday—6—Friday vbSaturday—7—Saturday Example: Sub Main 'return the date of the last Friday of next month. End Sub |
LastDateOfDayInQuarter
|
Syntax: LastDateOfDayInQuarter(dateexpr, NumZ{day}) Description: Returns the date of the last instance of the specified day in the quarter of the date specified. For example, this function could return the date of the last Monday of the next quarter. Parameters: dateexpr—The date to be used when determining the last instance of the quarter. NumZ{day}—Value—Description vbSunday—1—Sunday vbMonday—2—Monday vbTuesday—3—Tuesday vbWednesday—4—Wednesday vbThursday—5—Thursday vbFriday—6—Friday vbSaturday—7—Saturday Example: Sub Main 'return the date of the last Friday of next quarter. End Sub |
LastDateOfDayInYear
|
Syntax: LastDateOfDayInYear(dateexpr NumZ{day}) Description: Returns the date of the last instance of the specified day in the year of the date specified. For example, this function could return the date of the last Monday of next year. Parameters: dateexpr—The date to be used when determining the last instance of the day in the year. NumZ{day}—The day to check for. NumZ{day}—Value—Description vbSunday—1—Sunday vbMonday—2—Monday vbTuesday—3—Tuesday vbWednesday—4—Wednesday vbThursday—5—Thursday vbFriday—6—Friday vbSaturday—7—Saturday Example: Sub Main 'return the date of the last Friday of next year. End Sub |
LastDateOfWeek
|
Syntax: LastDateOfWeek(dateexpr, NumZ{day}) Description: Returns the date of the last instance of the specified day in the week of the date specified. Parameters: dateexpr—The date to be used when determining the last instance of the day in the week. NumZ{day}—The day to check for. NumZ{day}—Value—Description vbSunday—1—Sunday vbMonday—2—Monday vbTuesday—3—Tuesday vbWednesday—4—Wednesday vbThursday—5—Thursday vbFriday—6—Friday vbSaturday—7—Saturday Example: Sub Main 'return the date of the last Friday of this week. End Sub |
LastDayOfMonth
|
Syntax: LastDayOfMonth(dateexpr) Description: Returns the last day (i.e. Sunday, Monday, etc.) of the month specified by dateexpr. For example, this function could return the name of last day of the current month. Parameters: dateexpr—The date to be used when determining the last day of the current month. The return integer is one of the following: NumZ{day}—Value—Description vbSunday—1—Sunday vbMonday—2—Monday vbTuesday—3—Tuesday vbWednesday—4—Wednesday vbThursday—5—Thursday vbFriday—6—Friday vbSaturday—7—Saturday Example: Sub Main End Sub |
LastDayOfQuarter
|
Syntax: LastDayOfQuarter(dateexpr) Description: Returns the last day (i.e. Sunday, Monday, etc.) of the quarter specified by dateexpr. For example, this function could return the name of last day of the second quarter of the current year. A quarter occurs every three months starting in January. Parameters: dateexpr—The date to be used when determining the last day of the quarter. The return integer can be one of the following: NumZ{day}—Value—Description vbSunday—1—Sunday vbMonday—2—Monday vbTuesday—3—Tuesday vbWednesday—4—Wednesday vbThursday—5—Thursday vbFriday—6—Friday vbSaturday—7—Saturday Example: Sub Main End Sub |
LastDayOfYear |
Syntax: LastDayOfYear(dateexpr) Description: Returns the last day (i.e. Sunday, Monday, etc.) of the year specified by dateexpr. For instance, this function could return the name of last day of the current year. Parameters: dateexpr—A date which contains the year to be examined. The return integer can be one of the following: Firstday—Value—Description vbSunday—1—Sunday vbMonday—2—Monday vbTuesday—3—Tuesday vbWednesday—4—Wednesday vbThursday—5—Thursday vbFriday—6—Friday vbSaturday—7—Saturday Example: Sub Main |
RndEx |
Syntax: RndEx() Description: Returns a random number between 0 and 1. This function should be used in place of Rnd() as its results are more widely distributed in repeated calls than Rnd(). Parameter: (No parameters) Example: Sub Main End Sub |
RndFloat |
Syntax: RndFloat (Floor as Double, Ceiling As Double) Description: Returns a random floating point number between Floor and Ceiling. Parameters: Floor—The lowest random number possible. This cannot be a negative value. Ceiling—The highest random number possible. This cannot be a negative value and must be greater than Floor. Example: Sub Main End Sub |
RndInt |
Syntax: RndInt (Floor as Integer, Ceiling As Integer) Description: Returns a random number between Floor and Ceiling. Parameters: Floor—The lowest random number possible. This cannot be a negative value. Ceiling—The highest random number possible. This cannot be a negative value and must be greater than Floor. Example: Sub Main End Sub |
TaskId |
Syntax: TaskId() Description: Returns the ID number of the currently running task. Each running AWE task has a unique number assigned to it at runtime to differentiate it from other tasks running with the same name. The TaskID is a read-only property of the running task. Parameters: (no parameters) Example: Sub Main End Sub |