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.
Attachmate Extra! Macro Editor, installed and working.
BlueZone for the Desktop (version 3.2 or higher) with BlueZone Script Host & Debugger, installed and working.
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.
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.
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.
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()
'------------------------------------------------------------
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()
'-------------------------------------------------------------
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
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
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
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 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
GoTo Statements are not supported in VBScript and in most cases, must be converted to subroutines. Some exceptions are:
GoTo End - can be replaced with StopScript
OnError Goto - should be commented out or replaced with On Error Resume Next, which ignores the errors and keeps the script running
All other GoTo’s can be converted to sub routines. The script logic should be evaluated and changed as needed to maintain the same functionality.
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.
Change Begin Dialog to BeginDialog
Remove and %, $, or & in the dialog definition
If there are Drop List Boxes in the dialogs, you must remove the dot at the beginning of each DropListBox reference
If your listbox variant is an integer as opposed to a string, it may be necessary to include the following in your script before the BeginDialog:
DropListBox = 0 'sets the listbox variant to an integer
If there is more than one listbox, you will have to set each on to zero as follows:
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
Change End Dialog to EndDialog
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.
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
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:
Evaluate what the DLL call does and see if it can be eliminated from the script.
Find a COM object that does the same thing. Many Windows API calls have analogous methods or properties in the WScript or Windows Shell Objects.
Create a COM wrapper for the DLL that loads the DLL and translates the COM methods to DLL calls.
There are some differences between how BlueZone Script Host implements the Extra! Object that are important to understand.
Session Object - There is only one Session Object in the BlueZone Host Automation Object. When using the BlueZone Host Automation Object to control multiple BlueZone sessions, the script must explicitly “Connect” to the session prior to reading or writing it. Using the BlueZone Host Automation Object, simply calling .Connect “A” prior to using session A and .Connect “B” when switching to session B is all that is required. When using the Extra! Object, each session must be defined at startup as an Item, then the .Item method used to connect to each session prior to using it.
Area Object - There is only one Area Object used to store data from the screen. In Extra!, multiple Area Objects can be populated simultaneously, then, used any time. In BlueZone the Area Object contains only the last data stored. If the Area Object is to be used more that once in a macro or application, it must be filled, then used, prior to filling it with new data.
Extra! Recorded Macro Conversion