Contents
Visual Script Editor Contents

This help file contains a list of all Help topics available for the Visual Script Editor application.

Copyright Notice: Cypress Enable - Basic Scripting for Applications, Copyright © 1990 - 1996.  Cypress Software Inc. ® All rights reserved.

You can use the scroll bar to see entries that are not currently visible in the Help window.  For information on how to use Help, press F1 or choose Using Help from the Help menu.

Overview	How to Use	Troubleshooting
Menus

File

Edit

Assist

Run

Settings

Tools

Window

Go IntraNet!

Help


Overview

Visual Script Editor is an editor used to write or modify scripts.  The editor is user-friendly, helps you to learn the script language, and assists you in building the commands.

These script utilities allow you to dynamically reconfigure the user interface, perform random access file operations, automate tasks, modify current functionality, and handle incoming events.  For example, you could write a script to customize an end-user interface that would allow non-technical users to easily access various programs on a variety of hosts.

Note:	One of the easiest and most effective ways to familiarize yourself with Visual Script Editor/Player capabilities is to run the demo scripts provided with this application.  Run one of the script files (such as, demo.vba or demo1.vba) to see how a script works. You can also copy a sample script file and edit it to suit your needs.

Features

The Visual Script Editor and Visual Script Player applications include the following features:

•	These applications can be accessed from within the terminal emulator applications (Telnet,  3270 and 5250 Terminal Emulators).

The Visual Script Editor (VSE) can be used with two Script Types:

Simplified: A subset of  NetManage Visual Basic for Applications commands that provide automated login.  It can be run from Telnet, 3270 and 5250 Terminal Emulation applications using a connection profile or after a connection has been made. For additional information, see Simplified Mode.

•	VBA: Refers to NetManage Visual Basic for Applications.  This Script Type is compatible with the standard Microsoft VBA, and supports Visual Basic™ syntax. It also supports OLE automation and function calls for external DLLs. For information on NetManage VBA Language components and syntax, see How To Use Visual Script Editor.

•	There are two Visual Script Player applications.

•	VSP runs scripts that have been created using the Cham 4.5 or Simplified Script Type.

•	VSPVBA runs scripts that have been created using either the Cham 4.5 or the VBA Script Type.

•	VSE includes online assistance in using the commands, through the Assist menu.  The contents of the Assist menu changes depending on which Script type mode you have currently selected: Simplified, or VBA.

Note:	The Assist Screen contains a Print button that allows you to Print the current Command Description, so that you can have a hard-copy for reference.

For additional information, see How to Use Visual Script Editor.


How to Use
How to Use Visual Script Editor

The VBA Script Type has its own specific language components and syntax. Information on VBA Script Type language components and how to edit them is provided under the following topics:

Arrays in VBA

Comments in VBA

Control Structures in VBA

Dialogs in VBA

Editing a Script

File Input/Output in VBA

Numbers in VBA

OLE Automation in VBA

Script Examples

Statements in VBA

Subroutines and Functions in VBA

Variable and Constant Names in VBA

Variables in VBA

User-Defined Types in VBA

Using Right Mouse Button


Comments in VBA

Comments are non-executed lines of code which are included for the benefit of the programmer.  Comments can be included virtually anywhere in a script.  Any text following an apostrophe or the word “Rem” are ignored by VBA.  “Rem” and all other keywords and most names in VBA are not case sensitive.

'	This whole line is a comment

rem	This whole line is a comment

REM	This whole line is a comment

Rem	This whole line is a comment

Comments can also be included on the same line as executed code:

MsgBox Msg	' Display message.

Everything after the apostrophe is a comment.


Statements in VBA

In VBA there is no statement terminator.  More than one statement can be put on a line if they are separated by a colon.

X.AddPoint( 25, 100) :  X.AddPoint(  0,  75)

Which is equivalent to:

X.AddPoint( 25, 100)

X.AddPoint(  0,  75)


Numbers in VBA

VBA supports three representations of numbers:  Decimal, Octal and Hexadecimal.  Most of the numbers used in this manual are decimal or base 10 numbers.  However, if you need to use Octal (base 8) or hexadecimal (base 16) numbers simply prefix the number with &O or &H respectively.


Variable and Constant Names in VBA

Variable and Constant names must adhere to the following conventions:

•	Can contain the letters A to Z and a to z, the underscore “_” and digits 0 to 9

•	Must begin with a letter

•	Must be no longer than 40 characters

•	Must not be reserved words

One exception to this rule is that object member names and property names may be reserved words.  For a list of reserved words, see the online Assist menu.


Variables in VBA

As is the case with Visual Basic, when a variable is introduced in VBA, it is not necessary to declare it first (see option explicit for an exception to this rule).  When a variable is used but not declared, it is implicitly declared as a variant data type.  Variants can also be declared explicitly using "As Variant" as in Dim x As Variant. The variant data type is capable of storing numbers, strings, dates, and times.  When using a variant you do not have to explicitly convert a variable from one data type to another.  This data type conversion is handled automatically.

Sub Main

Dim x	'variant variable

x = 10

x = x + 8

x = "F" & x

print x       'prints F18

End Sub

A variant variable can readily change its type and its internal representation can be determined by using the function VarType.  VarType returns a value that corresponds to the explicit data types.  See online Assist for additional information on VarType.

When storing numbers in variant variables, the data type used is always the most compact type possible.  For example, if you first assign a small number to the variant it will be stored as an integer.  If you then assign your variant to a number with a fractional component it will then be stored as a double.

For doing numeric operations on a variant variable, it is sometimes necessary to determine if the value stored is a valid numeric, thus avoiding an error.  This can be done with the IsNumeric function.

For more information on Variables, select:

Declaration of Variables in VBA

Scope of Variables in VBA

Variable and Constant Names in VBA

Variants and Concatenation in VBA

Variable Data Types in VBA


Variants and Concatenation in VBA

If a string and a number are concatenated, the result is a string.  To be sure your concatenation works regardless of the data type involved, use the & operator.  The & will not perform arithmetic on your numeric values it will simply concatenate them as if they were strings.

The IsEmpty function can be used to find out if a variant variable has been previously assigned.


Other Data Types in VBA

The six data types available in VBA are shown below:

NetManage VBA Data Types

Variable	Type	Declaration	Size
String	$	Dim Str_Var As String	0 to 65,500 char
Integer	%	Dim Int_Var As Integer	2 bytes
Long	&	Dim Long_Var As Long	4 bytes
Single	!	Dim Sing_Var As Single	4 bytes
Double	#	Dim Dbl_Var As Double	8 bytes
Variant		Dim X As Any
Currency		(Currency datatype is not supported)


Scope of Variables in VBA

VBA scripts can be composed of many files and each file can have many subroutines and functions.  Variable names can be reused even if they are contained in separate files.  Variables can be local or global.


Declaration of Variables in VBA

In VBA variables are declared with the Dim statement.  To declare a variable other than a variant, the variable must be followed by As or appended by a type declaration character such as a % for Integer type.

Sub Main

   Dim X As Integer

   Dim Y As Double

   Dim  Name$, Age%	' multiple declaration on one line Dim v

End Sub


Arrays in VBA

VBA supports single and multi-dimensional arrays.  Using arrays lets you use the same name to refer to a series of variables. Each variable has a separate index within the array.  Arrays have upper and lower bounds which should not be declared larger than necessary.  VBA allocates space for each index number in the array.

VBA supports arrays of  integers, singles, double and strings. All the elements in an array have the same data type.

For more information refer to the following:

Ways to Declare an Array

Multi-Dimensional Arrays


Ways to Declare an Array

VBA does not support Dynamic arrays.

Fixed-size arrays can be global or local..  The array name must be followed by the upper bound enclosed in parentheses.  The upper bound must be an integer.

To declare a Global array use either a Dim or Global statement.

To declare a local array use either a Dim or Static statement.

Examples

1. This example uses the Dim statement

Dim  ArrayName (10) As Integer

Dim Sum (20) As Double

2. This example uses the Global statement

Global Counters (10) As Integer

Global Sums (20) As Double

3. The same declarations within a procedure use Static:

Static Counters (10)  As Integer

Static Sums (20) As Double

In the examples, the ArrayName declaration creates an array with 11 elements, with index numbers running from 0 to 10.  The Sums declaration creates an array with 21 elements. To change the default lower bound to 1 place an Option Base statement in the Declarations section of a module:

Option Base 1

You can also specify the lower bound explicitly (as an integer, in the range -32,768 to 32,767) using the To keyword:

Dim Counters (1 To 13) As Integer

Dim Sums (100 To 126) As String

In these declarations, the index numbers of Counters run from 1 to 13, and the index numbers of Sums run from 100 to 126.

Note:	Many other versions of Basic allow you to use an array without first declaring it. VBA Basic does not allow this; you must declare an array before using it.

Manipulating Arrays

Loops often provide an efficient way to manipulate arrays.  For example, the following For Loop initializes all elements in the array to 5:

Static Counters (1 To 20) As Integer

Dim I As Integer

For I = 1 To 20

Counters ( I ) = 5

Next I


MultiDimensional Arrays
Multi-Dimensional Arrays

VBA supports multi-dimensional arrays.  The following example declares a two-dimensional array within a procedure.

Static Mat(20, 20) As Double

Either or both dimensions can be declared with explicit lower bounds.  For example,

Static Mat(1 to 10, 1 to 10) As Double

For Loops often provide an efficient way to manipulate arrays.  In the following statements the elements in a multi-dimensional array are set to a value.

Dim L As Integer, J As Integer

   Static TestArray(1 To 10, 1 to 10) As Double

   For L = 1 to 10

For J = 1 to 10

TestArray(L,J) = I * 10 + J

Next J

   Next L

Arrays can be more than two dimensional.  VBA does not have an arbitrary upper bound on array dimensions.  For example,

Dim ArrTest(5, 3, 2)

creates a three dimensional array with sizes 6 by 4 by 3,  unless Option Base 1 has been set previously in the code.  Option Base 1 sets the lower bound of all arrays to 1 instead of 0.


Control Structures in VBA

VBA has complete process control functionality.  The control structures available are as follows:

•	Do loops

•	While loops

•	For loops

•	Select Case

•	If Statements

In addition, VBA has two branching statements:

•	GoTo

•	GoSub

The GoTo Statement branches to the specified label.

GoTo label1

.

.

.

label1:

