remy998,
was hoping to be able to do it with one search but I take it that is beyond attachmate
![[bigsmile] [bigsmile] [bigsmile]](/data/assets/smilies/bigsmile.gif)
Thankyou, two searches it may need to be but goodness that will be slow. the user said today that they think the owrd they will be looking for will be in upper case so are happy to type the word to find in upper case so may get away with one search but would like to run a check to make sure they have typed in upper case
I am building the code up one resolved problem at a time. Not sure which problem to tackle first. It could be to restrict the search area to be between rows 8 and 24, the next one will be to present the found information in a way that the user wants it. For now they will except it in a way my skill level can present it. I have pasted the whole code below in case it is useful for anyone.
smiler44
Global g_HostSettleTime%
Global g_szPassword$
dim totalpages as string ' total number of pages of notes
dim currentnote as INTEGER 'string ' current note
dim row as string ' row the searched for row is in
dim foundonpage as string
dim lwtf as string ' word to find before timmed to remove right spaces
dim wtf as string ' word to find one trimmed
Dim mycol as string
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions
If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 1000 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
' This section of code contains the woking code
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sess0.Screen.Sendkeys ("<Home>")
lwtf = Sess0.Screen.Getstring(1, 2, 6) ' location of the word to find
wtf = trim(lwtf) ' trims the missing spaces from the right
Sess0.Screen.Sendkeys ("<Home><Enter>")
Sess0.Screen.Sendkeys ("<Home><Enter>")
Sess0.Screen.Sendkeys("<ERASEEOF>")
Sess0.Screen.Sendkeys ("daj<Enter>")
Sess0.Screen.Sendkeys ("s<Home>")
Sess0.Screen.Sendkeys ("ln<enter>")
Sess0.Screen.Sendkeys ("s<enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
totalpages = Sess0.Screen.GetString(9, 72, 2) ' gets total number of pages
currentnote = Sess0.Screen.GetString(9, 65, 2) ' gets current page number
'foundonpage = currentnote
do until currentnote = 1
' This will find the location of the searched for word
Set MyArea = MyScreen.Search(wtf) 'finds first instance of word to find
MyScreen.MoveTo MyArea.Bottom, MyArea.Right ' if word is found place cursor by the word
if myscreen.col = 1 then ' word not found
Sess0.Screen.Sendkeys("<Home><Pf7>")
'foundonpage = currentnote
else
msgbox myscreen.row ' word found ' this is temporary, in time i will present this differently
Sess0.Screen.Sendkeys("<Home><Pf7>")
'currentnote = currentnote - 1
'foundonpage = currentnote
'msgbox foundonpage
end if
currentnote = Sess0.Screen.GetString(9, 65, 2)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
loop
System.TimeoutValue = OldSystemTimeout
msgbox "Finished"
End Sub