Skip to main content

hello :D

it looks like im getting errors when trying to run a script which should look at some specific positions on my screen and check if it fits a lot of different names. if it fits it should jump one line down and look again until it finds one which doens't match and then copy it for later use. 

my code looks like this right now:


'for i = 11 to 16
emreadscreen status13,7,i,30
'if (status13 = "KONKMHL") or (status13 = "COGNINZ") or (status13 = "AAR26GS") or (status13 = "ARHKDEJ") or (status13 = "KOLKEVP") or (status13 = "PAKKJDA") or (status13 = "ARHKMAK") or (status13 = "VIBKJYF") or (status13 = "ARHKKSL") or (status13 = "ARHKMAD") or (status13 "PAKKLOO") or (status13 = "ARHKHEK") or (status13 = "KOLKGUG") or (status13 = "PAKKSUJ") or (status13 = "ARHKMBA") or (status13 = "ARCKJEK") or (status13 = "AUTO1HL") or (status13 = "AUTO1GR") then
'next i 
'else
'emreadscreen opret,7,i,30
'emsendkey "<PF3>"
'emsendkey "<PF3>"
'emsendkey "<PF9>"
'emsendkey "<PA2>"

 

is this totally wrong or is it even possible to do? 

 

can anybody help me to make this happen


#Rumba

hello :D

it looks like im getting errors when trying to run a script which should look at some specific positions on my screen and check if it fits a lot of different names. if it fits it should jump one line down and look again until it finds one which doens't match and then copy it for later use. 

my code looks like this right now:


'for i = 11 to 16
emreadscreen status13,7,i,30
'if (status13 = "KONKMHL") or (status13 = "COGNINZ") or (status13 = "AAR26GS") or (status13 = "ARHKDEJ") or (status13 = "KOLKEVP") or (status13 = "PAKKJDA") or (status13 = "ARHKMAK") or (status13 = "VIBKJYF") or (status13 = "ARHKKSL") or (status13 = "ARHKMAD") or (status13 "PAKKLOO") or (status13 = "ARHKHEK") or (status13 = "KOLKGUG") or (status13 = "PAKKSUJ") or (status13 = "ARHKMBA") or (status13 = "ARCKJEK") or (status13 = "AUTO1HL") or (status13 = "AUTO1GR") then
'next i 
'else
'emreadscreen opret,7,i,30
'emsendkey "<PF3>"
'emsendkey "<PF3>"
'emsendkey "<PF9>"
'emsendkey "<PA2>"

 

is this totally wrong or is it even possible to do? 

 

can anybody help me to make this happen


#Rumba

Hi besafe,

here are two methods of check the string against a set of know strings.

Sub Main
Dim MyArray(18) as String
MyArray(1)="KONKMHL"
MyArray(2)="COGNINZ"
MyArray(3)="AAR26GS"
MyArray(4)="ARHKDEJ"
MyArray(5)="KOLKEVP"
MyArray(6)="PAKKJDA"
MyArray(7)="ARHKMAK"
MyArray(8)="VIBKJYF"
MyArray(9)="ARHKKSL"
MyArray(10)="ARHKMAD"
MyArray(11)="PAKKLOO"
MyArray(12)="ARHKHEK"
MyArray(13)="KOLKGUG"
MyArray(14)="PAKKSUJ"
MyArray(15)="ARHKMBA"
MyArray(16)="ARCKJEK"
MyArray(17)="AUTO1HL"
MyArray(18)="AUTO1GR"

  for i = 11 to 16
     emreadscreen status13,7,i,30
    Select Case status13
    Case "KONKMHL"
      Msgbox "KONKMHL"
    Case "COGNINZ"
      Msgbox "COGNINZ"
    Case "AAR26GS"
      Msgbox "AAR26GS"
    Case "ARHKDEJ"
      Msgbox "ARHKDEJ"
    Case "KOLKEVP"
      Msgbox "KOLKEVP"
    Case "PAKKJDA"
      Msgbox "PAKKJDA"
    Case "ARHKMAK"
      Msgbox "ARHKMAK"
    Case "VIBKJYF"
      Msgbox "VIBKJYF"
    Case "ARHKKSL"
      Msgbox "ARHKKSL"
    Case "ARHKMAD"
      Msgbox "ARHKMAD"
    Case "PAKKLOO"
      Msgbox "PAKKLOO"
    Case "ARHKHEK"
      Msgbox "ARHKHEK"
    Case "KOLKGUG"
      Msgbox "KOLKGUG"
    Case "PAKKSUJ"
      Msgbox "PAKKSUJ"
    Case "ARHKMBA"
      Msgbox "ARHKMBA"
    Case "ARCKJEK"
      Msgbox "ARCKJEK"
    Case "AUTO1HL"
      Msgbox "AUTO1HL"
    Case "AUTO1GR"
      Msgbox "AUTO1GR"
    Case Else
      Msgbox "Not Found"
    End Select

    MyString = "KONKMHL,COGNINZ,AAR26GS,ARHKDEJ,KOLKEVP,PAKKJDA,ARHKMAK,VIBKJYF,ARHKKSL,ARHKMAD,PAKKLOO,ARHKHEK,KOLKGUG,PAKKSUJ,ARHKMBA,ARCKJEK,AUTO1HL,AUTO1GR"

    Found = (Instr(1, MyString, status13)-1)/8
    'Msgbox Found
    If Found>0 then
      Msgbox MyArray(Found 1)
    End If
  Next i

    'else
    'emreadscreen opret,7,i,30
    'emsendkey "<PF3>"
    'emsendkey "<PF3>"
    'emsendkey "<PF9>"
    'emsendkey "<PA2>"

