So, now the script works, but not as intended
My problem was to differ popups with a similar title of each other. I did this with strings which were typical for the searched popup. But somehow it recognizes always the same popup with the string "will be cut off" in it. First I thought it does not work in this way, because the wrong answer was the first. But after exchanging the check it still doesn't work.
Don't bother about the code, it is a slightly modified copy of the same commands, so the basic routine is simple and there are many comments, so it is grown to 100 lines.
I made another comprimised version which is below, only with commands and without comments, which is half the length
//sets the loopvalue to 0
let>popuploop=0
//Start of the Popup-detection-Loop
Label>popups
//sets the values of the variables to 1
let>timeout=1
let>flash=1
let>ident=1
let>hardware=1
let>cutoff=1
//set focus to HMI
setfocus>HMI600*
//if window "Test configuration time" is open, goto check off
IfWindowOpen>Test configuration time,configtime
//Detect if another Popup is open
IfWindowOpen>HMI600
//Gets the text of the popup (GetWindowText>WINDOWTITLE,RESULT_VARIABLE)
GetWindowText>HMI600,popup
//Lower the string to prevent failures
Let>popup={Lower(%popup%)}
//Returns the absolut Position of the start of a substring in a string
//position>"KEYWORD",%STRING%,START_POSITION,RESULT_VARIABLE,FALSE=ABSOLUTE_RESULT
position>"nonvolantile flash memory",%popup%,1,flash,FALSE
//check for timeout and goto close popup if it is contained
if>flash>0,closeflash
//Returns the absolut position of the start of a substring in a string
//position>"KEYWORD",%STRING%,START_POSITION,RESULT_VARIABLE,FALSE=ABSOLUTE_RESULT
position>"will be cut off",%popup%,1,cutoff,FALSE
//check for timeout and goto targeterror if it is contained
if>timeout>0,cutoff
//Returns the absolut Position of the start of a substring in a string
//position>"KEYWORD",%STRING%,START_POSITION,RESULT_VARIABLE,FALSE=ABSOLUTE_RESULT
position>"equipment identification is not",%popup%,1,ident,FALSE
//check for timeout and goto close popup if it is contained
if>ident>0,closeident
//Returns the absolut Position of the start of a substring in a string
//position>"KEYWORD",%STRING%,START_POSITION,RESULT_VARIABLE,FALSE=ABSOLUTE_RESULT
position>"communication timeout",%popup%,1,hardware,FALSE
//check for timeout and goto close popup if it is contained
if>hardware>0,harwareErr
//no detection possible
goto>otherpopup
Else
wait>1
let>popuploop=popuploop+1
//if done loop 90 times, proceed
if>popuploop=90,proceedpopup
goto>popups
Endif
goto>popups
let>popuploop=0
Label>popups
let>timeout=1
let>flash=1
let>ident=1
let>hardware=1
let>cutoff=1
setfocus>HMI600*
IfWindowOpen>Test configuration time,configtime
IfWindowOpen>HMI600
GetWindowText>HMI600,popup
Let>popup={Lower(%popup%)}
position>"nonvolantile flash memory",%popup%,1,flash,FALSE
if>flash>0,closeflash
position>"will be cut off",%popup%,1,cutoff,FALSE
if>timeout>0,cutoff
position>"equipment identification is not",%popup%,1,ident,FALSE
if>ident>0,closeident
position>"communication timeout",%popup%,1,hardware,FALSE
if>hardware>0,harwareErr
goto>otherpopup
Else
wait>1
let>popuploop=popuploop+1
if>popuploop=90,proceedpopup
goto>popups
Endif
goto>popups
Label>hardwareErr
Messagemodal>Hardware Error
goto>end
Label>cutoff
Messagemodal>link cutoff
goto>popups
Label>closeflash
let>popuploop=80
Messagemodal>closeflash
goto>popups
Label>closeident
Messagemodal>closeident
goto>popups
Label>configtime
Messagemodal>configtime
goto>popups
Label>otherpopup
Messagemodal>The failure could not be detected, pleas check HMI manually
goto>end
Label>proceedpopup
Messagemodal>finished checkin popups
Label>end
*edit* Now I found one bug, this shows me that there has to be a fundamental error in my string handling.
To show the problematic case, a little simple example-code:
setfocus>HMI600*
//Detect if another Popup is open
IfWindowOpen>HMI600
Label>popups
//if window "Test configuration time" is open, goto check off
IfWindowOpen>Test configuration time,configtime
//Gets the text of the popup (GetWindowText>WINDOWTITLE,RESULT_VARIABLE)
GetWindowText>HMI600,popup
//Lower the string to prevent failures
Let>popup={Lower(%popup%)}
//Returns the absolut Position of the start of a substring in a string
//position>"KEYWORD",%STRING%,START_POSITION,RESULT_VARIABLE,FALSE=ABSOLUTE_RESULT
position>"nonvolatile flash memory",%popup%,1,flash,FALSE
//check for timeout and goto close popup if it is contained
if>flash>0,closeflash
Else
wait>1
let>popuploop=popuploop+1
//if done loop 90 times, proceed
if>popuploop=90,proceedpopup
goto>popups
Endif
goto>popups
Label>closeflash
//set popuploop variable to 10 runs left
let>popuploop=80
let>flash=0
Messagemodal>closeflash
//proceed with popupcheck
goto>popups
Label>end
String handling
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 58
- Joined: Mon Jun 27, 2005 7:03 am
- Location: Switzerland
-
- Pro Scripter
- Posts: 58
- Joined: Mon Jun 27, 2005 7:03 am
- Location: Switzerland
-
- Pro Scripter
- Posts: 58
- Joined: Mon Jun 27, 2005 7:03 am
- Location: Switzerland
I found the error by playing with the code, this is the good news. But the bad is: It is not documented.
when you have the function
popup=blabla will be cut off blabla
position>"will be cut off",%popup%,1,timeout,FALSE
after the execution timeout=0
it will only give back a result
///////////////////////////////////////
if the variable, you search in is:
popup=will be cut off
position>"will be cut off",%popup%,1,timeout,FALSE
after the execution timeout=1
EG an exact match
///////////////////////////////////////
but when you use:
popup=blabla will be cut off blabla
position>will be cut off,%popup%,1,timeout,FALSE
after the execution timeout=8
it does the mentioned thing.
///////////////////////////////////////
If you use a special sign in it, it searches as mentioned:
popup=blabla will be @ cut off blabla
position>"will be @ cut off frequency",%popup%,1,timeout,FALSE
after the execution timeout=8
when you have the function
popup=blabla will be cut off blabla
position>"will be cut off",%popup%,1,timeout,FALSE
after the execution timeout=0
it will only give back a result
///////////////////////////////////////
if the variable, you search in is:
popup=will be cut off
position>"will be cut off",%popup%,1,timeout,FALSE
after the execution timeout=1
EG an exact match
///////////////////////////////////////
but when you use:
popup=blabla will be cut off blabla
position>will be cut off,%popup%,1,timeout,FALSE
after the execution timeout=8
it does the mentioned thing.
///////////////////////////////////////
If you use a special sign in it, it searches as mentioned:
popup=blabla will be @ cut off blabla
position>"will be @ cut off frequency",%popup%,1,timeout,FALSE
after the execution timeout=8
Last edited by Hardware_Tester on Thu Nov 17, 2005 8:24 am, edited 2 times in total.
I didn't understand a word of that. Position returns the index of the position of the substring in a string. It tells you where that substring starts in the given string.
MJT Net Support
[email protected]
[email protected]
-
- Pro Scripter
- Posts: 58
- Joined: Mon Jun 27, 2005 7:03 am
- Location: Switzerland
No, sorry, Ich habe keinen blassen schimmer. I have read your previous message and it is all wrong. I think you do not understand what Position is supposed to do because your expectations appear to be wrong. Or I am still misunderstanding you. Please try this script. I have tested it with your data and it works correctly:
Let>popup=blabla will be cut off blabla
position>"will be cut off",popup,1,timeout,FALSE
//Shoule be ZERO becuse "will be cut off" does NOT appear in blabla will be cut off blabla
MessageModal>timeout
Let>popup=will be cut off
position>"will be cut off",popup,1,timeout,FALSE
//Should be ZERO because "will be cut off" does not appear in will be cut off
MessageModal>timeout
Let>popup=blabla will be cut off blabla
position>will be cut off,popup,1,timeout,FALSE
//Should be 8 because will be cut off starts at position 8 in blabla will be cut off blabla
MessageModal>timeout
Let>popup=blabla will be @ cut off blabla
position>"will be @ cut off frequency",popup,1,timeout,FALSE
//Should be 0 because substring does not appear in string
MessageModal>timeout
Results are correct and as expected.
1. "will be cut off" does NOT appear in blabla will be cut off blabla, so result is zero
2. "will be cut off" does NOT appear in will be cut off, so the result is zero.
3. will be cut off starts at position 8 in blabla will be cut off blabla
4. "will be @ cut off frequency" does NOT appear in blabla will be @ cut off blabla, so result is zero.
Position returns the index of the position of a substring in a string. It looks for substring in string and returns the starting position of that substring in the string. "will be cut off" is NOT a substring of blabla will be cut off blabla, so result is zero. But will be cut off IS a substring and starts at character number 8 in blabla will be cut off blabla.
If you run the script above you will see the correct results are reported.
Let>popup=blabla will be cut off blabla
position>"will be cut off",popup,1,timeout,FALSE
//Shoule be ZERO becuse "will be cut off" does NOT appear in blabla will be cut off blabla
MessageModal>timeout
Let>popup=will be cut off
position>"will be cut off",popup,1,timeout,FALSE
//Should be ZERO because "will be cut off" does not appear in will be cut off
MessageModal>timeout
Let>popup=blabla will be cut off blabla
position>will be cut off,popup,1,timeout,FALSE
//Should be 8 because will be cut off starts at position 8 in blabla will be cut off blabla
MessageModal>timeout
Let>popup=blabla will be @ cut off blabla
position>"will be @ cut off frequency",popup,1,timeout,FALSE
//Should be 0 because substring does not appear in string
MessageModal>timeout
Results are correct and as expected.
1. "will be cut off" does NOT appear in blabla will be cut off blabla, so result is zero
2. "will be cut off" does NOT appear in will be cut off, so the result is zero.
3. will be cut off starts at position 8 in blabla will be cut off blabla
4. "will be @ cut off frequency" does NOT appear in blabla will be @ cut off blabla, so result is zero.
Position returns the index of the position of a substring in a string. It looks for substring in string and returns the starting position of that substring in the string. "will be cut off" is NOT a substring of blabla will be cut off blabla, so result is zero. But will be cut off IS a substring and starts at character number 8 in blabla will be cut off blabla.
If you run the script above you will see the correct results are reported.
MJT Net Support
[email protected]
[email protected]
-
- Pro Scripter
- Posts: 58
- Joined: Mon Jun 27, 2005 7:03 am
- Location: Switzerland
Quotes are needed in VBEval and Complex Expressions. VBScript expects strings in quotes. Complex Expressions need strings in quotes so that it can differentiate between strings and numbers and variables.
Pos is a complex expression function
Position is a native Macro Scheduler function.
Pos is a complex expression function
Position is a native Macro Scheduler function.
MJT Net Support
[email protected]
[email protected]