×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Attachmate Search Macro

Attachmate Search Macro

Attachmate Search Macro

(OP)
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
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

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

RE: Attachmate Search Macro

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.

RE: Attachmate Search Macro

(OP)
Thanks for responding nyrtfleury14. Is there a list of new syntax or code for older scripts?

RE: Attachmate Search Macro

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close