End Sub

Tom


hello :D

it looks like im getting errors when trying to run a script which should look at some specific positions on my screen and check if it fits a lot of different names. if it fits it should jump one line down and look again until it finds one which doens't match and then copy it for later use. 

my code looks like this right now:


'for i = 11 to 16
emreadscreen status13,7,i,30
'if (status13 = "KONKMHL") or (status13 = "COGNINZ") or (status13 = "AAR26GS") or (status13 = "ARHKDEJ") or (status13 = "KOLKEVP") or (status13 = "PAKKJDA") or (status13 = "ARHKMAK") or (status13 = "VIBKJYF") or (status13 = "ARHKKSL") or (status13 = "ARHKMAD") or (status13 "PAKKLOO") or (status13 = "ARHKHEK") or (status13 = "KOLKGUG") or (status13 = "PAKKSUJ") or (status13 = "ARHKMBA") or (status13 = "ARCKJEK") or (status13 = "AUTO1HL") or (status13 = "AUTO1GR") then
'next i 
'else
'emreadscreen opret,7,i,30
'emsendkey "<PF3>"
'emsendkey "<PF3>"
'emsendkey "<PF9>"
'emsendkey "<PA2>"

 

is this totally wrong or is it even possible to do? 

 

can anybody help me to make this happen


#Rumba
hello Tom,

thanks at first for all the help you are giving me :D

however is it possible for you to explain some of the things that you are showing me

hello :D

it looks like im getting errors when trying to run a script which should look at some specific positions on my screen and check if it fits a lot of different names. if it fits it should jump one line down and look again until it finds one which doens't match and then copy it for later use. 

my code looks like this right now:


'for i = 11 to 16
emreadscreen status13,7,i,30
'if (status13 = "KONKMHL") or (status13 = "COGNINZ") or (status13 = "AAR26GS") or (status13 = "ARHKDEJ") or (status13 = "KOLKEVP") or (status13 = "PAKKJDA") or (status13 = "ARHKMAK") or (status13 = "VIBKJYF") or (status13 = "ARHKKSL") or (status13 = "ARHKMAD") or (status13 "PAKKLOO") or (status13 = "ARHKHEK") or (status13 = "KOLKGUG") or (status13 = "PAKKSUJ") or (status13 = "ARHKMBA") or (status13 = "ARCKJEK") or (status13 = "AUTO1HL") or (status13 = "AUTO1GR") then
'next i 
'else
'emreadscreen opret,7,i,30
'emsendkey "<PF3>"
'emsendkey "<PF3>"
'emsendkey "<PF9>"
'emsendkey "<PA2>"

 

is this totally wrong or is it even possible to do? 

 

can anybody help me to make this happen


#Rumba
hello again Tom,

with my script:
for i = 11 to 16
emreadscreen status13,7,i,30
if status13 = "KONKMHL" or "COGNINZ" or "AAR26GS" or "ARHKDEJ" or "KOLKEVP" or "PAKKJDA" or "ARHKMAK" or "VIBKJYF" or "ARHKKSL" or "ARHKMAD" or "PAKKLOO" or "ARHKHEK" or "KOLKGUG" or "PAKKSUJ" or "ARHKMBA" or "ARCKJEK" or "AUTO1HL" or "AUTO1GR" or "KOMPBKA" or "BALKSLO" then

else
emreadscreen opret,7,i,30
emsendkey "<PF3>"
emsendkey "<PF3>"
emsendkey "<PF9>"
emsendkey "<PA2>"

emsetcursor 9,2
emsendkey "r"
emsendkey "<enter>"
emsetcursor 6,8
emsendkey "b"
emsetcursor 6,24
emsendkey opret
emsendkey "<PF5>"
end if
next i

i really have to make sure that my script ain't saving a line which contains some of the words above, so i want the script to find a line which doens't contain one of the words but instead a completely different word and then save it, so i can use it on another page. it might be right what you showed my earlier however i cant really figure out what the different parts is doing

hello :D

it looks like im getting errors when trying to run a script which should look at some specific positions on my screen and check if it fits a lot of different names. if it fits it should jump one line down and look again until it finds one which doens't match and then copy it for later use. 

my code looks like this right now:


'for i = 11 to 16
emreadscreen status13,7,i,30
'if (status13 = "KONKMHL") or (status13 = "COGNINZ") or (status13 = "AAR26GS") or (status13 = "ARHKDEJ") or (status13 = "KOLKEVP") or (status13 = "PAKKJDA") or (status13 = "ARHKMAK") or (status13 = "VIBKJYF") or (status13 = "ARHKKSL") or (status13 = "ARHKMAD") or (status13 "PAKKLOO") or (status13 = "ARHKHEK") or (status13 = "KOLKGUG") or (status13 = "PAKKSUJ") or (status13 = "ARHKMBA") or (status13 = "ARCKJEK") or (status13 = "AUTO1HL") or (status13 = "AUTO1GR") then
'next i 
'else
'emreadscreen opret,7,i,30
'emsendkey "<PF3>"
'emsendkey "<PF3>"
'emsendkey "<PF9>"
'emsendkey "<PA2>"

 

is this totally wrong or is it even possible to do? 

 

can anybody help me to make this happen


#Rumba

TomFitz  Is using a long string of your keys to search within for the exact text coming from the screen

1. there is an assumption that the text to search are always 7 character - Not sure this is the correct restriction but as there is no Collection in this old VBA it will probably be OK as a solution

2. MyString is list of all your known keys separated by , aka XXX1234,YYY1234,ZZZ1234

3. Instr(1, MyString, status13) will search for your key coming from screen inside this long string list starting from the first position (1) response with 0 if there is no match or the position of the beginning of text that it found (1 based) --> let;'s call it FoundedPosition

4. Next FoundedPosition -1 will just move to zero based position

5. (FoundedPos -1 ) / 8 is the place of your string inside the long string (zero based) - 7 characters for the key plus 1 for the ","

6.  Found will now hold the position of the string - in our case 0 is KONKMHL, 1 is COGNINZ

7. If Found>=0 then ... end if    -- Note that you must check for >= and not just > as the first position is zero not 1 

8. To use this index to see what we found you can use MsgBox Mid(MyString, Found 1, 7)

9.Check that your last key does not have exact 7 characters so this will be a problem - just add spaces to be 7 chars exactly  , and padd your screen13 with spaces if the call does not do that 

Hope this helps 

PS. Moving to latest VBA will help you as we now supports VBA like Excel does - With better IDE and debug tools

 


hello :D

it looks like im getting errors when trying to run a script which should look at some specific positions on my screen and check if it fits a lot of different names. if it fits it should jump one line down and look again until it finds one which doens't match and then copy it for later use. 

my code looks like this right now:


'for i = 11 to 16
emreadscreen status13,7,i,30
'if (status13 = "KONKMHL") or (status13 = "COGNINZ") or (status13 = "AAR26GS") or (status13 = "ARHKDEJ") or (status13 = "KOLKEVP") or (status13 = "PAKKJDA") or (status13 = "ARHKMAK") or (status13 = "VIBKJYF") or (status13 = "ARHKKSL") or (status13 = "ARHKMAD") or (status13 "PAKKLOO") or (status13 = "ARHKHEK") or (status13 = "KOLKGUG") or (status13 = "PAKKSUJ") or (status13 = "ARHKMBA") or (status13 = "ARCKJEK") or (status13 = "AUTO1HL") or (status13 = "AUTO1GR") then
'next i 
'else
'emreadscreen opret,7,i,30
'emsendkey "<PF3>"
'emsendkey "<PF3>"
'emsendkey "<PF9>"
'emsendkey "<PA2>"

 

is this totally wrong or is it even possible to do? 

 

can anybody help me to make this happen


#Rumba
What Adi said !!!

So something like this besafe,

