StringReplace> Result

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

StringReplace> Result

Post by JRL » Mon Dec 15, 2014 2:01 pm

It would be handy if StringReplace> returned a result code. It would be even better if the result code was the number of replacements.

Code: Select all

Let>Str=When the sins of my mother weigh down in my soul
StringReplace>Str,mother,father,Str
If>Replace_Count=1
  GoSub>ReWrite
EndIf

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Re: StringReplace> Result

Post by jpuziano » Mon Dec 15, 2014 8:12 pm

Hi JRL,

I agree that would be handy... even though we could use RegEx for this, see below:

Code: Select all

Let>Str=When the sins of my mother weigh down in my soul
RegEx>mother,Str,0,matches,Replace_Count,1,father,new_Str

If>Replace_Count>0
  GoSub>ReWrite
Else
  MDL>There were no replacements
EndIf

SRT>ReWrite
   MDL>Number of replacements: %Replace_Count%%CRLF%Old String: %Str%%CRLF%New Strng: %new_Str%
End>ReWrite
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: StringReplace> Result

Post by JRL » Mon Dec 15, 2014 8:29 pm

jpuziano,

You're right. Old habits... thank you. :)

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