Midstr alternative method (or enhancement)

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
tbrahmer
Newbie
Posts: 15
Joined: Thu May 06, 2010 10:14 pm

Midstr alternative method (or enhancement)

Post by tbrahmer » Mon Mar 02, 2015 8:23 pm

Looking for a good way to return the remaining characters from a string just given a starting point...
For instance, to return 'End', I know I can use:

Code: Select all

Let>string=BeginEnd
MidStr>string,6,3,result1
Let>result2={copy(%string%,6,3)}
But using these methods require me to provide a length for the substrings, so I have always had to compute the total length, subtract where my starting point is, etc...

Was hoping for solution similar to many programming languages where if you omit the length, it will just return all the remaining characters till it hits the end of the string. Something like this...

Code: Select all

Let>string=BeginEnd
MidStr>string,6,,result1
Let>result2={copy(%string%,6)}
Is there a simple solution that I am missing, or should I call this an enhancement request... Thoughts?

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Re: Midstr alternative method (or enhancement)

Post by Jerry Thomas » Mon Mar 02, 2015 11:37 pm

Try just putting some number > than the string could ever be
I use 100 most of the time
Thanks,
Jerry

[email protected]

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

Re: Midstr alternative method (or enhancement)

Post by Marcus Tettmar » Tue Mar 03, 2015 10:15 am

You could also do:

Code: Select all

Let>string=BeginEnd
Let>result={copy(%string%,6,length(%string%))}
So you're still finding length but it's all done in-line.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

tbrahmer
Newbie
Posts: 15
Joined: Thu May 06, 2010 10:14 pm

Re: Midstr alternative method (or enhancement)

Post by tbrahmer » Tue Mar 03, 2015 10:29 pm

Thanks Jerry and Marcus, will use your suggestions.

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