'Define a long comma separated string with all of the words you want to check against.
MyString = "KONKMHL,COGNINZ,AAR26GS,ARHKDEJ,KOLKEVP,PAKKJDA,ARHKMAK,VIBKJYF,ARHKKSL,ARHKMAD,PAKKLOO,ARHKHEK,KOLKGUG,PAKKSUJ,ARHKMBA,ARCKJEK,AUTO1HL,AUTO1GR,KOMPBKA,BALKSLO"
For i = 11 To 16
emreadscreen status13, 7, i, 30

'If your status13 appears anywhere in the log string, then the following will return the start position of status13 within the long string. If it's not in the long string, then you get a 0 (which is what you wish to trigger off).

If InStr(1, MyString, status13) = 0 Then

emreadscreen opret, 7, i, 30
emsendkey "<PF3>"
emsendkey "<PF3>"
emsendkey "<PF9>"
emsendkey "<PA2>"

emsetcursor 9, 2
emsendkey "r"
emsendkey "<enter>"
emsetcursor 6, 8
emsendkey "b"
emsetcursor 6, 24
emsendkey opret
emsendkey "<PF5>"
End If
Next i

So if say status13="COGNINZ", then the Instr call returns 9 which is not = 0 so the "if" is not true and you loop around to the next row.
If say status = "besafe1" then the InStr call will return 0 (as "besafe1 is not in the long string) so the "if" is true and the code will execute before looping around to the next row.

Note: It looks like your code is navigating to a different screen (I see <Enter> and multiple <PF>/<PA> keys being sent. I don't think you have your logic quite right, unless that final <PF5> brings you back to where you started, so you are ready to read the next line on the original screen and to check for the status13 at (i,30).

Also, I don't see any EMWaitxxx calls in there, it's likely that you will need to add wait logic so that after sending an Aid key (such are <Enter> or <PF2>, etc.) the macro waits for host to send the new screen and for the cursor to return and for the x-clock to clear.

Cheers,
Tom

hello :D

it looks like im getting errors when trying to run a script which should look at some specific positions on my screen and check if it fits a lot of different names. if it fits it should jump one line down and look again until it finds one which doens't match and then copy it for later use. 

my code looks like this right now:


'for i = 11 to 16
emreadscreen status13,7,i,30
'if (status13 = "KONKMHL") or (status13 = "COGNINZ") or (status13 = "AAR26GS") or (status13 = "ARHKDEJ") or (status13 = "KOLKEVP") or (status13 = "PAKKJDA") or (status13 = "ARHKMAK") or (status13 = "VIBKJYF") or (status13 = "ARHKKSL") or (status13 = "ARHKMAD") or (status13 "PAKKLOO") or (status13 = "ARHKHEK") or (status13 = "KOLKGUG") or (status13 = "PAKKSUJ") or (status13 = "ARHKMBA") or (status13 = "ARCKJEK") or (status13 = "AUTO1HL") or (status13 = "AUTO1GR") then
'next i 
'else
'emreadscreen opret,7,i,30
'emsendkey "<PF3>"
'emsendkey "<PF3>"
'emsendkey "<PF9>"
'emsendkey "<PA2>"

 

is this totally wrong or is it even possible to do? 

 

can anybody help me to make this happen


#Rumba
Hello :D

the <PF>/<PA> keys is jumping between screen however first when a new name is found and then it is jumping between the screens, i hadn't have any errors with doing this so far :D

hello :D

it looks like im getting errors when trying to run a script which should look at some specific positions on my screen and check if it fits a lot of different names. if it fits it should jump one line down and look again until it finds one which doens't match and then copy it for later use. 

my code looks like this right now:


'for i = 11 to 16
emreadscreen status13,7,i,30
'if (status13 = "KONKMHL") or (status13 = "COGNINZ") or (status13 = "AAR26GS") or (status13 = "ARHKDEJ") or (status13 = "KOLKEVP") or (status13 = "PAKKJDA") or (status13 = "ARHKMAK") or (status13 = "VIBKJYF") or (status13 = "ARHKKSL") or (status13 = "ARHKMAD") or (status13 "PAKKLOO") or (status13 = "ARHKHEK") or (status13 = "KOLKGUG") or (status13 = "PAKKSUJ") or (status13 = "ARHKMBA") or (status13 = "ARCKJEK") or (status13 = "AUTO1HL") or (status13 = "AUTO1GR") then
'next i 
'else
'emreadscreen opret,7,i,30
'emsendkey "<PF3>"
'emsendkey "<PF3>"
'emsendkey "<PF9>"
'emsendkey "<PA2>"

 

is this totally wrong or is it even possible to do? 

 

can anybody help me to make this happen


#Rumba
and again thank you so much for all the help you are giving me, i apreciate it so much :D