BASIC Script - Execute

Declaration

<AMSCRIPT>text</AMSCRIPT>

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

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 dialog boxes.

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 filename of the .BAS file in the provided text-box.  If this parameter is enabled, the Embedded parameter becomes inactive.

Examples

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

Sample 1 - Run script file C:\Logs\Macro.bas.  

<AMSCRIPT FILENAME="C:\Logs\Macro.bas"></AMSCRIPT>

Sample 2 - Run embedded script.  

<AMSCRIPT>Sub Main MsgBox(&quot;Hi&quot;)End Sub </AMSCRIPT>

Sample 3 - 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.  

<AMVARIABLE NAME="theTime">[unset]</AMVARIABLE>

<!-- Function Declaration -->

<AMSCRIPT>Function setTime ()

theTime = Now()

End Function

</AMSCRIPT>

<AMMESSAGEBOX>Before using function:

%theTime%

After using function:

%setTime()%

%theTime%</AMMESSAGEBOX>