Hi,
I wrote this a few years ago to automate working with Extra
Its basically a wrapper Class Module which you can add to your Project,
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
To use it just add a line like to your code dont forget to add a reference to Extra!
Private WithEvents Tool As clsExtra ' declare (Tool is just a name)
then just say something like Tool. and it will list the methods in the class, or you can add your own methods
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Here's the Code for the class, just add a class to your project and paste this into it. Worked for me for years...
Option Explicit
' *********************************************************************************
' clsEasyExtra, Steve Carr 15/9/03. Please modify or distribute freely.
' A simple class designed to allow you to i/face your VB application with Extra
' I have only inserted some common methods which I think you may find useful
' You may of course insert as many as you like, or modify the code to suit your
' own application. DONT FORGET TO SET UP A REFERENCE TO THE EXTRA OBJECT LIBRARY
' *********************************************************************************
Private objSystem As EXTRA.ExtraSystem ' declare some objects
Private objSession As EXTRA.ExtraSession
Private objScreen As EXTRA.ExtraScreen
Private objSessions As EXTRA.ExtraSessions
' Class Event Handlers
Private Sub Class_Initialize()
On Error GoTo Class_Initialize_Error
' Establish connection to Host via a valid Session
Dim intSessionCount As Integer
Set objSystem = New EXTRA.ExtraSystem
Set objSessions = New EXTRA.ExtraSessions
objSystem.TimeoutValue = 500
For intSessionCount = 1 To objSystem.Sessions.Count
Set objSession = objSystem.Sessions.Item(intSessionCount)
Set objScreen = objSession.Screen
objSession.Visible = True
Exit Sub
Next
Exit Sub
Class_Initialize_Error:
MsgBox "Valid Host Session not Available", vbCritical, "Critical Application Error"
End Sub
Private Sub Class_Terminate()
On Error Resume Next
Set objSystem = Nothing ' dispose
Set objSession = Nothing
Set objScreen = Nothing
End Sub
' General class methods
'Sends a Reset to Host
Public Sub Reset()
objScreen.SendKeys "<pf24>"
WaitForHost 1
End Sub
'Make Host Screen visible
Public Sub OpenSession()
objSession.NavigateTo Me
End Sub
Public Sub CloseSession()
objSession.Close
End Sub
Public Sub Show()
objSession.Visible = True
End Sub
'Make Host Screen invisible
Public Sub Hide()
objSession.Visible = False
End Sub
'Host Page Forward
Public Sub PageForward()
objScreen.SendKeys "<pf8>"
WaitForHost 1
End Sub
'Host Page Back
Public Sub PageBack()
objScreen.SendKeys "<pf7>"
WaitForHost 1
End Sub
'Save Host Screen
Public Sub Save()
objScreen.SendKeys "<pf20>"
WaitForHost 1
End Sub
'Recall saved Screen
Public Sub Recall()
objScreen.SendKeys "<pf21>"
WaitForHost 1
End Sub
'Goto Home ie. Screen position 01/02
Public Sub Home()
objScreen.SendKeys "<home>"
WaitForHost 1
End Sub
'Send Enter to Host
Public Sub Enter()
objScreen.SendKeys "<enter>"
WaitForHost 1
End Sub
'Send PF9 to Host
Public Sub A1()
objScreen.SendKeys "<pf9>"
WaitForHost 1
End Sub
'Delete line
Public Sub EraseEOF()
objScreen.SendKeys "<EraseEOF>"
End Sub
'Send data to Host with screen position x,y
Public Sub SendMessageParams(ByVal message As String, X As Integer, y As Integer)
objScreen.PutString message, X, y
End Sub
'Send data to Host without screen position
Public Sub SendMessage(message As String)
objScreen.PutString message
End Sub
'Send a command to Host
Public Sub SendCommand(command As String)
objScreen.SendKeys command
WaitForHost 1
End Sub
'Read text at cursor position
Public Function GetText(X As Integer, y As Integer, chars As Integer) As String
GetText = objScreen.GetString(X, y, chars)
End Function
'Wait for x seconds until host settles
Public Sub WaitForHost(seconds As Integer)
Do While objScreen.OIA.XStatus = 5
objScreen.WaitHostQuiet seconds ' x milliseconds
Loop
End Sub
' Minimize Host Screen
Public Sub MinimizeScreen()
objSession.WindowState = xMINIMIZED
End Sub
' Maximize Host Screen
Public Sub MaximizeScreen()
objSession.WindowState = xMAXIMIZED
End Sub
' Send Clear to Host
Public Sub Clear()
objScreen.SendKeys ("<clear>")
End Sub
' Restore Host screen to Normal
Public Sub RestoreScreen()
objSession.WindowState = xNORMAL
End Sub
*********************************************************************************************************************
Hope it helps,
Steve...
!ExtraDunce