Return partial variables within string

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Tienytne
Newbie
Posts: 1
Joined: Fri Jun 07, 2019 12:26 pm

Return partial variables within string

Post by Tienytne » Fri Jun 07, 2019 12:36 pm

Hello, I'm trying to create a variable using the text image finder.

The text finder will return a string value of "11/22/33", but I want the numeric values to be placed in its own variable.
ie. x = 11, y = 22, z = 33

Going through the functions it seems RegEx would be the best command for this task? Currently looking through and figuring out how the easy pattern syntax works for this.

Thanks

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

Re: Return partial variables within string

Post by Dorian (MJT support) » Mon Jun 10, 2019 10:21 pm

Or you could use the Separate command, and separate by /
Always accepting custom script commissions. Message me or go here

User avatar
PepsiHog
Automation Wizard
Posts: 395
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Return partial variables within string

Post by PepsiHog » Sun Jun 16, 2019 12:35 am

Hello Tienytne,

Here is one way you can do it with RegEx.

Code: Select all

 let>nDate=11/22/33

RegEx>(\d\d?).(\d\d?).(\d\d?),nDate,0,match,nom,1,nx=$1;ny=$2;nz=$3,Result

StringReplace>Result,;,crlf,Result
StringReplace>Result,n,let>,Result

IncludeFromVar>Result

mdl>%x%/%y%/%z%
Hope this helps.
PepsiHog
MS v14 Windows 10

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2018) 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!

User avatar
PepsiHog
Automation Wizard
Posts: 395
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Return partial variables within string

Post by PepsiHog » Tue Jun 18, 2019 9:58 pm

Here is a more simplistic form of the above.

Code: Select all

let>nDate=11/22/33
RegEx>(\d\d?).(\d\d?).(\d\d?),nDate,0,match,nom,1,$1,x
RegEx>(\d\d?).(\d\d?).(\d\d?),nDate,0,match,nom,1,$2,y
RegEx>(\d\d?).(\d\d?).(\d\d?),nDate,0,match,nom,1,$3,z

mdl>%x%/%y%/%z%
MS v14 Windows 10

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2018) 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!

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

Re: Return partial variables within string

Post by CGooley » Fri Jun 28, 2019 6:06 pm

If ndate was separated by spaces instead of "/", how would I handle that?

i.e. ndate=11 22 33

Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7080
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Return partial variables within string

Post by Marcus Tettmar » Mon Jul 01, 2019 2:39 pm

PepsiHog's solution still works. It doesn't care what the separator is.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply