Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attachmate Search Macro

Status
Not open for further replies.

lisvard

IS-IT--Management
Feb 22, 2000
5
0
0
US
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
 
If it is finding it on the same page, but not any other pages, then my thought is that your language in the section for going to the next page is outdated for the attachmate version you upgraded to. As I understand it, there are subtle changes in the language attachmate 'understands' as you upgrade. It is probably as simple as changing one term or function, but I think that is the most help I can give without fully understanding and watching it run/attempt to run.
 
Thanks for responding nyrtfleury14. Is there a list of new syntax or code for older scripts?
 
I am not sure. I am actually having the same issue with someone who is using an upgraded version of attachmate. One snippet of the macro is causing a problem and it is because of the wording not being recognized by the upgraded version. I haven't been able to find any list of changes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top