We recently upgraded attachmate to run on Win7 64bit operating system. Unfortunately, some of our macros are failing, for example our search macro fails and generates a type mismatch error. If the item is on the same page it finds it, but if it's a different page we get the error. Can someone help?
Thanks.
Option Explicit
Declare Sub Filename_Prompt(str as String)
Dim SearchString As String
Dim Page As String
Dim OfPages As String
Dim ReCheck As Variant
Dim StartPage as String
Dim PageCount As Integer
Dim wOK As Variant
Dim Prompt_Button As Long
Dim Prompt_Reply As String
Dim Err_Save As Long
Dim Timeout As Integer
Dim Sys as Object
Dim Sess as Object
Dim MyScreen as Object
Dim MyArea As Object
Sub Main
' Initialize
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
Filename_Prompt "Enter the text to search for"
Select Case Prompt_Button
Case 1
SearchString = Prompt_Reply
Case 2
GoTo EndMain
End Select
PageCount = 1
Sys.TimeoutValue = 30000
LookAgain:
'Look for the value on the current screen
Set MyArea = MyScreen.Search(SearchString)
'See if it found anything
If MyArea.Top <> -1 Then
'It did, so place the cursor on the spot
MyScreen.Row = MyArea.Top
MyScreen.Col = MyArea.Left
GoTo EndMain
Else
'See if there are page designations at the bottom of the screen
If MyScreen.GetString(24, 78, 1) <> "/" Then
'If there are pages, you must be on page 1
MyScreen.SendKeys "<PF23>"
MyScreen.WaitHostQuiet(50)
'Check again
If MyScreen.GetString(24, 78, 1) <> "/" Then GoTo NotFound
End If
'Get the pages and current page
Page = MyScreen.GetString(24, 76, 2)
OfPages = MyScreen.GetString(24, 79, 2)
If Page = StartPage Then GoTo NotFound
If Page = OfPages and StartPage = "01" Then Goto NotFound
If PageCount = 1 Then
StartPage = Page
End If
[highlight #EDD400]If Page = OfPages Then
MyScreen.SendKeys "<PF21>"
If Not MyScreen.WaitHostQuiet(50) Then Goto Problem
If MyScreen.GetString(24, 76, 2) <> "01" Then Goto Problem
Else[/highlight]
MyScreen.SendKeys "<PF22>"
If Not MyScreen.WaitHostQuiet(50) Then Goto Problem
If MyScreen.GetString(24, 76, 2) <> Format(Val(Page) + 1, "00") Then Goto Problem
End If
PageCount = PageCount + 1
GoTo LookAgain
End If
Exit Sub
Problem:
msgbox "A Problem has occurred. Execution will stop."
GoTo Endmain
NotFound:
msgbox "The string could not be found", 0
Endmain:
End Sub
Sub Filename_Prompt(str as String)
Begin Dialog Prompt_Dialog 184, 61, "Search"
Text 4, 3, 120, 34, str
TextBox 5, 42, 174, 13, .Reply
OkButton 130, 5, 50, 14
CancelButton 130, 23, 50, 14
End Dialog
Dim dlg As Prompt_Dialog
On Error Resume Next
Dialog dlg
If Err = 102 Then
Prompt_Button = 2 ' Cancel
Prompt_Reply = ""
Else
Prompt_Button = 1 ' OK
Prompt_Reply = dlg.Reply
End If
End Sub
Function ErrorCode() As Long
Select Case Err
Case 0 ' no error
Case 7 ' out of memory
ErrorCode = 1
Case 9 ' subscript out of range
ErrorCode = 5
Case 48 ' end of file
ErrorCode = 13
Case 52 ' bad file name or number
ErrorCode = 7
Case 53 ' file not found
ErrorCode = 3
Case 54 ' bad file mode
ErrorCode = 15
Case 55 ' file in use
ErrorCode = 19
Case 62 ' end of file
ErrorCode = 12
Case 63 ' bad record number
ErrorCode = 14
Case 32767 ' Nothing from Sessons.Open
ErrorCode = 18
Case 32766 ' FALSE from file transfer
ErrorCode = 30
Case Else
ErrorCode = 2
End Select
End Function
Thanks.
Option Explicit
Declare Sub Filename_Prompt(str as String)
Dim SearchString As String
Dim Page As String
Dim OfPages As String
Dim ReCheck As Variant
Dim StartPage as String
Dim PageCount As Integer
Dim wOK As Variant
Dim Prompt_Button As Long
Dim Prompt_Reply As String
Dim Err_Save As Long
Dim Timeout As Integer
Dim Sys as Object
Dim Sess as Object
Dim MyScreen as Object
Dim MyArea As Object
Sub Main
' Initialize
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
Filename_Prompt "Enter the text to search for"
Select Case Prompt_Button
Case 1
SearchString = Prompt_Reply
Case 2
GoTo EndMain
End Select
PageCount = 1
Sys.TimeoutValue = 30000
LookAgain:
'Look for the value on the current screen
Set MyArea = MyScreen.Search(SearchString)
'See if it found anything
If MyArea.Top <> -1 Then
'It did, so place the cursor on the spot
MyScreen.Row = MyArea.Top
MyScreen.Col = MyArea.Left
GoTo EndMain
Else
'See if there are page designations at the bottom of the screen
If MyScreen.GetString(24, 78, 1) <> "/" Then
'If there are pages, you must be on page 1
MyScreen.SendKeys "<PF23>"
MyScreen.WaitHostQuiet(50)
'Check again
If MyScreen.GetString(24, 78, 1) <> "/" Then GoTo NotFound
End If
'Get the pages and current page
Page = MyScreen.GetString(24, 76, 2)
OfPages = MyScreen.GetString(24, 79, 2)
If Page = StartPage Then GoTo NotFound
If Page = OfPages and StartPage = "01" Then Goto NotFound
If PageCount = 1 Then
StartPage = Page
End If
[highlight #EDD400]If Page = OfPages Then
MyScreen.SendKeys "<PF21>"
If Not MyScreen.WaitHostQuiet(50) Then Goto Problem
If MyScreen.GetString(24, 76, 2) <> "01" Then Goto Problem
Else[/highlight]
MyScreen.SendKeys "<PF22>"
If Not MyScreen.WaitHostQuiet(50) Then Goto Problem
If MyScreen.GetString(24, 76, 2) <> Format(Val(Page) + 1, "00") Then Goto Problem
End If
PageCount = PageCount + 1
GoTo LookAgain
End If
Exit Sub
Problem:
msgbox "A Problem has occurred. Execution will stop."
GoTo Endmain
NotFound:
msgbox "The string could not be found", 0
Endmain:
End Sub
Sub Filename_Prompt(str as String)
Begin Dialog Prompt_Dialog 184, 61, "Search"
Text 4, 3, 120, 34, str
TextBox 5, 42, 174, 13, .Reply
OkButton 130, 5, 50, 14
CancelButton 130, 23, 50, 14
End Dialog
Dim dlg As Prompt_Dialog
On Error Resume Next
Dialog dlg
If Err = 102 Then
Prompt_Button = 2 ' Cancel
Prompt_Reply = ""
Else
Prompt_Button = 1 ' OK
Prompt_Reply = dlg.Reply
End If
End Sub
Function ErrorCode() As Long
Select Case Err
Case 0 ' no error
Case 7 ' out of memory
ErrorCode = 1
Case 9 ' subscript out of range
ErrorCode = 5
Case 48 ' end of file
ErrorCode = 13
Case 52 ' bad file name or number
ErrorCode = 7
Case 53 ' file not found
ErrorCode = 3
Case 54 ' bad file mode
ErrorCode = 15
Case 55 ' file in use
ErrorCode = 19
Case 62 ' end of file
ErrorCode = 12
Case 63 ' bad record number
ErrorCode = 14
Case 32767 ' Nothing from Sessons.Open
ErrorCode = 18
Case 32766 ' FALSE from file transfer
ErrorCode = 30
Case Else
ErrorCode = 2
End Select
End Function