Macro Conversion


Extra! Basic to BlueZone Macro Conversion

BlueZone Script Host and the BlueZone Host Automation Object have Extra! Compatible functions, methods, and properties to make the conversion from Extra! to BlueZone easier.

The BlueZone Script Host & Debugger supports several scripting languages such as Visual Basic Scripting Edition, also known as VBScript, JScript, Perl, Python, Rexx, as well as others.

The syntax rules for these scripting languages affect the level of compatibility with Extra! Basic.  Some syntax changes are necessary when converting from Extra! Basic to one of the supported scripting languages.

This document is a "rough-guide" to techniques involved in the process of converting Extra! Basic macros to BlueZone Visual Basic (VBScript) scripts.  Its purpose is to provide a source reference for those who wish to quickly begin using BlueZone Script Host & Debugger with their existing Extra! Basic macros.

The BlueZone Script Host & Debugger will identify the syntax errors and highlight them as the script is played.

Extra! Basic macros use the Extra! System Object and are coded to run within the Extra! scripting framework.  The BlueZone scripting framework includes Extra!-compatible objects and are coded to run within generic script host environments.  Some examples of script hosts are Internet Explorer (IE), Windows Script Host (WSH), Internet Information Services (IIS) and BlueZone Script Host & Debugger (BZSH).

The BlueZone Host Automation Object provides exact replacement methods and properties for most of the Extra! System Object and inherited objects.

SEE  Extra! Object Interface Compatibility for more information.

Requirements

Extra! Basic Macro Conversion

Save the Extra! Macro to a Text File

Using the Extra! Macro Editor, open the desired existing Extra! macro, then select File:Save As from the main menu.  In the Windows common file dialog, select "Save as type: Text File (*.txt)" and enter a name for the new file to be saved as.

Once the Extra! Basic macro has been saved as a text file, copy this file to the BlueZone \Scripts directory and manually rename the file extension to .vbs.

Open the Visual Basic Script using BlueZone Script Host & Debugger

To load the newly created script file, launch the BlueZone Script Host & Debugger and select File:Open from the MenuBar.  If the script file does not appear in the common file dialog list, then select Options from the MenuBar and make sure that the Script Type selected is Visual Basic.

Syntax Differences

Extra! Basic is similar to the older Microsoft Word Basic in features and syntax.  Below are some common syntax changes that must be made in order to convert an Extra! Basic macro to a VBScript.

Sub-setup Declarations

If you see something that looks like this at the top of the macro:

declare sub setups (file_name, set_to, set_to2)

 

Sub Main()

 

You must comment out this type of declaration with a single quote placed at the beginning of the line as shown here:

'declare sub setups (file_name, set_to, set_to2)

 

Sub Main()

'------------------------------------------------------------

Global Variable Declarations

If you see something that looks like this at the beginning of the macro:

' Global variable declarations

Global g_HostSettleTime%

Global g_szPassword$

 

Sub Main()

'-------------------------------------------------------------

You must comment out this type of declaration with a single quote placed at the beginning of each line as shown here:

' Global variable declarations

'Global g_HostSettleTime%

'Global g_szPassword$

 

Sub Main()

'-------------------------------------------------------------

Variable Handling

In Extra! Basic, you declare a variables along with the type of variable at the same time.  For example:

dim x as integer

dim test as string

dim System as Object

 

In VBScript, you can not declare the type of variable.  You must delete the variable type as shown here:

dim x

dim test

dim System

 

Replace the Extra! System Object with the BlueZone System Object

 

Here is an example of the Extra! System Object in a Extra! Basic macro:

 

sub setups (file_name as string, set_to as integer, set_to2 as integer)

 

Dim Sessions As Object

Dim System As Object

Set System = CreateObject("EXTRA.System") ' Gets the system object

If (System is Nothing) Then

Msgbox "Could not create the EXTRA System object.  Stopping macro playback."

STOP

End If

Set Sessions = System.Sessions

 

If (Sessions is Nothing) Then

Msgbox "Could not create the Sessions collection object.  Stopping macro playback."

STOP

End If

 

Here is the modified code with all the occurrences of "as string", "as integer" and "As Object" removed:

sub setups (file_name, set_to, set_to2)

 

Dim Sessions

Dim System

Set System = CreateObject( "Bzwhll.Whllobj" ) ' Gets the system object

If (System is Nothing) Then

Msgbox "Could not create the BlueZone System object.  Stopping macro playback."

STOP

End If

Set Sessions = System.Sessions

 

If (Sessions is Nothing) Then

Msgbox "Could not create the Sessions collection object.  Stopping macro playback."

STOP

End If

Replace WaitHostQuiet with WaitReady

This change is optional but recommended.  While WaitHostQuiet is supported in the BlueZone Screen object, it is recommended to replace this method with the WaitReady function included in the BlueZone System Object.  Although the WaitHostQuiet method in Extra! macros does work, it's not a fool-proof method for determining when the host machine is done transmitting, and may slow script execution unnecessarily.  WaitReady on the other hand, is used to specify the number of host keyboard restores sent between screens (this number is displayed on BlueZone Display's StatusBar as Ready(x) where x is the number of host keyboard restores) and results in blazingly fast errorless scripts.

For example, convert statements like this:

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

 

To this:

System.WaitReady 10, 1

Invalid Characters

Extra! Basic uses the following special characters “$”, “%”, “&”, "!", "#" and "@" as a suffix to variable names which are not supported in VBScript.  Use the Script Host & Debugger search feature to find these characters and delete them.

CAUTION  The "&" character is a valid VBScript character when it is used to perform concatenation of two string values.  So be careful not to delete the any &'s when used in this fashion.

Include Main Execution Statement

Include the Main subroutine name at the bottom of your script to begin script execution at run-time.  The Extra! Basic macro will end like this:

End Sub

 

You must add the Main subroutine name (the comment is of course optional) after the End Sub as shown here:

End Sub

 

Main   'execute sub Main at run-time

Converting GoTo Statements

GoTo Statements are not supported in VBScript and in most cases, must be converted to subroutines.  Some exceptions are:

Converting Extra! Basic Dialogs

BlueZone has a nearly identical dialog structure as Extra!.  The main differences are the beginning and end of the dialog statement.  Also, BlueZone dialogs do not support a callback feature that allows you to change the dialog list box contents based on user input.

DropListBox = 0 'sets the listbox variant to an integer

 

DropListBox1 = 0 'sets the listbox variant to an integer

DropListBox2 = 0 'sets the listbox variant to an integer

DropListBox3 = 0 'sets the listbox variant to an integer

 

Include Statements

Include Statements for header files (extra.ebh) are not supported.  Header files referenced in Extra! macros should be merged into each macro that references them.

Open and Close Statements

If you are using Open and Close Statements to open and close files, Extra! Basic uses slightly different syntax.

If you have an Open statement like this:

Open "C:\myfiles\" & file_name  for input as #1

 

change to the following syntax:

Open "C:\myfiles\" & file_name, "Input", 1

 

If you have a Close statement like this:

Close #1

 

change to the following syntax:

Close 1

Loading DLL’s

Extra! Basic provides a means to load Windows DLLs and call them directly that is not possible with VBScript.  Changes must be made to provide the same or similar functionality.  Possible changes include:

Other Object Differences

There are some differences between how BlueZone Script Host implements the Extra! Object that are important to understand.


Related Topics:

Extra! Recorded Macro Conversion