The program execution jumps to the part of the program that begins with the label "Label1:".

GoSub statement returns to its original position in the code after executing a return statement.

GoSub  Label2

.

.

.

Label2:

.

.

.

Return


Do Loops in VBA

The Do...Loop allows you to execute a block of statements an indefinite number of times.  The variations of the Do...Loop are:

•	Do While

•	Do Until

•	Do Loop While

•	Do Loop Until

Do While and Do Until check the condition before entering the loop, thus the block of statements inside the loop are only executed when those conditions are met.

Do While condition

Statement(s)...

Loop

Do Until condition

Statement(s)...

Loop

Do Loop While and Do Loop Until check the condition after having executed the block of statements thereby guaranteeing that the block of statements is executed at least once.

Do

Statements...

Loop While condition

Do

statements...

Loop Until condition


While Loop in VBA

The While...Wend loop is similar to the Do While loop.  The condition is checked before executing the block of statements comprising the loop.

While condition

statements...

Wend


For...Next Loop in VBA

The For...Next loop has a counter variable and repeats a block of statements a set number of times.  The counter variable increases or decreases with each repetition through the loop.  The counter default is one if the Step variation is not used.

For counter = beginning value To ending value [Step increment]

statements...

Next


If Statements in VBA

The If...Then block has a single line and multiple line syntax.  The condition of an If statement can be a comparison or an expression, but it must evaluate to True or False.

If condition Then Statements...	'single line syntax

If condition Then

'multiple line syntax

statements...

End If

The other variation on the If statement is the If...Then...Else statement  This statement should be used when there are different statement blocks to be executed depending on the condition.  There is also the If...Then...ElseIf... variation, which can get quite long and cumbersome; consider using the Select Case statement.

If condition Then

statements...

ElseIf condition Then

statements...

Else

End If


Select Case in VBA

The Select Case statement tests the same variable for many different values.  This statement tends to be easier to read, understand and follow and should be used in place of a complicated If...Then...ElseIf statement.

Select Case variable to test

Case 1

statements...

Case 2

statements...

Case 3

statements...

Case Else

statements...

End Select


Subroutines and Functions in VBA

Subroutine and Function names must adhere to the following conventions:

•	Can contain the letters A to Z and a to z, the underscore “_” and digits 0 to 9

•	Must begin with a letter

•	Must be no longer than 40 characters

•	Must not be reserved words

For a list of reserved words, see the online Assist menu.

VBA allows script developers to create their own functions or subroutines or to make DLL calls.  Subroutines are created with the syntax "Sub <subname> .... End Sub".  Functions are similar "Function <funcname> As <type> ... <funcname> = <value> ... End Function.”  DLL functions are declared via the Declare statement.


File Input/Output in VBA

VBA supports limited file I/O, as shown in the following example:

Sub FileIO_Example()

Dim Msg	' Declare variable.

Call Make3Files()	' Create data files.

Msg = "Several test files have been created on your disk. "

Msg = Msg & "Choose OK to remove the test files."

MsgBox Msg

For I = 1 To 3

        	Kill "TEST" & I ' Remove data files from disk.

        Next I

End Sub

Sub Make3Files ()

Dim I, FNum, FName	' Declare variables.

For I = 1 To 3

FNum = FreeFile	' Determine next file number.

FName = "TEST" & FNum

Open FName For Output As FNum	' Open file.

Print #I, "This is test #" & I	' Write string to file.

Print #I, "Here is another ";  "line";  I

Next I

Close	' Close all files.

End Sub


User-Defined Types in VBA

Users can define their own types that are composites of other built-in or user defined types.  Variables of these new composite types can be declared and then member variables of the new type can be accessed using dot notation.  Variables of user defined types can not be passed to DLL functions expecting ‘C’ structures.

User Defined types are created using the Type statement, which must be placed outside the procedure in your VBA Code.  User defined types are global.  The variables that are declared as user defined types can be either global or local.

Type type1

    a As Integer

    d As Double

    s As String

End Type

Type type2

    a As Integer

    o As type1

End Type

Dim type2a As type2

Dim type1a As type1

Sub TypeExample ()

    a = 5

    type1a.a = 7472

    type1a.d = 23.1415

    type1a.s = "YES"

    type2a.a = 43

    type2a.o.s = "Hello There"

    MsgBox type1a.a

    MsgBox type1a.d

    MsgBox type1a.s

    MsgBox type2a.a

    MsgBox type2a.o.s

    MsgBox a

End Sub


Dialogs in VBA

NetManage VBA has support for custom dialogs.  The syntax may be familiar to users of Microsoft Word Basic. The dialog syntax is not part of Microsoft Visual Basic or Microsoft Visual Basic For Applications (VBA).

NetManage VBA supports the following standard Windows dialog box controls:

OK and Cancel in VBA

List Boxes, Drop-down List Boxes, and Combo boxes in VBA

Check Boxes in VBA

Text Boxes and Text in VBA

Option Button and Group Boxes in VBA


OK and Cancel in VBA

Every custom dialog box must contain at least one “command” button - an OK button or a Cancel button.  VBA includes separate dialog box definition statements for each of these two types of buttons.

Sub Main

Begin Dialog ButtonSample 16,32,180,96,"OK and Cancel"

OKButton 132,8,40,14

CancelButton 132,28,40,14

End Dialog

Dim Dlg1 As ButtonSample

Button = Dialog (Dlg1)

End Sub


List Boxes, Drop-down List Boxes, and Combo Boxes in VBA

You can use a list box, drop-down list box, or combo box to present a list of items from which the user can select.  A drop-down list box saves space (it can drop down to cover other dialog box controls temporarily).  A combo box allows the user to select either an item from the list or type in a new item.  The items displayed in a list box, drop-down list box, or combo box are stored in an array that is defined before the instructions that define the dialog box.

Sub Main

Dim MyList$ (5)

MyList (0) = "line Item 1"

MyList (1) = "line Item 2"

MyList (2) = "line Item 3"

MyList (3) = "line Item 4"

MyList (4) = "line Item 5"

MyList (5) = "line Item 6"

Begin Dialog BoxSample 16,35,256,89,"List Box, Combo Box, and Drop-Down List Box"

OKButton 204,24,40,14

CancelButton 204,44,40,14

ListBox 12,24,48,40, MyList$( ),.Lstbox

DropListBox 124,24,72,40, MyList$( ),.DrpList

ComboBox 68,24,48,40, MyList$( ),.CmboBox

Text 12,12,32,8,"List Box:"

Text 124,12,68,8,"Drop-Down List Box:"

Text 68,12,44,8,"Combo Box:"

End Dialog

Dim Dlg1 BoxSample

Button = Dialog ( Dlg1 )

End Sub


Check Boxes in VBA

You use a check box to make a “yes or no” or “on or off” choice.  For example, you could use a check box to display or hide a toolbar in your application.

Sub Main

Begin Dialog CheckSample15,32,149,96,"Check Boxes"

OKButton 92,8,40,14

CancelButton 92,32,40,14

CheckBox 12,8,45,8,"CheckBox",.CheckBox1

CheckBox 12,24,45,8,"CheckBox",.CheckBox2

CheckBox 12,40,45,8,"CheckBox",.CheckBox3

CheckBox 12,56,45,8,"CheckBox",.CheckBox4

End Dialog

Dim Dlg1 As CheckSample

Button = Dialog ( Dlg1 )

End Sub


Text Boxes and Text in VBA

A text box control is a box in which the user can enter text while the dialog box is displayed.  By default, a text box holds a single line of text. (NetManage VBA does not support multi-line text boxes in this version.)

Sub Main

Begin Dialog TextBoxSample 16,30,180,96,"Text Boxes and Text"

OKButton 132,20,40,14

CancelButton 132,44,40,14

Text 8,8,32,8,"Text Box:"

TextBox 8,20,100,12,.TextBox1

Text 8,44,84,8,"Multiline Text Box:"

TextBox 8,56,100,32,.TextBox2

End Dialog

Dim Dlg1 As TextBoxSample

Button = Dialog ( Dlg1 )

End Sub


Option Buttons and Group Boxes in VBA

You can have option buttons to allow the user to choose one option from several.  Typically, you would use a group box to surround a group of option buttons, but you can also use a group box to set off a group of check boxes or any related group of controls.

Begin Dialog GroupSample 31,32,185,96,"Option Button and Check Box"

OKButton 28,68,40,14

CancelButton 120,68,40,14

GroupBox 12,8,72,52,"GroupBox",.GroupBox1

GroupBox 100,12,72,48,"GroupBox",.GroupBox2

OptionGroup .OptionGroup1

OptionButton 16,24,54,8,"OptionButton",.OptionButton1

OptionButton 16,40,54,8,"OptionButton",.OptionButton2

CheckBox 108,24,45,8,"CheckBox",.CheckBox1

CheckBox 108,40,45,8,"CheckBox",.CheckBox2

End Dialog

Dim Dlg1 As GroupSample

Button = Dialog (Dlg1)

End Sub

Sub Main

    Begin Dialog DialogName1 60, 60, 160, 70

    TEXT 10, 10, 28, 12, "Name:"

    TEXTBOX 42, 10, 108, 12, .nameStr

    TEXTBOX 42, 24, 108, 12, .descStr

    CHECKBOX 42, 38, 48, 12, "&CHECKME", .checkInt

    OKBUTTON 42, 54, 40, 12

    End Dialog

    Dim Dlg1 As DialogName1

    Dialog Dlg1

    MsgBox Dlg1.nameStr

    MsgBox Dlg1.descStr

    MsgBox Dlg1.checkInt

End Sub


Editing a Script

You can edit a script or move within the script using the New Line button and the up and down arrows on the button bar at the bottom of the Script Commands Assistance Screen.

To add a new line to a script, choose the New Line button.  This gives you an empty line. You can either add new text or leave it empty.

To move up or down a line, choose the up or down arrows. You can then edit the existing text.


Using Right Mouse Button

Another way to edit the script is to use the right mouse button.  Place the cursor at the desired location and click the right mouse button.  A drop down menu will be displayed with the following options:

•	Assist

•	Keyword

•	Undo

•	Cut

•	Copy

•	Paste

•	Delete

•	Select All

1.	Choose Assist to start the Assist dialog and edit a complete line.

2.	Choose Keyword to add or replace script commands or to concatenate text to the end of an existing command line.

