This subroutine finds the last line containing a string in an input text.
Inputs:
Local__Input: The body of text to be searched
Local__TextToFind: the string to be found
Output:
%Variable%Local__Found%: The subroutine returns the line containing the last occurrence of the string to be found. If nothing is found, the empty string is returned.
Error Checking:
The subroutine terminates with an error when either or both of the inputs are empty.
Also, I hadn't seen the Assert action before. Is there a functional difference between this and an If/Else that leads to either empty action slots (if at the end of a macro) or a Cancel this macro action? I can see a few uses for it that might neaten up some of my macros.
Yup - it's an error in the regex (of course). I've just corrected it in the original post.
You could replicate this with If/Else actions but that adds the distraction of the actual If/Else structure.
Asserts originate, I believe, in the computer programming world where at the start of a program you would set out what is needed for the subsequent code to operate correctly and if that is not satisfied to throw an error, making debugging much more straightforward. You could call it "defensive programming".
It seems to me particularly appropriate in a subroutine that expects certain inputs to work properly and to therefore fail rather than continue with erroneous inputs.
I've included the assert here because I'm trying to protect anyone who comes along and uses this subroutine but fails to provide the correct inputs.