Technical support and scripting issues
Moderators: JRL, Dorian (MJT support)
-
Scones
- Junior Coder
- Posts: 32
- Joined: Fri Jul 05, 2019 11:21 am
Post
by Scones » Mon Nov 18, 2019 11:52 am
Hi.
I want to make a formula that does this:
If string contains "this text" then do this.
This is my line atm.
If>DesiredChange=Inside dim
I'm basically looking for something to replace the "=" so it isn't 100% equal. I just want to know if the text appears in the string.
I tried using the * that works on things like window titles, but it doesn't seem to work here
Will regex be necessary?
Thanks in advance!
-
Dorian (MJT support)
- Automation Wizard
- Posts: 1417
- Joined: Sun Nov 03, 2002 3:19 am
Post
by Dorian (MJT support) » Mon Nov 18, 2019 2:19 pm
Does something like the script below do what you need? It takes a string, in this case FishCatDog, and looks for Cat. If it finds Cat, it changes it to Horse. If it doesn't, nothing is changed.
Code: Select all
Let>MyString=FishCatDog
Pos>Cat,MyString,1,PosCat,
If>PosCat>1
StringReplace>MyString,Cat,Horse,MyString
Endif
MessageModal>MyString
-
PepsiHog
- Automation Wizard
- Posts: 517
- Joined: Wed Apr 08, 2009 4:19 pm
- Location: Florida
Post
by PepsiHog » Wed Nov 20, 2019 3:05 pm
@Scones,
Does this work for you?
Code: Select all
let>MyText=That darn cat keeps barking all night long.
let>FindThis=cat
RegEx>FindThis,MyText,0,match,nom,0
if>nom>0
RegEx>FindThis,MyText,0,match,nom,1,dog,res
endif
mdl>%res%
Do you not like RegEx? You can skin a cat, including this one, in many ways.
Good Luck,
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!