×
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!
  • Students Click Here

*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

Jobs

Questions!

Questions!

Questions!

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

RE: Questions!

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: Why WAIT? Or how long should I WAIT?

http://docs.attachmate.com/reflection/14.x/prog-re...

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

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

RE: Questions!

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: Strategies for scraping in multiple screens.

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

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

RE: Questions!

“to input data into the fields”

Use PutString

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

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

RE: Questions!

Please post your code.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)

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.

RE: Questions!

The syntax is...

CODE

Sess0.Screen.PutString ("HK" & mtrnID, 4, 5) 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
There is syntax error..

RE: Questions!

What error message?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)


Sorry, I have to blank out some details.
The error is only "syntax error"

RE: Questions!

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

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

RE: Questions!

PutString functions without TAB!
http://docs.attachmate.com/extra/x-treme/apis/com/...

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

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

RE: Questions!

You’re saying that the field you intend to fill is row 4 column 5?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

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

RE: Questions!

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

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
Ehh.. Actually till now even after I removed <F13> on the code before that, Sess0.Screen.PutString ("HK" & mtrnID, 4, 5) still is syntax error.
The beetle will be removed if I put it as Sess0.Screen.PutString ("HK" & mtrnID), 4, 5

and yup, it will load that field where the cursor is.

RE: Questions!

Beats me!

BTW, I see no code to instantiate a SYSTEM object or a SESSION object.

???

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
Haha.. Okay, this is my full working code.

CODE -->

'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "C:\Users\S90103\Desktop\sebis_HK.edp"
' User: S90103 - 20190117
'--------------------------------------------------------------------------------

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

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 = 100     ' 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
    
    
' This section of code contains the recorded events
    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 = "SOMETHING" Then
        Sess0.Screen.SendKeys ("<Tab><Tab><Tab>0000000<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>")
    
    If crAcct = "123456789" Then                                                       
        Sess0.Screen.SendKeys ("<F13>7<Tab><Ctrl+M>")
    Else
        Sess0.Screen.SendKeys ("<Tab><Ctrl+M>")
    End If
    
    System.TimeoutValue = OldSystemTimeout
End Sub 

See if you can spot where's causing the problem. Thanks!

RE: Questions!

Ok, strip down your code after instantiating your system & session variables to one line of code...

CODE

Sess0.Screen.PutString "HK", 4, 5 
...and execute.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
it still input onto my cursor instead of the coordinates specified.

RE: Questions!

Please post this code.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
Which code?

RE: Questions!

Never mind. This makes no sense. It’s 1 AM. I’m going to bed.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
Haha, alright. Good night! :)

RE: Questions!

(OP)
Next question!

How do I read external files? (Eg. txt file)

sample 1
to scan sample 1 2nd column data downwards with a variable to match string

sample 2
if found matching string.. in sample 2, copy the string after delimiter ':'
and put into a variable

can it be done?

BR
kzhkr

RE: Questions!

My mission was mostly to get data from the mainframe and send it to a user that requested it. Since they usually sent me a list of key values in an Excel workbook and my data went back to them in a workbook and since the Extra!VB editor was so pitiful (I’d rather drive a Lexis than a Yugo) I did ALL my coding in the Excel VBA editor.

Consequently, your text file would simply be IMPORTED into an Excel sheet via Data > Get external data... where it would be parsed into columns using a specified delimiter.

Then it’s merely looping through the desired column...

CODE

For Each r In rng
   ‘Do something with r.Value
Next 

Of course you could Open the text file, loop thru it and grab the part of the text string that you want in Extra!VB. To me, that would be an unwanted chore.

Things are a LOT easier to do in Excel VBA! The editor has many features that can help you.

What do you intend to do with the data from these two text files?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
Hi,

Will there by any speed difference when accessing excel or text file? If not I also believe excel will be a better choice in organizing the list.

will be doing string comparison in SEBIS with the file sample 1, if found matching string will go ahead to open file sample 2 to look for same name and copy the string beside the matched name back into SEBIS.

Br
kzhkr

RE: Questions!

Ok, help me out. Please explain what you’re doing process wise as if this were a manual process using the computer to store your data. I just looked up SEBIS and know its some sort of document management system. Is SEBIS what’s in the mainframe?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
Hi,

Okay..

I can't show you what's on my attachmate screen due to sensitive information.

1. I will key in a "Register number" to process the entry.
2. After which I will cross reference Field 52 (11, 62) (Eg. BOFUSESS) with sample 1 database.
2a. If YES, proceed with cross referencing with sample 2 database and find correspondent partner which is after the delimiter ":". (Eg. BOFUSESS:ABCDHKHH)
2b. If NO, proceed with processing.
3. Copy ABCDHKHH and paste into Attachmate screen Field 53 (14, 66).

That will be the manual processing steps I will do.

Hope it helps, thank you!

Regards,
kzhkr

RE: Questions!

Why are you keying in anything? Isn’t this to be an automated process?

“After which I will cross reference Field 52 (11, 62) (Eg. BOFUSESS) with sample 1 database.”
Couldn’t that a lookup in Excel?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
Apparently I have tried running the lookup with Excel on my colleagues' computer but it didn't run well.
So looking at using text file as alternative.

Now waiting for the files to be sent to me for trying..

:D

RE: Questions!

Either your missing something or I am but lookups are pretty easy.

Do you not have Excel on your PC?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Questions!

(OP)
I do have but different computers, their Excel behave differently. Like I just tried my macro in excel on my colleague's computer to run Attachmate, it just hanged there while mine was running smoothly.

Was advised by my IT dept to run the macro via Attachmate instead.

So..... can I check how do I open the excel/text file for referencing via Attachmate? bigsmile

RE: Questions!

Well since I don’t see the macro in question, I cannot comment. It often depends HOW you write your macros. I write mine with the intentbto run on anybody’s Excel (with available versions in mind). Our IT managed the versions in use within a band that all users could exchange data.

Regarding the question of reading text files, you just open using native VB. In a loop you read or input one record at a time, inspect it, do something or not and on the the next.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

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