Latest News

the latest news from our team

Capture a moving value

Usually the Text to XML preprocessor is the first choice to capture data that is not in a predictable location. An existing project that uses text files to create invoices had a total value at the end of an invoice that could be one or more pages long. The customer wanted to capture the total amount as a variable to include in an email body, and attach the invoice as a PDF.

Redoing the project as Text to XML would take several hours. Instead, the following solution was employed, and it took all of ten minutes. This project uses a plain-text file as data. This approach is not appropriate for XML or CSV files. It might work for some PDF files.

  1. Back up the existing project file.
  2. Create a variable called TotalLocation. The document identifies the total with the text TOTAL PAYMENT AMOUNT:.
  3. Add a Set Value function to TotalLocation and set it to the system variable Raw Page Data. Raw Page Data is the content of the data file.

4. Add a String Position function and enter TOTAL PAYMENT AMOUNT:. This is the string that tells us the total amount immediately follows. The function returns the position in the document where this string begins. Your search string might be different.

5. Create a variable named TotalPayment. This variable must be after the TotalLocation variable because it will use the value of that variable. Add the same Set Value function that TotalLocation uses.

6. After the Set Value function, add a Substring function. Click Variable and select TotalLocation. 44 is a number that will always be enough to include the search string, several spaces, and the total amount we want to capture.

7. Add a Replace function to remove the search string, and then add a Left Trim function to remove leading spaces.

8. The TotalPayment variable should now contain the amount and can be used in the email body.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code