Hi,
I am trying to see if a variable contains an hyphen. I am sure this is a very simple question; I simply can't get the hyphen to be recognized as a string. Below is my code:
Let>hyphen=-
//Check if variable contains "-"
Pos>hyphen,accountname,1,posText
If>posText>0
//variable contains substring
//close the window
MouseMove>1257,3
LClick
setfocus>Account Locate*
//click in results box
Press Down
Press Enter
Goto>verify
Endif
This works for other characters, for example if I say hyphen=R. Just wondering the syntax for making the hyphen string?
Thank you, and apologies for this beginner question. [snippet=][/snippet]
Hyphen as A String in a Variable??
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1416
- Joined: Sun Nov 03, 2002 3:19 am
Re: Hyphen as A String in a Variable??
That does work. My guess is maybe that accountname doesn't exist or doesn't contain a hyphen? If we make sure it exists and contains a hyphen we can see the code works.
Both of these work :
Both of these work :
Code: Select all
Let>accountname=qwerty-uiop
Let>hyphen=-
//Check if variable contains "-"
Pos>hyphen,accountname,1,posText
If>posText>0
MDL>I see it!
Endif
Code: Select all
Let>accountname=qwerty-uiop
//Check if variable contains "-"
Pos>-,accountname,1,posText
If>posText>0
MDL>I see it again!
Endif
Re: Hyphen as A String in a Variable??
This ended up working, thank you!