a)	To concatenate text to the end of an existing command line, place the cursor at the end of the line and choose Keyword.  This opens the Script Commands Assistance Screen.  Select the desired command from the Commands list box.  The command you select will be concatenated.

b)	To replace text in a script command, select the text and choose Keyword. This opens the Script Commands Assistance Screen. You can then select the desired command or parameter.  Choose the Close button.  The change you made now replaces the previous text in the script template.

c)	To add text, place the cursor at the insertion point, and follow the instructions in b.

The Edit commands provide a shortcut for the Edit commands on the menu bar.


OLE Automation in VBA

OLE Automation is an emerging standard promoted by Microsoft which applications use to expose their OLE objects to development tools, VBA, and containers that support OLE Automation. A spreadsheet application may expose a worksheet, chart, cell, or range of cells all as different types of objects (Microsoft Excel 5.0 does this).  A word processor might expose objects such as application, paragraph, sentence, bookmark, or selection (Microsoft Word 6.0 does this).

When an application supports OLE Automation, the objects it exposes can be accessed by VBA.  You can use VBA to manipulate these objects by invoking methods on the object, or by getting and setting the object’s properties, just as you would with the objects in VBA.  For example, if you created an OLE Automation object named MyObj, you might write code such as this to manipulate the object:

Sub Main

Dim MyObj As Object

Set MyObj = CreateObject ("Word.Basic")

MyObj.FileNewDefault

MyObj.Insert "Hello, world."

MyObj.Bold 1

End Sub

The following syntax is supported for the GetObject function:

Set MyObj = GetObject ("", class)

where class is the parameter representing the class of the object to retrieve. The first parameter at this time must be an empty string.

The properties and methods an object supports are defined by the application that created the object.  See the application's documentation for details on the properties and methods it supports.

See Also:

Accessing an Object in VBA

Using the OLE Browser

Creating an OLE Object with Assist

OLE Fundamentals in VBA

OLE Automation Example

Making Applications Work Together in VBA

Registration Database in VBA


Accessing an Object in VBA

The following functions and properties allow you to access an OLE Automation object:

Name	Description
CreateObject Function	Creates a new object of a specified type.
GetObject Function	Retrieves an object pointer to a running application.
An OLE Automation Object is an instance of a class within your application that you wish to manipulate programmatically, such as with VBA.  These may be new classes whose sole purpose is to collect and expose data and functions in a way that makes sense to your customers.

The object becomes programmable when you expose those member functions.  OLE Automation defines two types of members that you may expose for an object:

•	Methods are member functions that perform an action on an object.  For example, a Document object might provide a Save method.

•	Properties are member function pairs that set or return information about the state of an object.  For example, a Drawing object might have a style property.


OLE Fundamentals in VBA

Object Linking and Embedding (OLE) is a technology that allows a programmer of Windows-based applications to create an application that can display data from many different applications, and allows the user to edit that data from within the application in which it was created.  In some cases, the user can even edit the data from within their application.

The following terms and concepts are fundamental to understanding OLE.

OLE Object

An OLE object refers to a discrete unit of data supplied by an OLE application.  An application can expose many types of objects.  For example a spreadsheet application can expose a worksheet, macro sheet, chart, cell, or range of cells all as different types of objects.  You use the OLE control to create linked and embedded objects.  When a linked or embedded object is created, it contains the name of the application that supplied the object, its data (or, in the case of a linked object, a reference to the data), and an image of the data.

OLE Automation

Some applications provide objects that support OLE Automation.  You can use VBA to programmatically manipulate the data in these objects.  Some objects that support OLE Automation also support linking and embedding. You can create an OLE Automation object by using the CreateObject function.

Class

An object’s class determines the application that provides the object’s data and the type of data the object contains.  The class names of some commonly used Microsoft applications include:

•	MSGraph

•	MSDraw

•	WordDocument

•	ExcelWorksheet.


Using the OLE Browser

OLE Browser is an option in the Assist Dialog that allows you to select an OLE Type Library and view its online help. You can also access the Windows Help Files for the particular Type Library.

Note:	 You can have more than one Type Library open at the same time.

To activate the Browser:

1.	Choose OLE Browser from the Script Commands Class list box. This activates the Browser Dialog and displays a list of all OLE Type Libraries.

2.	Choose a specific Type Library. This adds the selected OLE object to the Command Class combo box and its methods and properties to the Command List list box.

3.	Select an object and the online help for that method or property will be displayed in the Command Description Window.

4.	To access the Windows Help Files, choose the help icon on the bottom of the screen.  If the Type Library does not have a Windows online help, the help icon will not appear.


Creating an OLE Object with Assist

You can use the Assist menu to create an OLE object.

1.	Choose the Assist menu.

2.	Open the OLE Browser by selecting it from the Commands Class list box.

3.	Select  the desired Type Library from the OLE Browser Dialog.

4.	Select the relevant method or property in the Script Command list box and choose the Select button.  The selected method or property is displayed in the Current Command field and text boxes prompt you for input of parameters that are listed in the drop-down list menu.

5.	Enter the object name in the Object Var Name box or open the drop-down menu and choose <object> to see a list of objects currently available.

6.	Choose the New button to enter a new object related to the current class.

7.	Choose the Close or New Line button or the Up or Down arrow to automatically add the object declaration to the script with the correct syntax.

Many command classes have properties and methods with the same name.  If you enter such a command in the script, then choose the Assist menu, a list of all objects that have this command will be displayed.  Select an object from the list and choose the Display button.  The correct object will then be inserted in the script template.


Making Applications Work Together in VBA

Operations like linking and object embedding need applications to work together in a coordinated fashion.  However, there is no way that Windows can be set up, in advance, to accommodate all the applications and dynamic link libraries that can be installed.  Even within an application, the user has the ability to select various components to install.

As part of the installation process, Windows requires that applications supporting DDE/OLE features register their support by storing information in several different locations.  The most important of these to VBA is the registration database.

The win.ini file contains a special section called [embedding] that contains information about each of three applications that operate as object servers.


Registration Database in VBA

Starting with Windows 3.1, each Windows system maintains a registration database file that records details about the DDE and OLE functions supported by the installed applications.  The registration database is stored in a file called REG.DAT in the \ WINDOWS directory.

REG.DAT contains information that controls a variety of activities relating to data integration using DDE and OLE.  This information can be divided into four basic categories, as described in the following table:

Category	Meaning
Associations	Information that associates files with specific extensions to particular applications.  This is essentially the same function performed by the [extensions] section of the WIN.INI.
Shell Operations	Shell refers to a program that organizes basic operating system tasks, like running applications, opening files, and sending files to the printer.  Shell programs use list, windows, menus, and dialog boxes to perform these operations.  (In contrast, command systems like DOS require the entry of explicit command lines to accomplish these tasks.)
OLE Object Servers	A highly structured database of the details needed by programs that operate as object servers.  This is by far the most complex task performed by the database.  There is no WIN.INI equivalent for this function.
DDE/OLE Automation	Contains the details and the applications that support various types of DDE/OLE Automation operations.
Note:	There is a significant difference in structure between the WIN.INI file and the REG.DAT database.  WIN.INI is simply a text document.  There are no special structures other than headings (simply titles enclosed in brackets) that organize the information.   If you want to locate an item in the WIN.INI file, you must search through the file for the specific item you want to locate.  The registration database is a tree-like, structured database used for storing information relating to program and file operations, in particular, those that involve the use of DDE or OLE.  The tree structure makes it easier to organize the complex set of instructions needed to implement DDE and OLE operations, so that they are easily accessible to the applications that need to use them.  This is not possible when you are working with a text document like WIN.INI.  The WIN.INI file records all sorts of information about the Windows system in a simple, sequential listing.


Global Array

An array declared out the procedure section of a code module.


Local Array

An array declared inside a procedure.


OLE Automation Example

Sub OLEexample()

    Dim word6 As Object

    Dim myData As String

    myData = 4 * Atn(1)	' Demonstrates Automatic type conversion

    Set word6 = CreateObject("Word.Basic")

    word6.FileNewDefault

    word6.Insert "The following was computed in VBA: "

    word6.Bold 1	' Show value in boldface

    word6.Insert myData

    word6.Bold 0

   MsgBox "Done"

End Sub


File

New

Open...

Close

Save

Save As...

Configuration...

Translate...

Print...

Print Preview

Print Setup

Exit


Edit

Undo

Cut

Copy

Paste

Delete

Find...

Find Next

Replace...

Select All


Settings

Preferences

Script Type

Font...

Toolbar

Smart Buttons

Status Bar

Printer Font...


Run

Go

Debug


Tools

Selecting  this menu activates the Dialog Editor. The Dialog Editor  allows you to create or edit a VBA dialog template.

To create a dialog template:

1.	Place the cursor on a new line in the script.

2.	Select the Dialog Editor option in the Tools menu.  A dialog box will be displayed.

3.	Choose the required dialog item from either the Dialog Item menu or the Dialog Editor toolbar.

4.	When you have completed the dialog, choose the Put Dialog on Clipboard option followed by the Close option in the VBA Script Dialog Editor's File menu. The code that was in the Dialog Editor creates a dialog template and is placed in the script.

To edit a dialog template:

Select the code you want to change and follow the steps for creating a template (starting from step 2).


Window

Cascade

Tile

Arrange Icons


Help

Contents

About Visual Script Editor...


New

Opens a new Script template file.  The form of the template changes, depending on which Script Type you have currently selected.

To open a new Script Template file:

1.	Choose the New command from the File menu.


Open
Open...

Opens an existing Script file.  When you select Open, Visual Script Editor allows you to load an existing file.  Files created with the Cham 4.5 or Simplified Script Type have the *.scr extension.  Files created with the VBA Script Type have the *.vba extension.

To open an existing file:

1.	Choose the Open... command from the File menu.

2.	Select the desired Drive, directory and file

3.	Choose the OK button.


Close

Choose this command to close the currently open Script file.

1.	Choose the Close command from the File menu.


Save

Save saves the script file with its existing script file name to disk.

To save a script file:

1.	Choose the Save command from the File menu.


Save As
Save As...

Allows you to select the file name, directory, and drive you want to use for saving your script file.  The appropriate extension for the currently selected Script Type is automatically supplied. For files created with the Cham 4.5 or Simplified Script Type, the *.scr extension is used.  For files created with the VBA Script Type, the *.vba extension is used.

