String Matching

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
OldGeek
Junior Coder
Posts: 21
Joined: Thu Oct 30, 2014 11:49 am
Location: Upstate NY, USA

String Matching

Post by OldGeek » Mon May 15, 2023 5:15 pm

I'm having trouble testing if two string variables match. Below is my code (sorry I know know how to embed this correctly)

// Testing String Matching

Let>IGNORESPACES=1
Let>VAREXPLICIT=1

Let>str_One=A
Let>str_Two=B
If str_One=str_Two
MessageModal>Method One Match
Else
MessageModel>No match with method one
EndIf

Let>str_One={"A"}
Let>str_Two={"B"}
If %str_One%=%str_Two%
MessageModal>Match Two Match
Else
MessageModel>No match with method two
EndIf
MS v15 | Windows 11 Pro | NY, USA

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: String Matching

Post by hagchr » Mon May 15, 2023 7:00 pm

Hi,

If --> if>
MessageModel --> MessageModal

Code: Select all

Let>IGNORESPACES=1
Let>VAREXPLICIT=1

Let>str_One=A
Let>str_Two=B

If>str_One=str_Two
MessageModal>Method One Match
Else
MessageModal>No match with method one
EndIf

Let>str_One={"A"}
Let>str_Two={"B"}

If>str_One=str_Two
MessageModal>Match Two Match
Else
MessageModal>No match with method two
EndIf

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

Re: String Matching

Post by Dorian (MJT support) » Mon May 15, 2023 7:00 pm

Two issues :

1. You forgot the chevron after If. So :

Code: Select all

If>
2. You had MessageModel twice instead of MessageModal

Code: Select all

Let>IGNORESPACES=1
Let>VAREXPLICIT=1
Let>str_One=A
Let>str_Two=B
If>str_One=str_Two
MessageModal>Method One Match
Else
MessageModal>No match with method one
EndIf
Let>str_One={"A"}
Let>str_Two={"B"}
If>%str_One%=%str_Two%
MessageModal>Match Two Match
Else
MessageModal>No match with method two
EndIf
To display code select your text and then click the fifth button along in the editor. the one that looks like this : </>
Yes, we have a Custom Scripting Service. Message me or go here

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

Re: String Matching

Post by Dorian (MJT support) » Mon May 15, 2023 7:01 pm

hagchr wrote:
Mon May 15, 2023 7:00 pm
Hi,

If --> if>
MessageModel --> MessageModal

Code: Select all

Let>IGNORESPACES=1
Let>VAREXPLICIT=1

Let>str_One=A
Let>str_Two=B

If>str_One=str_Two
MessageModal>Method One Match
Else
MessageModal>No match with method one
EndIf

Let>str_One={"A"}
Let>str_Two={"B"}

If>str_One=str_Two
MessageModal>Match Two Match
Else
MessageModal>No match with method two
EndIf
Snap! Two for the price of one. :D
Yes, we have a Custom Scripting Service. Message me or go here

OldGeek
Junior Coder
Posts: 21
Joined: Thu Oct 30, 2014 11:49 am
Location: Upstate NY, USA

Re: String Matching

Post by OldGeek » Tue May 16, 2023 11:00 am

Thank you everyone who kindly replied. You have no idea how long I stared at that small bit of code and didn't see the typos. I'm sure it would a huge undertaking to add syntax checking to the editor but, I miss that feature.
MS v15 | Windows 11 Pro | NY, USA

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

Re: String Matching

Post by Dorian (MJT support) » Tue May 16, 2023 11:19 am

If your command doesn't change colour, it's not been recognized. You should also see a little syntax helper at the bottom of the window. If you don't see that and/or it does not progress as you add parameters, then the command has not been recognized. Also once you type the first 3 letters of a command, it will make suggestions. Down arrow and enter will complete that for you.
Yes, we have a Custom Scripting Service. Message me or go here

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