Whether you are extracting data from the screen, or directly from a database, the time will come when additional formatting is necessary. Foxtrot is equipped with hundreds of formulas to deal with such scenarios. We will review the LeftOf & RightOf Formulas in this example.
Each Formula has two required parameters, as well as 2 optional parameters:
- Original Text is the original text to be searched. – required
- End Value is the value marking the end of (but not included in) the text to keep. – required
- Start Position is the starting position of the search. The default is 1 i.e. start at the first character in the Original Text – optional
- Left to Right – If True (default), the text will be searched from Left to Right for the End Value. If False, the text will be searched from Right to Left – optional
You need to extract the first and last name from a Variable or database field. Say for example you have the Variable Complete Name, whose value is “Doe, John”. Ideally, you would like to create two Variables, a First Name Variable, whose value is “John”, and a Last Name Variable whose value is “Doe”.
Note that the value of the Complete Name Variable is “Doe, John”
Extracting the First Name…
To begin, we will extract the First Name by using a RightOf Formula. This Formula will do exactly what it says, we will parse out everything to the right of some character, in this case, a “, “.
The result, “John” is to be stored in a separate Variable, which I have called First Name.
Extracting the Last Name…
Next, we will take the same approach to parse the Last Name from the Complete Name. By using the LeftOf Formula, we will take everything to the left of “, “.
The result, “Doe” is to be stored in a separate Variable, which I have called Last Name.
This Formula may be used to do other types of data parsing in which it is necessary to know a value to the right or left of some other value.