To save a file with a new file name:

1.	Choose the Save As... command from the File menu.

2.	Select the desired drive and directory.

3.	Enter the filename into the text box.

4.	Choose the OK button.


Configuration

This command has a pop-down list of subcommands that relate to the vsevba.cfg file, that is, the configuration file for the VSEVBA application.  The VSEVBA.cfg file contains the values (default, or user-specified) for the various Settings.

New: Opens a new configuration file for the application, so that you can have more than one configuration file with different settings specified for each.

Open: Opens an existing configuration file for the VSEVBA application.

Save: Saves changes made to the current configuration file.

Save As: Saves changes made to the configuration file with the name specified in this dialog box.


Translate

Displays a dialog box that lets you convert a Cham 4.5 script to a VBA script.

It contains the following text boxes:

Convert from: Specifies the Script Type from which you wish to convert, that is, Cham 4.5.

Source File Name: Specify the name of the script file that you wish to convert.

Converted File Name: Specify the name of the file that will result from the conversion.  A file name with the *.vba extension will be displayed by default.  However, you can change the file name as you wish.

It also contains the following check box options for Adding Comments to the converted file:

•	all:	Adds comments, describing all changes made from the source file.

•	special: Adds only comments on more complicated changes, such as noting if a change was made because a name that was not reserved in Cham 4.5 is reserved in VBA.

•	none: No comments are added to the file.

If you select the Log option, you can see a real-time log of all changes as they are being made.  If you have selected a check box for Adding Comments, the comments are included in the log.


Print
Print...

Allows you to print the contents of the script file to your windows printer.

To print the file:

1.	Choose the Print... command from the File menu.


Print Preview

Allows you to see entire pages at a reduced size before printing.  You can check page breaks and adjust the margins.

To select Print Preview mode:

1.	Choose the Print Preview... command from the File menu.  An entire page is now shown at a reduced size on your screen.  The following menu items appear:

•	Print:  prints the page on your screen

•	Next Page:  advances file to the next page

•	Previous Page:  reverts file to the previous page

•	Two Page:  displays two pages on the screen

•	Zoom In:  enlarges the page size

•	Zoom Out:  reduces the page size

•	Close:  returns your file to its original size on screen and normal mode

2.	When you want to return to viewing the file in normal mode, select the close menu item on your Print Preview screen.


Print Setup
Print Setup...

Allows you to select different print options.

To modify the printer setup:

1.	Choose the Print Setup... command from the File menu.

2.	Select the default printer or a specific printer.

3.	Select the paper size, paper source, and Portrait or Landscape.

4.	Choose the OK button.


Exit

Exit closes VSE.

To exit :

1.	Choose the Exit command from the File menu.


Undo

Undo allows you to undo your last command.

To undo your last command:

1.	Choose the Undo command from the Edit menu.


Cut

Cut allows you to delete selected text and transfers it to the Clipboard.

To delete text:

1.	Select the text you want to delete

2.	Choose the Cut command from the Edit menu.


Copy

Copy allows you to copy selected text from the VBA Editor window into the Clipboard, leaving the original intact and erasing the previous Clipboard contents.

To copy text:

1.	Select the text using your mouse.

2.	Choose the Copy command from the Edit menu.


Paste

Paste allows you to add text from the Clipboard into the script file.

To paste Clipboard text:

1.	Place the cursor where you want the clipboard text to be inserted.

2.	Choose the Paste command from the Edit menu.


Delete

Delete allows you to delete selected text.

To delete selected text:

1.	Select the text using your mouse.

2.	Choose the Delete command from the Edit menu.


Find

Find allows you to locate specified text.

To locate specified text:

1.	Choose the Find command from the Edit menu.

2.	Type in the specified text in the Find What field in the Find dialog box.  Select the Match Case checkbox, if you want to locate upper or lower case letters in words, and the Up and Down check boxes if you want to search for the word in the rest of the file in a specific direction.

3.	Choose the Find Next button.


Find Next

Find Next allows you to repeat the last Find command.

To repeat the Find command:

1.	Choose the Find Next command from the Edit menu.

Your last Find command is then executed.


Replace

Replace allows you to replace specific text with different text.

To replace specific text:

1.	Choose the Replace command from the Edit menu.

2.	Enter the specified text in the Find What field in the Find dialog box.  Then enter the new text in the Replace With field.

3.	Choose the Replace or Replace All button.


Select All

Select All allows you to select the text in the entire document.

1.	Choose the Select All command from the Edit menu to highlight all the text in the document.


Assist

Assist invokes a dialog box that contains explanations of the Script commands and actually assists you to write a script. The contents of the Assist changes depending on which Script Type mode you have currently selected.  If the cursor is in a script line when you choose Assist, it opens with the specified command and its parameters listed.

The Assist dialog contains the following parts:

Command Class: This pop-down list box in the upper right corner of the dialog lets you filter the selection of commands listed in the Script Commands list box.  The contents of this list changes depending on which Script Type mode you have currently selected. You can select to view All the commands or one of the listed categories (such as Dialog).

Script Commands: This scrolling list box provides an alphabetical list of the commands available for the current Script Type in the currently selected Command Class. The default list shows all the commands available for the Script Type currently being used.

Command Description - This block contains the syntax, the definition, and an example of the command you have highlighted in the alphabetical list of commands. The Assist Screen contains a Print button that allows you to Print the current Command Description, so that you can have a hard-copy for reference.

Current Command -  This field contains the script command line that you have highlighted.. When you select or enter command parameters for that command, the specified parameters are added to the displayed Current Command line.

To build a script by using the Assist menu, do the following:

1.	Highlight a command in the Script Commands list box.  The command description is displayed in the Command Description box.

2.	Choose the Select button.  The selected command is displayed in the Current Command line, and text boxes appear prompting you to input any parameters that are part of that command. Open the drop-down menu to see a list of valid parameter types.

3.	Specify the requested information for the parameters in the appropriate text boxes.  The parameters you specify appear in the Current Command line.  If you fail to specify a required parameter, an error message will appear prompting you to specify that parameter.

4.	You can move within the script or edit it as you work.  To add a new line choose the New Line button.  To move up or down within the script use the up or down arrow button.  Repeat these steps for any other commands on the Assist list to continue building your script.

5.	Choose the Close button when you have completed building the script.  Your selected command and selected command parameters now appear in your script template.

For an example of using the Assist command, see

VBA Assist Example


VBA Assist Example

To open a Message Box:

1.	In the Script Commands list box, highlight the MsgBox command.

2.	Choose the Select button.

3.	A text box appears, prompting you to enter the message.  When you enter the requested text, it appears in the Current Command line.  For example, you could enter the message, “Hello, from NetManage, Inc.”

4.	Choose the Close button.

The line, MsgBox “Hello, from NetManage, Inc.” now appears in your script template.

Note:	You must enclose all strings within quotes.  The quotes are not added automatically.


Go

Go allows you to execute the Script from the VSE application.  A script can be run using either the Cham 4.5 Script Type or the VBA Script Type.  The choice of Script Type to be used during the run depends on which Script Type option is currently selected for the Run As option under Settings/Script Type.

To execute the Script:

1.	Choose the Go option from the Run menu.

2.	Choose the directory and drive, and enter or select the file in the Open Script File dialog box.

3.	Choose the OK button to execute the script.  The program then executes and appears on your screen.


Debug

Runs the open script in Debug mode, making it possible to debug the script line by line.  If you have stopped debugging, go back to the Run menu and choose the Go option.


Preferences

The Preferences dialog box allows you to select the following options:

Tab Stops: This option determines the number of characters (1 through 16) between tab stops.  The default is 8 characters.  To increase the space between tabs, specify a higher number.  To decrease the space between tabs, specify a lower number.  Changing the value in this option has an immediate effect on the tab stops.

The checkbox options do not have an effect on your current window.  They do not take effect until you close VSE and reopen the application.

Initial Template: This checkbox option determines whether the Virtual Script Editor (VSE) opens with a template for a script file, which includes the framework for a main function.  The option is selected by default.  If you prefer to have VSE open with a blank file, you can deselect this checkbox.

Word Wrap: This checkbox option determines whether VSE wraps text to the beginning of the next line when your typing reaches the margin.  The option is selected by default.  If this option is not selected, text will continue to run past the margin until you press ENTER.


Script Type

Allows you to select the Script Type Mode that you wish to use (Simplified or VBA) for editing and running the script:  To edit, select either:

•	Simplified: A subset of  NetManage Visual Basic for Applications commands that provide automated login.  It can be run from Telnet, TN3270 and TN5250 Terminal Emulation applications using a connection profile or after a connection has been made.

•	VBA: Refers to NetManage Visual Basic for Applications.  This Script Type is compatible with the standard Microsoft VBA, and supports Visual Basic™ syntax. It also supports OLE automation and function calls for external DLLs.

To run the script select either:

•	VBA: Runs scripts that have been created using either the Cham 4.5 or the VBA Script Type. Using this script player you can test your scripts by setting breakpoints, single stepping through the script, and watching as variables change.

•	Cham 4.5: Runs scripts that have been created using the Cham 4.5 or Simplified Script Type.

Note:  	If you have scripts that have been created using Cham 4.5, it is recommended that they be converted to VBA scripts.  However, for backward compatibility they can still be used, although support may be limited.

The Script Type that you select for editing affects the following commands:

•	New command from the File menu: The type of script template displayed depends on which Script Type you have selected for editing.

•	Assist command: The Assist contents depends on which Script Type you have selected for editing.


Font...

Allows you to select the screen display font for VBA.

To choose your font:

1.	Choose the Font command from the Settings menu.

2.	Select your font, font style, and font size in the Font dialog box.

3.	Press OK.


Toolbar

Allows you to display or hide the screen's toolbar.  You can use the Toolbar feature to create a new document, open an existing document, save the document, cut selected text, copy selected text, paste selected text, print active document, and display program information and version number.


Smart Buttons

Allows you to display each icon's description below the toolbar icons.


Status Bar

Allows you to display or hide the screen's status bar.


Set Printer Font
Printer Font...

Allows you to select the type of font for your printer.

To choose your font type:

1.	Choose the Printer Font command from the Settings menu.

2.	Select your desired font, font style and font size in the dialog box.

3.	Choose the OK button.


Cascade

Allows you to display your windows lined up vertically and overlapping on the screen.  To line up your windows, select the Cascade option from the Window menu to turn this option on.


Tile

Tile allows you to display your windows side-by-side on the screen.  Each window is the same size, and none are hidden.  To display windows side by side, select the Tile option from the Window menu to turn this option on.


Arrange Icons

Allows you to display your icons neatly displayed in a row at the bottom of your screen.  To arrange your icons, select the Arrange Icons option from the Window menu.


Contents

Using Help

To choose a Help topic:

Mouse               Point to the underlined topic you want to view and click the mouse button.

When the pointer is over an item you can choose, the pointer changes to a hand icon.

Keyboard           Press Tab to move the highlight to the underlined topic you want to view, and then press Enter.

To exit Help:

Mouse            1)  Point to the File menu and click the mouse button.

2)   Click the Exit command.

Keyboard          1)   Press Alt.

2)  Type the letter F.

3)  Type the letter X.


Troubleshooting

If you experience difficulties using this application, refer to the following items:

•	Ensure that the syntax in your commands matches the syntax of samples in the Assist Command Description box.

•	Ensure that the terminal emulation can be invoked manually.

•	Ensure that terminal emulation short names are correct.

Note:	 If you call NetManage Technical Support for assistance with this application, be sure to request Development Support.


About Visual Script Editor

1.	Choose the About VSE... command from the Help menu for information about this program.

2.	Choose the Copy button to copy the application version information into the Windows clipboard.  You can then paste this information into any application.

3.	Choose the OK button to continue.


Simplified Mode Commands

Simplified Mode commands are a set of commands that have a simplified syntax, which are intended to make it easier for you to create a script.  The Simplified Mode commands do not require you to specify parameter definitions.  Only predefined parameters are used.  The predefined parameters are, as follows:

•	$Result: When the script is executed, the text results of the command are stored in this parameter.

•	$Row, $Column: When the script is executed, the numeric results of the relevant command are stored in these parameters.

If you want the VSE Assist function to display only Simplified Mode commands, choose the Simplified command from the Script Type... option of the Settings menu. .

Simplified Mode commands must be included within a Simplified Mode block, so that the VSP application can distinguish these commands from regular commands.

A Simplified Mode block must begin with the 'Begin_Simplified' command and continues until the 'End_Simplified' command.

An entire Script can be contained within a Simplified Mode block, or a Simplified Mode block can be simply a portion of a Script.

For an example of Simplified Mode commands, select the following:

Example of Simplified Emulation Commands

Example of Simplified FTP Commands

Example of Simplified Mail Commands


Example of Simplified Emulation Commands

The following script example demonstrates how to use Simplified Mode to create Emulation commands.

Begin_Simplified

REM ****************************************************

REM  RUN THIS FILE FROM THE TELNET EMUALTION .

REM  This file demonstrate automatic login to TELNET  emulation.

REM  When asking enter your User ID and your password .

REM *****************************************************

WaitTexts  ( "Login","login","LOGIN")

If ( Found )

Set ( $Result , "")

Ask ( "Login Name :")

SendKey ( $Result )

SendAndWait  ( "<RETURN>" , "Password" , "PASSWORD" )

If  ( NotFound )

Goto ( LoginError )

EndIf

Password

SendKeys("<RETURN>")

SendAndWait  ( "%" , ">" , "#" )

If ( Found )

Type ( " Login Complite ")

Stop

Else

Goto ( LoginError )

EndIf

Else

Goto ( LoginError )

EndIf

LoginError:

Type ( " Login error , program terminate. ")

Stop

End_Simplified


Example of  Simplified FTP Commands

The following script example demonstrates how to create FTP commands in Simplified Mode.

Begin_Simplified

REM ****************************************************

REM  This file demonstrate how to use FTP simplified

REM  script command.

REM  This demo connect you to netmange FTP host .

REM  When asking you for password you should

REM  enter your e-mail address .

REM  see assist for the commands description.

REM *****************************************************

Type ("Welcome to FTP simplified script Demo.")

AskPassword ("Enter your Password ")

FTPConnect  ( "ftp.netmanage.com" , "anonymous" , $Result )

FTPChangeDir  ( "pub" )

FTPReceive  ( "readme.txt" , "readme.txt" , "ASCII" , "REPLACE" )

FTPDirToFile  ( "" , "FTPFILE.TXT" )

FTPDisconnect

 End_Simplified


Example of  Simplified Mail Commands

The following script example demonstrates how to use Simplified Mode to create Mail commands.

Begin_Simplified

REM ****************************************************

REM  This file demonstrate how to use MAIL simplified

REM  script command.

REM  This demo send a e- mail message , with

REM  attached file.

REM  use assist for the commands description.

REM *****************************************************

Type ("Welcome to MAIL simplified script demo.")

Ask (" Enter your E-mail address ")

MailPrepare ( "To" , $Result , "Demo for simplified script" , "mailsmp.scr")

MailAttach ("demo.scr")

MailSend

End_Simplified


Examples Using VBA Commands
Script Examples

For examples using different types of script components, select the following:

Example of Dialog Commands

Example of Emulation Commands

Example of Mail Commands

Example of FTP Commands

Example of Table Commands

Example of String Commands

Example of File Commands


Example_of_Dialog_Commands
Example of Dialog Commands

The following script example demonstrates how to use the Dialog commands.

' * SubRoutine :	 Dialog Operations

' * Demonstrates the commands :

' *	MsgAsk

' *	MsgAskQuite

' *	MsgAskPassword

' *	MsgType

' *	MsgMenu

' *	MsgRadio

' *	MsgButton

' *	TableList

' *	DlgItemType

' *	DlgItemAsk

' *	DlgItemAskQuiet

' *	DlgItemMenu

' *	DlgItemButton

' *	DlgItemRadio

' *	DlgItemTableList

' *	DlgItemSameLine

' *	DlgItemCheckList

' *******************************************************

Sub DialogOperations

Dim msg As String

Dim result1(8) As Integer

Dim result2(1) As Integer

Dim answer As String

Dim answer1 As String

Dim num As String

Dim num1 As Integer

Dim tmpStr As String

Dim i As Integer

Dim tableDlg As String

Dim tempDataArr(20) As String

DlgStart

DlgTitle "Dialog Operations"

DlgItemType "The script commands support many User Interface operations."

   	DlgItemType "The user interface commands can be grouped in one dialog box,"

   	DlgItemType "or they can be done one at a time."

   	DlgItemType "Here is a sample of them."

   	DlgItemType ""

   	DlgInquire

DlgEnd

num=""

MsgAsk "Please enter a numeric value. ", num, 20

   	answer = "you entered ... "

answer1 = answer

   	answer1 = answer1 & num

   	MsgType answer1

tmpStr=""

MsgAsk "Please enter a string value. ", tmpStr, 20

   	answer1 = answer

   	answer1 = answer1 & tmpStr

MsgType answer1

MsgAskQuiet "Please enter a PASSWORD. ", num, 8

   	answer1 = answer

   	answer1 = answer1 & num

   	MsgType answer1

tmpStr = ""

MsgAskPassword "please enter a PASSWORD string value (to be encrypt) :", tmpStr, 20

   	StrEncrypt tmpStr, tmpStr

answer1 = answer

   	answer1 = answer1 & "(after encrypt)  ..."

   	answer1 = answer1 & tmpStr

   	MsgType answer1

   	SysReDim tempDataArr , 8

   	tempDataArr(0) = "John"

   	tempDataArr(1) = "Jerry"

   	tempDataArr(2) = "Adam"

   	tempDataArr(3) = "Jim"

   	tempDataArr(4) = "Tom"

   	tempDataArr(5) = "Mike"

   	tempDataArr(6) = "Stewert"

   	tempDataArr(7) = "James"

   	tempDataArr(8) = "Richard"

   	MsgMenu "Please choose a name", tmpStr, tempDataArr

   	answer1 = answer

   	answer1 = answer1 & tmpStr

   	MsgType answer1

 	MsgRadio "Please choose a name", tmpStr, tempDataArr

   	answer1 = answer

   	answer1 = answer1 & tmpStr

   	MsgType answer1

   	MsgButton "Please choose a name", tmpStr, tempDataArr

   	answer1 = answer

   	answer1 = answer1 & tmpStr

   	MsgType answer1

   	MsgCheckList "Please choose names ", tempDataArr, result1

answer1 = answer

For i = 0 to 8

if result1(i) = 1 Then

answer1 = answer1 & tempDataArr(i)

answer1 = answer1 & ","

End if

Next  i

   	MsgType answer1

  	tableDlg = "Table in dialog"

   	SysReDim tempDataArr , 2

   	tempDataArr(0) = "Name"

   	tempDataArr(1) = "Company"

   	tempDataArr(2) = "Phone"

   	TableDefine tableDlg, tempDataArr

   	tempDataArr(0) = "Erez"

   	tempDataArr(1) = "NETiX"

   	tempDataArr(2) = "050570172"

   	TableAdd tableDlg, tempDataArr

   	tempDataArr(0) = "Yaron"

   	tempDataArr(1) = "IBM"

   	tempDataArr(2) = "838474"

   	TableAdd tableDlg, tempDataArr

   	tempDataArr(0) = "Yoram"

   	tempDataArr(1) = "Micro"

   	tempDataArr(2) = "98327476"

   	TableAdd tableDlg, tempDataArr

   	tempDataArr(0) = "Eliav"

tempDataArr(1) = "Zoranim"

   	tempDataArr(2) = "551551"

   	TableAdd tableDlg, tempDataArr

DlgStart

DlgItemType "Table can be also displayed in a dialog ."

DlgItemType " Please , select one line from the table by clicking it "

DlgItemType " and then click OK ."

DlgItemTableList tableDlg, index, 1

DlgInquire

DlgGetItemValue 1, index

DlgEnd

msg = "Row number "

   	msg = msg & index

   	msg = msg & " "

   	msg = msg & "containes "

   	msg = msg & " "

  	TableGet tableDlg, index, tempDataArr

    	msg = msg & tempDataArr(0)

   	msg = msg & " "

   	msg = msg & tempDataArr(1)

 	msg = msg & " "

   	msg = msg & tempDataArr(2)

   	MsgType msg

   	MsgType "The next dialog box will pause for 20 seconds "

   	MsgType "Press the Cancel button to continue sooner..."

MsgTitle "Delay"

   	SysDelay 20

DlgStart

   	DlgTitle"Dialog Operations"

