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 SkipVought 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
0
0
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
 
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.
 
Beats me!

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

???


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
 
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!
 
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,
[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 still input onto my cursor instead of the coordinates specified.
 
Please post this 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
 
Never mind. This makes no sense. It’s 1 AM. I’m going to bed.

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
 
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

 
 https://files.engineering.com/getfile.aspx?folder=6f3bd38e-65dd-4984-be49-739fdbbf764b&file=sample.zip
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,
[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
 
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
 
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,
[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
 
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
 
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,
[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
 
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
 
Either your missing something or I am but lookups are pretty easy.

Do you not have Excel on your PC?

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
 
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]
 
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,
[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