The Problem with Embeds, Part 4: A TXA Embed Viewer
by Unknown user
In Part 2 of this series I mentioned that I wanted to reuse my original TXA parsing code to produce something like this:
With my TXA parser class in place (from Part 3) I threw together a new app. I added a global include statement for the class .INC file:
include('DCL_Clarion_TXAParser.inc'),once
I created a new Window procedure and added two data elements:
- a string field for the file name
- a queue with a single CString(1000) field.
- the entry field
- a file lookup control template (filter: *.txa)
- a list box (with the queue as its FROM attribute)
TxaParser      DCL_Clarion_TXAParser
and created a routine, which I called from the Accepted embed for both the TXA file name entry field and the lookup button:
LoadTXA ROUTINE if TxaParser.Parse(TxaFileName) TxaParser.GetEmbedData(DataQ,DataQ.DataQText) ELSE free(DataQ) DataQ.DataQText = TxaParser.Errors.GetLastError() add(DataQ) END
I also had to add DevRoadmapsClarion.lib to the project.Â
On running the app and loading a TXA I saw this:
That's not quite as pretty as my initial objective. But it wasn't much work to clean up the code for the DCL_Clarion_TXAParser.GetEmbedData method. I also changed the window font to Segoe and the list box font to Consolas.Â
The image below, by the way, shows all the embed code for this application.Â
Because I'd changed the DCL_Clarion_TXAParser.GetEmbedData method, one of my unit tests failed, the one that verifies the exact data extracted from the TXA. I could fix my test to accommodate these changes, but if I make yet another display change I'm going to break the test again.Â
Instead I created a simplified GetRawEmbedData routine that does absolutely no formatting, and I used that for my unit test. I also renamed GetEmbedData to GetFormattedEmbedData for the sake of clarity.Â
Next up: Invoice.app!
In Part 1 of this series I said I would be refactoring code in the shipping Invoice.app. That was a long time ago, but with the unit-tested TXA parser in hand it's finally time to dive into that app. Read Part 5.
Download the source
The app is available here:Â ExtractAndDisplayEmbeds.app
You will also need DevRoadmapsClarion.lib and DevRoadmapsClarion.dll, which you can find on GitHub.
Read more about the DevRoadmaps Clarion Library (DCL)
Â