DlgItemType "This is a collection of User Interface and text elements inside one Dialog Box"

   	DlgItemAsk "Numeric value :              ", num, 0, 20

   	DlgItemAsk "String value  :", tmpStr, 1, 10

   	DlgItemAskQuiet "PASSWORD numeric value: ", num, 2, 5

   	tempDataArr(0) = "Erez"

   	tempDataArr(1) = "Jane"

   	tempDataArr(2) = "Roger"

   	DlgItemMenu "Menu:", tmpStr, 3, tempDataArr

   	DlgItemCheckList "CheckList:", tempDataArr, result2, 4

   	DlgItemSameLine

   	SysReDim tempDataArr , 2

   	tempDataArr(0) = "Suzanne"

   	tempDataArr(1) = "Eliav"

   	tempDataArr(2) = "David"

   	DlgItemButton "Button:", tmpStr, 5, tempDataArr

   	DlgInquire

DlgEnd

End Sub


Example of Emulation Commands

The following script example demonstrates how to use the emulation commands: SysHide, Emulation, EmSetTelnet, and others.

Sub EmulationOperations

Dim hostName As String

Dim sessionName As String

Dim port As Integer

Dim row As Integer

Dim col As Integer

Dim length As Integer

Dim readScreen As String

Dim writeScreen As String

Dim searchText As String

Dim row1 As Integer

Dim col1 As Integer

Dim tryAgain As Integer

Dim quoteMark

Dim varEcho As String

Dim valueEcho As String

Dim endEcho As String

Dim msg As String

Dim msg1 As String

Dim msg2 As String

Dim msg3 As String

Dim num As Integer

Dim options(8) As String

Dim selected(8) As Integer

Dim userName As String

Dim LF As String

Dim tempDataArr(20) As String

Dim result(1) As Integer

result(0) =1

result(1) = 1

LF=Chr$(13)

quoteMark = chr$(34)

varEcho = "String variable : " & quoteMark

valueEcho = quoteMark & " has the value of : " & quoteMark

endEcho = quoteMark

Dim userPassword As String

Dim res As Integer

Dim commandLine As String

Emulation "Telnet"

userName = ""

hostName = ""

DlgStart

DlgTitle "Welcome to Telnet emulation demo !!!"

DlgItemType "When we write a script program with emulation, we have to choose"

DlgItemType "emulation type first. In this case we will choose Telnet."

DlgInquire

DlgEnd

DlgStart

DlgTitle "Activate"

DlgItemType "After we have chosen the emulation type ,we can "

DlgItemType "activate it ,but first we need the host name, port number and session name ."

DlgInquire

DlgEnd

DlgStart

DlgTitle "Activate"

DlgItemType "Activate terinal emulation Telnet"

DlgItemAsk "Host Name :", hostName, 0,30

SysReDim tempDataArr , 4

tempDataArr( 0 ) = "AA"

tempDataArr( 1 ) = "AB"

tempDataArr( 2 ) = "AC"

tempDataArr( 3 ) = "AD"

tempDataArr( 4 ) = "AE"

DlgItemMenu "Session name :", sessionName, 1, tempDataArr

DlgItemSameLine

DlgItemAsk "Port", 23, 2, 3

DlgInquire

DlgGetItemValue 0, hostName

DlgGetItemValue 1, sessionName

DlgGetItemValue 2, port

DlgEnd

EMSetTelnet hostName, port

 	EMActivate sessionName

DlgStart

DlgTitle "CaptureOn"

DlgItemType "From now, we start capture incoming data to file 'Capture.cap' ."

DlgInquire

DlgEnd

 	EMCaptureOn "CAPTURE.CAP", "append"

DlgStart

DlgTitle "Login info."

DlgItemAsk "UserName :", userName, 0, 20

DlgInquire

DlgGetItemValue 0, userName

DlgEnd

EMWaitText 30, "login:", 1, 1, row, col

DlgStart

DlgTitle "EmSendPassword"

DlgItemType "Now we will send a password to the emulation.  "

DlgItemType "The password is encrypted using the DlgItemAskPassword command or StrEncrypt command."

DlgItemType "The EmSendKeyPassword command decrypts the password"

 	DlgItemType "and then sends it ( without displaying it on the screen )."

DlgItemAskPassword "Enter Password  to be encrypted :", userPassword, 0, 20

DlgInquire

DlgGetItemValue 0, userPassword

DlgEnd

DlgStart

DlgTitle "WaitText"

DlgItemType "Wait untill a certain text appears on screen. In this case "

DlgItemType "wait until 'password' appears ."

DlgInquire

DlgEnd

SysReDim tempDataArr , 2

tempDataArr( 0 ) = "Password"

tempDataArr( 1 ) = "PASSWORD"

tempDataArr( 2 ) = "password"

EMWaitLineTexts "Set", 30, res, tempDataArr

EMSendKey userName

EMSendKey "<RETURN>"

EMWaitLineTexts "WAIT", 30, res, tempDataArr

If NM_ResultCode>0 Then

MsgType NM_ResultText

Exit Sub

End If

EMSendKeyPassword userPassword

SysReDim tempDataArr , 2

tempDataArr( 0 ) = "% "

tempDataArr( 1 ) = ">"

tempDataArr( 2 ) = "#"

EMWaitLineTexts "Set", 30, res, tempDataArr

EMSendKey "<RETURN>"

EMWaitLineTexts "WAIT", 30, res, tempDataArr

If NM_ResultCode > 0 Then

MsgType NM_ResultText

Exit Sub

End If

SysHide "Emulation"

DlgStart

DlgTitle "Hide"

DlgItemType "Oops , Where is it ?"

DlgItemType "We just used the SysHide command to minimize the emulation window ."

DlgItemType "By using the SysShow command , we can now continue with the demo ."

DlgInquire

DlgEnd

SysShow "EMULATION"

DlgStart

DlgTitle "ScreenSize"

DlgItemType "Get the screen size ."

DlgInquire

DlgEnd

EMScreenSize row, col

Msg = "The emulation screen size is : "

Msg = Msg & row

Msg = Msg & "x"

Msg = Msg & col

MsgType Msg

EMReadCursor row, col

DlgStart

DlgTitle "ReadScreen"

DlgItemType "Now we will read from the cursor position the specified number of characters."

  	DlgItemType "If you don't like the cursor position, you can change it."

DlgItemAsk "Select number of characters to be read :", 20, 0, 3

DlgItemType "Change cursor position here :"

DlgItemAsk "Row:", row-2, 1, 3

DlgItemAsk "Col:  ", 1, 2, 3

DlgInquire

DlgGetItemValue 0, length

DlgGetItemValue 1, row

DlgGetItemValue 2, col

DlgEnd

EMReadScreen readScreen, length, row, col

Msg = VarEcho

Msg = Msg & "ReadScreen"

Msg = Msg & ValueEcho

Msg = Msg & ReadScreen

Msg = Msg & EndEcho

MsgType Msg

DlgStart

DlgTitle "ReadCursor"

DlgItemType "Now, we will read the cursor position on the screen."

DlgInquire

DlgEnd

EMReadCursor row, col

Msg = "Cursor position is : "

Msg = Msg & row

Msg = Msg & "x"

Msg = Msg & col

MsgType Msg

TryAgainSearch:

DlgStart

   	DlgTitle "Search"

DlgItemType "You can search for a specified text on the emulation screen, starting from a specific position ."

DlgItemType ""

DlgItemAsk "Insert text to search : ", userName, 0, 20

DlgItemType "Enter starting search position , please ."

DlgItemAsk "Row :", 1, 1, 3

DlgItemAsk "Col :  ", 1, 2, 3

DlgInquire

DlgGetItemValue 0, searchText

DlgGetItemValue 1, row

DlgGetItemValue 2, col

DlgEnd

EMSearch searchText , row, col, row1, col1

If  NM_ResultCode > 0 Then

MsgType "Text wasn't found"

MsgConfirm "Do you want to try again ?", TryAgain

If TryAgain = 1 Then

Goto TryAgainSearch

End If

Else

Msg = VarEcho

Msg = Msg & "Search"

Msg = Msg & ValueEcho

Msg = Msg & Row1

Msg = Msg & " x"

Msg = Msg & Col1

Msg = Msg & EndEcho

MsgType Msg

End If

DlgStart

DlgTitle "SendKey"

DlgItemType "We can also send a command key or function key to the screen ."

DlgItemAsk "Command Line : ", "ls" ,0 , 10

DlgInquire

DlgGetItemValue 0,commandline

DlgEnd

EMSendKey CommandLine

EmSendKey "<RETURN>"

DlgStart

DlgTitle "CaptureOff"

DlgItemType "We will now stop capturing incoming data to the file. "

DlgItemType "The NotePad will be opened to show the captured file."

DlgInquire

DlgEnd

EMCaptureOff

SysWinExec "NotePad capture.cap"

DlgStart

DlgTitle "Disconnect Command"

DlgItemType "You have reached to the end of the TELNET demo.  ."

DlgItemType "We hope you enjoyed it."

DlgItemType "The last step is to disconnect  the host..."

DlgInquire

DlgEnd

kill "capture.cap"

EMDisconnectExit SessionName

End Sub


Example of Mail Commands

The following script example demonstrates how to use Mail commands.

Sub MailOperations

Dim address As String

Dim subject  As String

Dim file As String

Dim file1 As String

Dim relation As String

Dim tempDataArr(20) As String

Dim num As Integer

MailTryAgain:

DlgStart

DlgTitle "Mail Operations"

DlgItemType "The script also support  Mail commands."

DlgItemType ""

SysReDim tempDataArr , 2

tempDataArr(0) = "To"

tempDataArr(1) = "Cc"

tempDataArr(2) = "Bcc"

DlgItemRadio "Relation  :", relation, 0, tempDataArr

DlgItemAsk "Address :        ", address, 1, 25

DlgItemAsk "Subject :          ", subject, 2, 25

DlgItemAsk "Mail body file:", file, 3, 25

DlgInquire

DlgGetItemValue 0, relation

DlgGetItemValue 1, address

DlgGetItemValue 2, subject

DlgGetItemValue 3, file

DlgEnd

MailPrepare relation, address, subject, file

if NM_ResultCode <> 0 Then

MsgConfirm "Do you want to try again ?",num

If num = 1  Then

 Goto MailTryAgain

Else

Exit Sub

End If

End If

