Option Explicit
Function DELAY%
If Hour(Now())<17 Then DELAY=500 Else DELAY=0
End Function
'---------------------------------------------------------------------------------------------------------
Sub Main
Dim System As Object, Session As Object, Screen As Object, OIA As Object
Dim IN%, OUT%, infile$, outfile$
Dim ref$, mpan$, acno$,tenant%
Dim ioption%, value$, temp%, success%, num_record&, num_success&, num_error%
Dim result$, detail$
'---------------------------------------------------------------------------------------------------------
'# Find an active extra! screen object
Set System=CreateObject("EXTRA.System")
If Not System Is Nothing Then Set Session=System.ActiveSession
If Not Session Is Nothing Then Set Screen=Session.Screen
If Screen Is Nothing Then
MsgBox "Please open Attachmate EXTRA! mainframe client first"
Goto Finish
End If
Set OIA=Screen.OIA
'---------------------------------------------------------------------------------------------------------
'# Prompt user for file name and check answer
infile=InputBox("Enter the name of a text file to use as input"+Chr(10)+Chr(13)+ _
"Please use the full path, i.e. C:\Data\inputfile.txt")
Do
If Len(infile)=0 Then
MsgBox "No path entered, Event cancelled!"
Goto Finish
End If
If Len(Dir(infile))>0 Then Exit Do
infile=InputBox("There was a problem with "+infile+Chr(10)+Chr(13)+ _
"Please try something different this time."+Chr(10)+Chr(13)+ _
Chr(10)+Chr(13)+ _
"Enter the name of a text fileto use as input"+Chr(10)+Chr(13)+ _
"Please use the full path, i.e. C:\Data\inputfile.txt")
Loop
outfile=infile+"_OUTPUT.log"
'---------------------------------------------------------------------------------------------------------
'# Open files for use
IN=FreeFile
Open infile For Input As #IN
Do Until EOF(IN)
'---------------------------------------------------------------------------------------------------------
'# clear reused variables
mpan=""
acno=""
tenant=0
result=""
detail=""
success=0
Input #IN, ref
num_record=num_record+1
'---------------------------------------------------------------------------------------------------------
'# Give up if dodgy data is encountered
If Not IsNumeric(ref) Then
result="bad ref"
detail="not numeric"
End If
'---------------------------------------------------------------------------------------------------------
'# Decide whether ref is account number or MPAN
If CInt(left(ref,2))<30 Then mpan=ref Else acno=ref
'---------------------------------------------------------------------------------------------------------
'# Enter account
Screen.SendKeys "<CLEAR>"
Do:Screen.WaitHostQuiet DELAY

oEvents:Loop While OIA.XStatus=5
Screen.PutString acno,9,23
Screen.PutString "floh",7,23
Screen.SendKeys "<ENTER>"
Do:Screen.WaitHostQuiet DELAY

oEvents:Loop While OIA.XStatus=5
If Screen.GetString(9,28,5) = "D0190" then screen.putstring "01",22,18 else
If Screen.GetString(9,27,5) = "D0190" then screen.putstring "02",22,18 else
If Screen.GetString(9,26,5) = "D0190" then screen.putstring "03",22,18 else
If Screen.GetString(9,25,5) = "D0190" then screen.putstring "04",22,18 else
If Screen.GetString(9,24,5) = "D0190" then screen.putstring "05",22,18 else
If Screen.GetString(9,23,5) = "D0190" then screen.putstring "06",22,18 else
If Screen.GetString(9,22,5) = "D0190" then screen.putstring "07",22,18 else
If Screen.GetString(9,21,5) = "D0190" then screen.putstring "08",22,18
Screen.sendkeys "<ENTER>"
'---------------------------------------------------------------------------------------------------------
End Sub