{"id":8650,"date":"2020-11-18T10:08:43","date_gmt":"2020-11-18T18:08:43","guid":{"rendered":"https:\/\/minisoft.com\/support\/?p=8650"},"modified":"2020-11-18T10:08:44","modified_gmt":"2020-11-18T18:08:44","slug":"capture-a-moving-value","status":"publish","type":"post","link":"https:\/\/www.minisoft.com\/support\/capture-a-moving-value\/","title":{"rendered":"Capture a moving value"},"content":{"rendered":"\n<p>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. <\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<ol><li>Back up the existing project file. <\/li><li>Create a variable called TotalLocation. The document identifies the total with the text TOTAL PAYMENT AMOUNT:. <\/li><li>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.<\/li><\/ol>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"390\" height=\"200\" src=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount1.jpg\" alt=\"\" class=\"wp-image-8651\" srcset=\"https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount1.jpg 390w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount1-300x154.jpg 300w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount1-150x77.jpg 150w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount1-250x128.jpg 250w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount1-351x180.jpg 351w\" sizes=\"(max-width: 390px) 100vw, 390px\" \/><\/figure><\/div>\n\n\n\n<p>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. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"380\" height=\"206\" src=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount2.jpg\" alt=\"\" class=\"wp-image-8652\" srcset=\"https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount2.jpg 380w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount2-300x163.jpg 300w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount2-150x81.jpg 150w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount2-250x136.jpg 250w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount2-332x180.jpg 332w\" sizes=\"(max-width: 380px) 100vw, 380px\" \/><\/figure><\/div>\n\n\n\n<p>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. <\/p>\n\n\n\n<p>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. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"311\" height=\"234\" src=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount3.jpg\" alt=\"\" class=\"wp-image-8653\" srcset=\"https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount3.jpg 311w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount3-300x226.jpg 300w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount3-150x113.jpg 150w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount3-250x188.jpg 250w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount3-239x180.jpg 239w\" sizes=\"(max-width: 311px) 100vw, 311px\" \/><\/figure><\/div>\n\n\n\n<p>7. Add a Replace function to remove the search string, and then add a Left Trim function to remove leading spaces.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"348\" height=\"334\" src=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount4.jpg\" alt=\"\" class=\"wp-image-8654\" srcset=\"https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount4.jpg 348w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount4-300x288.jpg 300w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount4-150x144.jpg 150w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount4-250x240.jpg 250w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount4-188x180.jpg 188w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount4-313x300.jpg 313w\" sizes=\"(max-width: 348px) 100vw, 348px\" \/><\/figure><\/div>\n\n\n\n<p>8. The TotalPayment variable should now contain the amount and can be used in the email body.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"532\" height=\"133\" src=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount5.jpg\" alt=\"\" class=\"wp-image-8655\" srcset=\"https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount5.jpg 532w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount5-300x75.jpg 300w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount5-150x38.jpg 150w, https:\/\/www.minisoft.com\/support\/wp-content\/uploads\/2020\/11\/TotalAmount5-250x63.jpg 250w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[655,654],"_links":{"self":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/8650"}],"collection":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/comments?post=8650"}],"version-history":[{"count":3,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/8650\/revisions"}],"predecessor-version":[{"id":8660,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/8650\/revisions\/8660"}],"wp:attachment":[{"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/media?parent=8650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/categories?post=8650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.minisoft.com\/support\/wp-json\/wp\/v2\/tags?post=8650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}