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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Questions!

Status
Not open for further replies.

kzhkr

Technical User
Dec 11, 2018
25
SE
Hello,

Not sure if it's a norm to create different threads for different questions but thought I would consolidate my queries under this thread.

Q1. WaitForCursor
would like to check for this 2 codes below
Code:
        Sess0.Screen.SendKeys ("<Enter>")
        Do Until Sess0.Screen.WaitForCursor(23, 9)
            Sess0.Screen.SendKeys ("<Enter>")
        Loop
and
Code:
        Sess0.Screen.SendKeys ("<Tab>")
        Do Until Sess0.Screen.WaitForCursor(23, 9)
            Sess0.Screen.SendKeys ("<Tab>")
        Loop

So far I could only make the first code with <Enter> works but not the code with <Tab>, it will always overshot the coordinates I specify, may I know what could be the cause?

Q2. <Tab>-ing
Is there another method to specify the cursor to move to a desired coordinates besides using <Tab>? As I need the cursor to always go to the same field in any different scenario. I have tried MoveTo and it won't work (unless there's a certain setting which I am missing).

Thanks in advance!

Br
kzhkr
 
Hi,

This is an asynchronous process. You must SEND a command to a remote computer and you must determine when the remote computer has completed its process. Using WaitForCursor is one way to determine if the remote computer is done. After sending the command ONE TIME, your code must WAIT in a loop until the cursor reappears at the screen rest coordinates. At that time the WaitForCursor expression becomes TRUE.

Assuming that the screen rest coordinates are 23, 9:
Code:
‘
   Sess0.Screen.SendKeys ("<Enter>")     ‘one time command
   Do Until Sess0.Screen.WaitForCursor(23, 9)
       DoEvents
   Loop
faq99-7887


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
So.. my DoEvents is to tab through the field until the cursor rest on (23, 9) but everytime it overshot it.

And MoveTo does not work on my EXTRA! attachmate, is there alternative method to tab to specific coordinates if WaitForCursor does not work with <tab>?

Thanks

kzhkr
 
You must think out of the box of a user sitting at a terminal and tabbing through the screen.

Every point (row, column coordinate) is at your command by either GetString, PutString or Area. Back ten years ago when I was doing this regularly, I’d grab the entire screen from 1,1 to 24,80 using Area and assign every field to an array variable and write that array to a table in Excel that described the entire screen.

Never ever TABBED via code! Don't need to! You can grab a single piece of data off each screen, all data or anything in between.

Check out faq99-7950.

BTW, if you were to TAB to a cell, that in only one third of the data you need to grab data. You need the LENGTH of the field and the TYPE of data (character or number). The FAQ I posted gives you a suggestion about that.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Understood. But maybe I missed out an important point..

The tabbings are for me to input data into the fields
and will execute the codes in Attachmate itself.

Thanks

kzhkr
 
“to input data into the fields”

Use PutString

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
It doesn't work unless my cursor is at that field. If it should work, is there any settings I have to do in order for it to work?
 
Please post your code.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Code:
Sub Main()    
    Dim mtrnStart As Long
    Dim reaCode As Long
    Dim mtrnID As String
    Dim crDate As String
    Dim crDate2 As String
    Dim remitID As String
    Dim crAcct As String
    Dim valDate As String
    Dim valDate2 As String
    
    DisableKeystrokeProductivity = True
    DisableScreenHistory = True
    
    mtrnStart = InputBox("MTRN number:")
    reaCode = InputBox("Reason code:")                                                                      ' Credit date
    
    Sess0.Screen.SendKeys (mtrnStart)
    Sess0.Screen.SendKeys ("<Enter>")
    
' Screen check
    Sess0.Screen.WaitForString "MTRN/Rep.ID:", 3, 1
    
    Sess0.Screen.SendKeys ("<Enter><Enter><Enter><Enter><Enter>")    
      
    crAcct = Trim(Sess0.Screen.GetString(5, 52, 8))
    valDate = Format(Date, "ddmmyy")
    valDate2 = Format(Date, "yymmdd")
    crDate = Format(Trim(Sess0.Screen.GetString(6, 32, 8)), "ddmmyy")
    crDate2 = Format(Trim(Sess0.Screen.GetString(6, 32, 8)), "yymmdd")    
    
    If crDate2 > valDate2 Then
        valDate = crDate
    End If
    
    remitID = Trim(Sess0.Screen.GetString(9, 15, 8))
    mtrnID = Trim(Sess0.Screen.GetString(3, 13, 11))
    
    Sess0.Screen.SendKeys ("CHG<Ctrl+M><Tab><Tab><F13>")
    Sess0.Screen.SendKeys ("HK" & mtrnID)                                             ' MTRN Ref.
    
    If remitID = "SCBLHKHH" Then
        Sess0.Screen.SendKeys ("<Tab><Tab><Tab>N01800126<Tab>")
    Else
        Sess0.Screen.SendKeys ("<Tab><Tab><Tab><Tab>")
    End If
    
    Sess0.Screen.SendKeys (reaCode)
    Sess0.Screen.SendKeys ("<Tab><Tab><Tab><Tab>")
    Sess0.Screen.SendKeys (reaCode)
    Sess0.Screen.SendKeys ("<Tab><Tab>")
    Sess0.Screen.SendKeys (valDate)    
    Sess0.Screen.SendKeys ("<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab>")
End Sub

This is my current working code. If I replace Sess0.Screen.SendKeys ("HK" & mtrnID) with Sess0.Screen.PutString ("HK" & mtrnID), 4, 5 and removing the line before this, it won't work.
 
The syntax is...
Code:
Sess0.Screen.PutString ("HK" & mtrnID, 4, 5)

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
What error message?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
attachmate_error_ojeiid.jpg


Sorry, I have to blank out some details.
The error is only "syntax error
 
The statement before...
Code:
Sess0.Screen.SendKeys ("CHG<Ctrl+M><Tab><Tab><F13>")
...the F13 command will kick off a process on the remote mainframe computer. Your line of code that errors is trying to write to the screen while the screen is INOPERABLE, waiting for the mainframe to complete the F13 process!

After each SendKeys that kicks off the mainframe, you must have a WaitFor??? Loop!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Ehh... Means after every <Enter>, <Tab> , <F13> etc I have to do a WaitForCursor Loop? [spin2]
F13 is a command for clearing field so I think it's unavoidable and F13 should be instantaneous.

So... correct me if I'm wrong. I can actually use PutString without doing any tabbing in the screen?
 
PutString functions without TAB!

FYI, any Key sequence that causes the mainframe to process requires a WAIT until the asynchronous process completes.

If the Key sequence merely manipulates the screen, like TAB or CLEAR, no WAIT is required.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Removed the <F13> also still have the syntax error.

And tried using the code in the example you linked, it will only PutString "Hello" on the line my cursor is.
It won't specifically go to the coordinates I assigned.
 
You’re saying that the field you intend to fill is row 4 column 5?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Yup, that's right. So unless my cursor is there, it will not input anything. (Eg. My cursor is currently at 3,13, the string will be put at 3,13 instead of 4,5)
Is there any setting to disable/enable for the string to be place anywhere in the screen and not based on where the cursor is?

 
So if your cursor is at 4,5 then [tt]Sess0.Screen.PutString ("HK" & mtrnID, 4, 5)[/tt] will load that field?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top