Skip to main content

Hello everyone,

 

Currently, the way I am writing the scripts is to check a whole row the required string in an IF statement and if it's not there go to the next IF statement.

While this definitely does work, i'm just wondering if there is a way to compress the code so I don't have a long list of IF statements.

I would just like to try to code more efficiently with less work if possible. 

 

For example in the below script. it checks 2 strings and if its there it puts a 2, if not it goes to the next IF statement to check the row below it and do the same

I have 10 different IF statements since there are 10 rows. 

Is there anyway to repeat the same IF statement, just move down a row?

Do
'Check to see if Tapes have EXP Status and if they are a CART3592A2
'If yes then Place 2

EMReadScreen MyString, 3, 13, 75
EMReadScreen SysString, 10, 13, 60
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor 13, 3
EMSendKey "2"
Else
End if

 

EMReadScreen MyString, 3, 14, 75
EMReadScreen SysString, 10, 14, 60
'If yes then Place 2
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor 14, 3
EMSendKey "2"
Else
End if

 

 

 

As always, thanks in advance!


#Rumba

Hello everyone,

 

Currently, the way I am writing the scripts is to check a whole row the required string in an IF statement and if it's not there go to the next IF statement.

While this definitely does work, i'm just wondering if there is a way to compress the code so I don't have a long list of IF statements.

I would just like to try to code more efficiently with less work if possible. 

 

For example in the below script. it checks 2 strings and if its there it puts a 2, if not it goes to the next IF statement to check the row below it and do the same

I have 10 different IF statements since there are 10 rows. 

Is there anyway to repeat the same IF statement, just move down a row?

Do
'Check to see if Tapes have EXP Status and if they are a CART3592A2
'If yes then Place 2

EMReadScreen MyString, 3, 13, 75
EMReadScreen SysString, 10, 13, 60
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor 13, 3
EMSendKey "2"
Else
End if

 

EMReadScreen MyString, 3, 14, 75
EMReadScreen SysString, 10, 14, 60
'If yes then Place 2
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor 14, 3
EMSendKey "2"
Else
End if

 

 

 

As always, thanks in advance!


#Rumba
Hi Erik,

glad to hear you got the Input box string match issue out of the way.

In terms to looping through each row of the screen, you could use an replace the "Do" loop with a "For" clause to handle that and replace the row number in your EM... calls with the index in your for loop

e.g.
Dim MyString as String, Dim SysString as String
Dim DontStop as Integer, i as Integer
For i = 13 to 24
EMReadScreen MyString, 3, i, 75
EMReadScreen SysString, 10, i, 60
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor i, 3
EMSendKey "2"
'Are you looking for only the first match? Then uncomment the following
'Exit For
End If
Next i

Does that make sense?

Tom

Hello everyone,

 

Currently, the way I am writing the scripts is to check a whole row the required string in an IF statement and if it's not there go to the next IF statement.

While this definitely does work, i'm just wondering if there is a way to compress the code so I don't have a long list of IF statements.

I would just like to try to code more efficiently with less work if possible. 

 

For example in the below script. it checks 2 strings and if its there it puts a 2, if not it goes to the next IF statement to check the row below it and do the same

I have 10 different IF statements since there are 10 rows. 

Is there anyway to repeat the same IF statement, just move down a row?

Do
'Check to see if Tapes have EXP Status and if they are a CART3592A2
'If yes then Place 2

EMReadScreen MyString, 3, 13, 75
EMReadScreen SysString, 10, 13, 60
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor 13, 3
EMSendKey "2"
Else
End if

 

EMReadScreen MyString, 3, 14, 75
EMReadScreen SysString, 10, 14, 60
'If yes then Place 2
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor 14, 3
EMSendKey "2"
Else
End if

 

 

 

As always, thanks in advance!


#Rumba
opps typo on line 1 of my code..

Remove the second Dim
i.e.
Dim MyString as String, SysString as String

Tom

Hello everyone,

 

Currently, the way I am writing the scripts is to check a whole row the required string in an IF statement and if it's not there go to the next IF statement.

While this definitely does work, i'm just wondering if there is a way to compress the code so I don't have a long list of IF statements.

I would just like to try to code more efficiently with less work if possible. 

 

For example in the below script. it checks 2 strings and if its there it puts a 2, if not it goes to the next IF statement to check the row below it and do the same

I have 10 different IF statements since there are 10 rows. 

Is there anyway to repeat the same IF statement, just move down a row?

Do
'Check to see if Tapes have EXP Status and if they are a CART3592A2
'If yes then Place 2

EMReadScreen MyString, 3, 13, 75
EMReadScreen SysString, 10, 13, 60
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor 13, 3
EMSendKey "2"
Else
End if

 

EMReadScreen MyString, 3, 14, 75
EMReadScreen SysString, 10, 14, 60
'If yes then Place 2
If UCase( MyString) = "EXP" and UCase(SysString) = "CART3592A2" then
EMSetCursor 14, 3
EMSendKey "2"
Else
End if

 

 

 

As always, thanks in advance!


#Rumba
That is perfect! I've never used a For clause and that's exactly what I needed!
Thanks Tom your amazing!