Hello everyone,
So while I have been able to use both FOR statements and DO loops successfully, I can't seem to combine them to get my required outcome.
Here is my current script I am using:
Sub Main
Dim RetC as Integer, SEQ as String, JOB as String, NUM as String
EMConnect "A"
SysHide "Timer"
For i = 7 to 20
EMReadScreen SEQ, 3, i, 2
EMReadScreen JOB, 6, i, 7
EMReadScreen NUM, 6, i, 49
If UCase(SEQ) = "110" and UCase(JOB) = "MER - " and UCase(NUM) = "686-32" then
EMSetCursor i, 2
EMWaitX 1, RetC
EMSendkey "215"
EMWaitX 1, RetC
Exit for
Exit Sub
Else
End if
Next i
End Sub
To break it down, I am searching for 3 declared strings and when I do find it, replace number 110 to 215.
The issue I am having, is that I cannot get it to Page Down and continue searching without getting continuous errors and having to force close the script editor.
I have tried wrapping everything in a DO loop, so I can add in the Page Down until it finds it, but while it changes the number from 110 to 215, the script wants to keep running.
Please tell me if i'm missing something or doing something wrong.
Maybe have things in the wrong spot?
Here is how I have it in the DO loop:
Sub Main
Dim RetC as Integer, SEQ as String, JOB as String, NUM as String
EMConnect "A"
SysHide "Timer"
Do
For i = 7 to 20
EMReadScreen SEQ, 3, i, 2
EMReadScreen JOB, 6, i, 7
EMReadScreen NUM, 6, i, 49
If UCase(SEQ) = "110" and UCase(JOB) = "MER - " and UCase(NUM) = "686-32" then
EMSetCursor i, 2
EMWaitX 1, RetC
EMSendkey "215"
EMWaitX 1, RetC
Exit for
Exit Do
Else
End if
Next i
EMSendkey "<PAGE_DOWN>"
EMReadScreen SEQ, 3, i, 2
If UCase(SEQ) = "215" then
Print "Changed SEQ Successfully"
Exit Do
Else
End if
Loop
End Sub
Thank you.
#Rumba