msgConfirm "Do you want to send this mail to other names ?", num

If num = 1 Then

Address = " "

DlgStart

DlgItemRadio "Relation  :", relation, 0, tempDataArr

DlgItemAsk "Address :", address, 1, 25

DlgInquire

DlgGetItemValue 0, relation

DlgGetItemValue 1, Address

DlgEnd

MailAddress relation, address

End If

msgConfirm "Do you want to attach a file ?", num

If num =1 Then

msgAsk "File to be attached :", file1, 25

MailAttach file1

End If

MailSend

End Sub


Example of FTP Commands

The following script example demonstrates how to use FTP commands.

Sub Main

Dim Password As String

MsgType "Welcome to FTP script Demo."

MsgAskPassword "Enter your ftp Password " , Password , 40

FTPConnect  "ftp.netmanage.com" , "anonymous" ,Password

FTPChangeDir  "pub"

FTPReceive  "readme.txt" , "readme.txt" , "ASCII" , "REPLACE"

FTPDirToFile   "" , "FTPFILE.TXT"

FTPDisconnect

End Sub


Example of Table Commands

The following script example demonstrates how to use the Table commands: Table, TableAdd, TableErase, TableGet, and TableList.

'*************************************************

' *  SubRoutine : TableOperations

' *  Demonstrats the commands :

' *	Table

' *	TableAdd

' *	TableErase

' *	TableGet

' *	TableList

'***********************************************************

Sub TableOperations

Dim table As String

Dim confirm As Integer

Dim index As Integer

Dim column(3) As String

Dim tempDataArr(20) As String

Dim Msg As String

Dim Msg1 As String

Dim Msg2 As String

Dim Msg3 As String

DlgStart

DlgTitle "Table Operations"

DlgItemType "You can define a table with N columns."

DlgItemType "You can add , erase and get rows from the table. "

DlgItemType "You can display it (within a dialog or separately.)"

DlgItemType "Each Column can be sorted by doubleclicking  on the top of the column."

DlgItemType "You can also change the order of columns ."

DlgItemType "Doubleclicking on a certain row will return the index of the row."

DlgItemType "In this example, we will define a table with 3 columns."

DlgItemAsk "Table : ", "Table", 0, 10

DlgItemAsk "First column name:      ", "Name       ", 1, 10

DlgItemAsk "Second column name:", "Company", 2, 10

DlgItemAsk "Third column name:     ", "Phone      ", 3, 10

DlgInquire

DlgGetItemValue 0, table

DlgGetItemValue 1, msg1

DlgGetItemValue 2, msg2

DlgGetItemValue 3, msg3

DlgEnd

column(0)=msg1

column(1)=msg2

column(2)=msg3

TableDefine table, column

SysReDim tempDataArr, 2

DlgStart

DlgItemType "After we define the table ,we can add a line to it , by using TableAdd command."

DlgItemAsk column(0), "Joe Allan", 0, 20

DlgItemAsk column(1), "NetManage", 1, 20

DlgItemAsk column(2), "9737171", 2, 20

DlgInquire

DlgGetItemValue 0, msg1

DlgGetItemValue 1, msg2

DlgGetItemValue 2, msg3

DlgEnd

tempDataArr(0) = msg1

tempDataArr(1) = msg2

tempDataArr(2) = msg3

TableAdd table,TempDataArr

tempDataArr(0) = "Jack Velan"

tempDataArr(1) = "NETiX"

tempDataArr(2) = "8721487"

TableAdd table, tempDataArr

tempDataArr(0) = "Tom Smith "

tempDataArr(1) = "IBM"

tempDataArr(2) = "5435234"

TableAdd table, tempDataArr

MsgConfirm "Add more ?", confirm

If confirm =1 Then

DlgStart

DlgItemAsk column(0), "", 0, 10

DlgItemAsk column(1), "", 1, 10

DlgItemAsk column(2), "", 2, 10

DlgInquire

DlgGetItemValue 0, msg1

DlgGetItemValue 1, msg2

DlgGetItemValue 2, msg3

DlgEnd

tempDataArr(0) = msg1

tempDataArr(1) = msg2

tempDataArr(2) = msg3

TableAdd table, tempDataArr

End If

DlgStart

DlgItemType "Now, it's time to display the table. You can double-click a row , and the index of the row "

DlgItemType "is returned as a result."

DlgInquire

DlgEnd

TableList table, index

DlgStart

DlgItemType "By using TableGet command , you can get all the "

DlgItemType "values in a line according to its specified index."

DlgInquire

DlgEnd

TableGet table, index, tempDataArr

msg = "Line number "

msg = msg & Index

msg = msg & " containes  "

msg = msg & tempDataArr(0)

msg = msg & " , "

msg = msg &tempDataArr(1)

msg = msg & " , "

msg = msg &tempDataArr(2)

MsgType msg

MsgType "You can also delete the last line that was added."

TableDelete table

TableList table, index

MsgType "And, of course,  you can erase all lines from the table."

TableErase table

TableList table, index

End Sub


Example of VBA Commands

(this is here in case it should be added later)

The following script example demonstrates how to use VBA commands.

***********************************************

' * Subroutine : VBAOperations Demo

' * Demonstrates the commands:

' *	Time

' *	Format

' *	UpperBound

' *	LowerBound

' *	Chdir

' *	Mkdir

' *	RmDir

' *	Shell

' *	SendKeys

' *	Begin Dialog

' *	PushButton

' *	ListBox

' *	DropListBox

' *	ListBox

' *	OKButton

' *	CancelButton

' *	ComboBox

' *	Text

' *	TextBox

' ************************************************

Sub VBAOperations

Dim dateVar As String

Dim timeVar As String

Dim varEcho As String

Dim valueEcho As String

Dim endEcho As String

Dim Msg As String

Dim Msg1 As String

LF=Chr$(13)

quoteMark = chr$(34)

varEcho = "String variable : " & quoteMark

valueEcho = quoteMark & " has the value of : " & quoteMark

endEcho = quoteMark

DlgStart

DlgTitle "VBA Operations"

DlgItemType "The Visual Basic for Appliactions language adds many new commands to the script language."

DlgItemType "In this part we will explore these commands."

DlgItemType "We will start with the time handling commands."

DlgItemType "These commands allow you to know the year, month, day and time"

DlgInquire

DlgEnd

timeVar = Format(Time,"Short time")

dateVar= Format(date,"Short date")

MsgTitle "Short Format"

msg = "The time & date can be shown in a Short format : " & LF & LF

msg = msg & "The time is : " & timeVar & LF & LF

msg = msg & "The date is : " & dateVar

MsgType msg

timeVar = Format(Time, "Long time")

dateVar = Format(Date,  "Long date")

MsgTitle "Long Format"

msg = "The time & date can be also shown in a Long format : " & LF & LF

msg = msg & "The time is : " & timeVar & LF & LF

msg = msg & "The date is : " & dateVar

MsgType msg

DlgStart

DlgTitle "SendKeys Command"

DlgItemType "You can activate Windows applications and send keys to them."

DlgItemType "In the next example we will activate the Notepad application in maximized mode , send the word"

DlgItemType quoteMark & "Hello World" & quoteMark & " and save the document under"

DlgItemType qouteMark & "demotext.txt" & quoteMark & ". Then we will close it."

DlgInquire

DlgEnd

kill "demotext.txt"

shell ("notepad.exe")

SysHide "Timer"

SendKeys "Hello World"

SysDelay 1

SendKeys "%F,S"

SendKeys "demotext.txt"

SysDelay 1

SendKeys "{ENTER}"

SysDelay 1

SendKeys "%F,X"

SysShow "Timer"

kill "demotext.txt"

DlgStart

DlgTitle "Arrays in VBA"

DlgItemType "Working with Arrays is much easier with VBA."

DlgItemType "You can create an Array of Integers, Strings or Variants."

DlgItemType "You can Redim the Array as many time as you want during the execution of the script."

DlgItemType "The UpperBound or LowerBound of the array can be changed too."

DlgItemType"Finally - if you want to earse all elemants from the array use the Erase command."

DlgInquire

DlgEnd

DlgStart

DlgTitle "Dos commands"

DlgItemType "There are many DOS commands that you can execute directly from the script"

DlgItemType "For Example:"

DlgItemType "Current default directory is: " & CurDir

DlgItemAsk "Create New Directory by the name: ","Test", 1, 10

DlgInquire

DlgGetItemValue 1,msg1

DlgEnd

ChDir "\"

MkDir msg1

FileDirList "temp.txt"

MsgType "We will now open Notepad with a file created by the FileDirList command, so you can see that the directory was created"

shell("notepad temp.txt")

MsgType"Now we will remove the directory we just created"

RmDir msg1

DlgStart

DlgTitle "User Defined Dialogs"

DlgItemType "The VBA language allows you to create sophisticated user defined Dialogs."

DlgItemType "These Dialogs can be edited and created using the Dialog Editor found in the Tools menu"

DlgItemType "The 4 next Dialogs will demonstrate some of the possible fields of a VBA Dialog window."

 	DlgItemType "All of them were created using the Dialog Editor."

DlgInquire

DlgEnd

Dim MyList(7) As String

MyList(0) = "Array Line 1"

MyList(1) = "Array Line 2"

MyList(2) = "Array Line 3"

MyList(3) = "Array Line 4"

MyList(4) = "Array Line 5"

MyList(5) = "Array Line 6"

MyList(6) = "Array Line 7"

MyList(7) = "Array Line 8"

Begin Dialog EXAMPLE1 89,44, 200, 199, "Radio Buttons , Check Boxes & Group Boxes"

  OptionGroup .GROUP_1

  OptionButton 16,96,60,8, "RadioButton 1"

  OptionButton 16,116,64,8, "RadioButton 2"

  GroupBox 8,80,76,56, "GroupBox"

  CheckBox 112,92,52,12, "CheckBox 1", .CheckBox_1

 	 CheckBox 112,116,56,12, "CheckBox 2", .CheckBox_2

  Text 4,16,188,28, "The two radio buttons are associated together to form a  group - therefore you can only select one of them."

  Text 4,48,188,24, "The Check Boxes are not tied together so you can select the first one, second one or both."

  OKButton 60,172,68,16

End Dialog

Dim ex1 As EXAMPLE1

Dialog ex1

