Hyphen as A String in a Variable??

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
CGooley
Newbie
Posts: 17
Joined: Tue Jun 25, 2019 6:13 pm

Hyphen as A String in a Variable??

Post by CGooley » Tue Jun 25, 2019 6:20 pm

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]

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Hyphen as A String in a Variable??

Post by Dorian (MJT support) » Wed Jun 26, 2019 9:56 am

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 :

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
Yes, we have a Custom Scripting Service. Message me or go here

CGooley
Newbie
Posts: 17
Joined: Tue Jun 25, 2019 6:13 pm

Re: Hyphen as A String in a Variable??

Post by CGooley » Wed Jun 26, 2019 6:23 pm

This ended up working, thank you!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts