Hey guys,
How can I write an if statement to see if a variable CONTAINS a specific piece of text? It doesn't have to be equal to it, it just has to contain it. For example, the strings might all be numbers, but I only want to execute a command if the number contains a number 1 in it, so the number could be 1, 10, 14, 21, 101 etc.
Hope this makes sense
Kind regards,
Dominic Fichera
If "variable" contains specific text
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 82
- Joined: Mon Mar 24, 2014 12:15 pm
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: If "variable" contains specific text
Use the Position function. Like this:
Code: Select all
Pos>substring,variable,1,posText
If>posText>0
//variable contains substring
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?