05-15-2015 07:58 AM
Updating an old legacy test application that was originally written in C, to now be maintained in Labview. The report generation function of the original application used .txt files as templates, and filled in the test data where appropriate. Since it was just a text file (no fancy MS Word formatting or HTML) it used special control characters to indicate the places where data needed to be entered. I still need to use these origianal templates to maintain the required format, but I am not sure on the best approach. My first thought was to read in the .txt file, scan it for the special characters, and replace them with the required data, but that seems like it would be very difficult to maintain. I would like to be able to create a template that has each one of the fields named for it's specific data, but I am not sure how to accomplish this. Any suggestions on converting text files to templates, or other, more advanced methods for using these files? Please advise.
Using Labview 2013, and I do have the report generation toolkit installed (but not sure if it can help me).
Thanks in advance,
GSinMN
05-15-2015 01:21 PM
@GSinMN wrote:
My first thought was to read in the .txt file, scan it for the special characters, and replace them with the required data
That is what I would do as you are duplicating the existing test program.
05-15-2015 01:51 PM
If you really need to retain the original templates, then you (forgive me here) need to retain the original templates, meaning you have to continue to parse them as you are doing.
However, you might consider trying to Have Your Cake and Eat It, Too. You mention there are control characters in the O.T. (Original Template). You could consider replacing the existing Control characters (you don't mention what they are) with a "Placeholder Entry" of a specified format, one that allowed you to create/define "named" placeholders.
Here's an example -- we'll say that a Placeholder is defined by the string "%%<Placeholder_Name", e.g. "%%Name", "%%Date", "%%Time". So your templace could have an entry like
"Test of Subject %Name on %Date at %Time"
You would, of course, need to (somehow) get values for the Template fields, but you clearly have a mechanism at present to do this.
You are still "stuck" with parsing your Template and replacing fields, but now the Template is "Human-readable", making it easier to expand or modify to suit new situations.
Bob Schor
05-15-2015 01:52 PM
Oops -- my Placeholder identifier was "%%", but I only used one "%" in my example Template. You would, of course, have your parser look for "obvious errors" like single "%" symbols and kick out "Did you mean to say %%Name in the Template?" ...
BS