Begin Dialog EXAMPLE2 82,55, 200, 199, "User Defined Push Buttons"

  Text 12,12,0,0, "You c"

  Text 12,8,168,32, "You Can create as many Push-Buttons as you like and give each of the user's choice a sepearete action later in your script."

  Text 16,60,156,12, "Choose one of these buttons:"

PushButton 16,88,68,16, "Push ME!", .Push1

  	PushButton 100,88,72,16, "NO - Push ME!", .Push2

  	PushButton 100,128,72,16, "Don't think about it !", .Push4

  	PushButton 16,168,68,16, "Push the right one!", .Push5

  	PushButton 100,168,72,16, "Push the left one!", .Push6

  	PushButton 16,128,68,16, "Don't Push Me!", .Push3

End Dialog

Dim ex2 As EXAMPLE2

Button = Dialog (ex2)

if Button = 1 then msg1 =" 'Push Me!' "

if button = 2 then msg1 = " 'No- Push ME!' "

if button = 3 then msg1 = " 'Don't think about it!' "

if button = 4 then msg1 = " 'Push the right one!' "

if button = 5 then msg1 = " 'Push the left one!' "

if button = 6 then msg1 = " 'Don't Push Me !' "

MsgBox "You pushed the" & msg1 & "button"

Begin Dialog EXAMPLE3 46,71, 288, 199, "Combo Boxes, Drop-Down List-Boxes & List Boxes."

  	Text 8,12,268,32, "In order to create a Drop-down list box , a Combo-box or a List box you first have to define an array that will hold the items you want to include in the list."

ListBox 8,56,68,68, MyList, .ListBox_1

ComboBox 100,52,72,72, MyList, .ComboBox_1

  	DropListBox 196,52,76,72, MyList, .DropDown_1

  	OKButton 120,160,36,24

End Dialog

Dim ex3 As EXAMPLE3

Dialog ex3

Print "You Choose line: " &MyList(ex3.ListBox_1) &" from the ListBox "

Print "You Choose line: " &MyList(ex3.ComboBox_1) &" from the ComboBox "

Print "You Choose line: " &MyList(ex3.DropDown_1) &" from the DropListBox "

Begin Dialog EXAMPLE4 57,62, 261, 189, "Edit Box and Cancel button."

  	TextBox 40,104,184,12, .EditBox_1

  	Text 4,4,244,28, "An edit box is useful if you want the user to enter text freely rather than choosing from a given list."

Text 4,44,244,24, "We also included a Cancel button here to demonstrate the possiblity of allowing the user to exit the script at whatever point he is at."

  	OKButton 24,164,60,12

  	CancelButton 172,164,60,12

  	Text 40,84,84,12, "Please enter your name:"

End Dialog

Dim ex4 As EXAMPLE4

Dialog ex4

Print "Hello " & ex4.EditBox_1

End Sub


Example of String Commnads; StrReverse , StrEncrypt , InStr , Len , Mid , StrParse
Example of String Commands

The following script example demonstrates how to use the string commands.

*******************************************************

' *  SubRoutine : 	StringOperations

' *  Demonstrates the commands :

' *	StrReverse

' *	StrEncypt

' *	Instr

' *	Len

' *	Mid

' *	StrParse

'  *******************************************************

Sub StringOperations

Dim varEcho As String

Dim valueEcho As String

Dim endEcho As String

Dim concat As String

Dim reverse As String

Dim textVar As String

Dim pattern As String

Dim encrypt As String

Dim searchString As String

Dim strLen As Integer

Dim start As Integer

   	Dim numChrs As Integer

Dim subString As String

Dim stringToParse As String

Dim itemNumber As Integer

   	Dim delimiter As String

Dim string1 As String

Dim string2 As String

Dim msg As String

Dim msg1 As String

Dim msg2 As String

Dim msg3 As String

LF=Chr$(13)

quoteMark = chr$(34)

varEcho = "String variable : " & quoteMark

valueEcho = quoteMark & " has the value of : " & quoteMark

endEcho = quoteMark

string1 = "Net"

string2 = "Manage"

msg1 = varEcho & "String1" & valueEcho & String1 & endEcho

msg2 = varEcho & "String2" & valueEcho & String2 & endEcho

DlgStart

DlgTitle "String Operations Demo"

DlgItemType "The script commands support many string operations."

DlgItemType "We can assign values to a string variable and manipulate it... "

DlgItemType "For example :"

DlgItemType msg1

DlgItemType msg2

DlgItemType "Now let's join the two together..."

DlgInquire

DlgEnd

concat = string1 & string2

msg = varEcho & "concat" & valueEcho & concat  & endEcho

MsgType msg

MsgType "How about reversing the result ?"

StrReverse concat, reverse

msg = varEcho & "reverse" & valueEcho & reverse & endEcho

MsgType msg

MsgType "OOPS!!! Lets reverse it back ..."

   	StrReverse reverse, reverse

   	msg = varEcho & "reverse" & valueEcho & reverse & endEcho

MsgType msg

   	textVar = reverse

DlgStart

DlgItemType "You can encrypt a string (usally as an encrypted password)..."

DlgItemAsk "Enter string to encrypt :", "NetManage", 0, 20

DlgInquire

DlgGetItemValue 0, encrypt

DlgEnd

   	StrEncrypt encrypt, encrypt

   	msg = varEcho & "encrypt" & valueEcho & encrypt & endEcho

   	MsgType msg

DlgStart

DlgItemType "We can search for the first occurence of a string pattern in a text."

DlgItemType "You can change the Text and the Pattern if you like."

DlgItemAsk "Text:    ", "NetManage", 0, 20

DlgItemAsk "Pattern to search :", "Man", 1, 10

DlgInquire

DlgGetItemValue 0, textVar

DlgGetItemValue 1, pattern

DlgEnd

searchString = InStr(1, textVar, pattern)

   	msg = varEcho & "searchString" & valueEcho & SearchString & endEcho

MsgType msg

msg = "Lets check the length of text : "& quoteMark & textVar & quoteMark

   	MsgType msg

  	strLen = Len(textVar)

   	msg = varEcho

   	msg = msg & "strLen"

   	msg = msg & valueEcho

   	msg = msg & StrLen

   	msg = msg & endEcho

   	MsgType msg

DlgStart

DlgItemType "We can also copy characters from text, starting from a certain position."

DlgItemType ""

DlgItemAsk "Text : ", textVar, 0, 20

DlgItemAsk "Start from position :",2 , 1, 5

DlgItemAsk "Number to copy :      ",4 ,2, 5

DlgInquire

DlgGetItemValue 0, textVar

DlgGetItemValue 1, start

DlgGetItemValue 2, numChrs

DlgEnd

subString = Mid(textVar, start, numChrs)

   	msg = varEcho

   	msg = msg & "subString"

   	msg = msg & valueEcho

   	msg = msg & subString

   	msg = msg & endEcho

   	MsgType msg

stringToParse = "Jerry,Adam,Jim,Tom,Mike,Johan"

   	delimiter = ","

   	msg = varEcho

msg = msg & "stringToParse"

   	msg = msg & valueEcho

   	msg = msg & stringToParse

   	msg = msg & endEcho

  	msg1 = varEcho

   	msg1 = msg1 & "delimiter"

   	msg1 = msg1 & valueEcho

msg1 = msg1 & Delimiter

   	msg1 = msg1 & endEcho

DlgStart

DlgItemType "We can extract a specific item from text that includes items divided by a delimiter ."

DlgItemType msg

DlgItemType msg1

DlgItemAsk "Enter item number :", 2, 0, 2

DlgItemSameLine

DlgItemType "to be extract."

DlgInquire

DlgGetItemValue 0, itemNumber

DlgEnd

StrParse stringToParse, delimiter, itemNumber, textVar

   	msg = varEcho

   	msg = msg & "text"

   	msg = msg & valueEcho

   	msg = msg & textVar

   	msg = msg & endEcho

   	MsgType msg

End Sub


Example of fileRead, FileReadNext, FileWrite,  FileAppend, FileCopy, FileDelete, FileRename, FileDirList, Kill
Example of File Commands

The following script example demonstrates how to use file operation commands.

' *******************************************************

' *  SubRoutine :	 FileOperations

' *  Demonstrates the commands :

' *	FileRead

' *	FileReadNext

' *	FileWrite

' *	FileAppend

' *	FileCopy

' *	FileDelete

' *	FileDirList

' *	FileRename

' *	Kill

' *******************************************************

Sub FileOperations

Dim varEcho As String

Dim valueEcho As String

Dim endEcho As String

Dim appendStr As String

Dim lineStr As String

Dim counter As Integer

DlgStart

DlgTitle "File Operations"

DlgItemType "The script commands support file input/output operations."

   	DlgItemType "The script will now read 7 lines from the file DEMO.VBA and write "

   	DlgItemType "them to DEMO.SAV"

      	DlgItemType "At the end of the file, the string that you will enter below and your name "

   	DlgItemType "will be appended to DEMO.SAV."

   	DlgItemAsk "String to be Appended", "Add this line", 0, 15

   	DlgItemType "We will also copy ,rename and finaly delete the file ."

   	DlgInquire

   	DlgGetItemValue 0, appendStr

DlgEnd

   	FileRead "demo.vba", lineStr,0

   	FileWrite "demo.sav", lineStr

for i =1 to 5

FileReadNext lineStr, 0

FileAppend lineStr

   	Next i

FileAppend appendStr

   	FileAppend userName

   	SysHide "Timer"

   	MsgType "We shall now activate the NotePad application to see the file."

   	SysWinExec "NotePad demo.sav"

   	SysDelay 1

   	SysShow "Timer"

MsgType "Copy DEMO.SAV to OLDDEMO.SAV"

   	FileCopy "demo.sav", "olddemo.sav"

MsgType "Rename demo.sav to NEWDEMO.SAV"

FileRename "demo.sav", "newdemo.sav"

MsgType "Activate NotePad application to see the files ."

   	SysWinExec "NotePad olddemo.sav"

   	SysWinExec "NotePad newdemo.sav"

MsgType "Delete OLDDEMO & NEWDEMO.SAV"

   	Kill "olddemo.sav"

Kill "newdemo.sav"

MsgType "You can write all filenames from the current directory to a file "

   	FileDirList "dirfile.txt"

MsgType "Activate NotePad to see the file "

   	SysWinExec "NotePad dirfile.txt"

   	SysDelay 1

Kill "dirfile.txt"

End Sub