BASIC Script - Execute

Declaration

<AMSCRIPT SCRIPT="text" />
OR
<AMSCRIPT FILENAME="text" />

Related Topics   

Description

Runs an embedded or external BASIC script or creates a user defined function which may be called in subsequent expressions or BASIC scripts. This activity includes a BASIC Script IDE which is an Interactive Design Environment used for developing, examining, testing and executing BASIC scripts. To access the BASIC Script IDE, click the Edit Script button located in the BASIC Script activity's General properties.

Practical usage

Automate Desktop's built-in AML language is easy to use, very robust and includes drag-and-drop functionality. However, there may be occasions when it is necessary to use BASIC scripting to access advanced objects or increase execution time. This activity is ideal for such occasions. BASIC scripting can also be used for advanced flow, COM objects, API calls and the creation of custom dialogs.

IMPORTANT: When setting the value of an Automate Desktop variable created outside a BASIC script, do not include the SET command.

Parameters

General

Property Type Required Default Markup Description
Embedded Text No (Empty) SCRIPT="Function setTime()theTime=Now()End Function" If enabled, specifies that the script is embedded in the task (enabled by default). Enter the script in the provided text-box or click the Edit Script button to access the BASIC Script IDE, an Interactive Design Environment used for developing, examining and testing BASIC scripts. If this parameter is enabled, the External parameter becomes inactive.
External Text No (Empty) FILENAME="C:\temp\scriptFile.bas" If enabled, specifies that the script is located in an external (.bas) file (disabled by default).Click the Folder icon to navigate to the desired external .BAS file or manually enter the full path and file name of the .BAS file in the provided text-box.  If this parameter is enabled, the Embedded parameter becomes inactive.

Description

Error Causes

On Error

Examples

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Example 1

This task executes a BASIC script to modify the contents of a variable.

Copy
<AMVARIABLE NAME="StringValue" VALUE="original text" />
<AMSHOWDIALOG WINDOWTITLE="Variable's value">Variable's current value:%StringValue%</AMSHOWDIALOG>
<AMSCRIPT>Sub Main StringValue="NEW AND IMPROVED TEXT"End Sub</AMSCRIPT>
<AMSHOWDIALOG WINDOWTITLE="Variable's value">Variable's new value:%StringValue%</AMSHOWDIALOG>

Example 2

A streamlined example of how to define your own function in a Basic script and call it from another step. The Basic function in this task does nothing more than set a variable to the current date/time.  

Copy
<AMVARIABLE NAME="theTime" VALUE="[unset]"></AMVARIABLE>
<!-- Function Declaration -->
<AMSCRIPT>Function setTime ()theTime = Now()End Function</AMSCRIPT>
<AMSHOWDIALOG>Before using function:%theTime%After using function:%setTime()%%theTime%</AMSHOWDIALOG>