Automatic processing of data for TeX / LaTeX
The problem in your question is the term "sequentially". It is impossible to generate one TeX/LaTeX document continuously. A TeX / LaTeX document that produces valid output has a begin and more important, an end. When the document is finished without errors, the output is complete and the TeX / LaTeX job is done. You cannot "feed" data into that document, once it is done.
What you can do is to build a LaTeX frame document, \input some_external_data
and re-produce the output every time the external data changes.
The topic is: At the time the LaTeX job runs, the data you want to produce has to be defined in content and length, as the output document wont update automatically later, when the data changes, without running the LaTeX job again. At least not without quite complex, customized methods, that greatly depend on your used viewer or output medium.
To improve your original approach
It might help to change the way you process the data
Dear --MRMRS-- --NAME--, we hope ...
Here you use a self defined template language to produce a TeX file. I think that is, what you mean by "hard coded".
As its a good practice to separate output form (layout) and logic, it is also a good practice to separate generated data from the template as long as possible and to translate the set of information (the input or the data) in a way, the next processor understands (next processor is LaTeX in our case).
I show what I mean: LaTeX does not know what to do with --MRMRS-- and such constructs, thought the TeX machine is generally able to setup such a parser. But that would make things quite complex and hard to control and debug. So keep in the language LaTeX language domain, when you define your template:
Dear \MRMRS{} \NAME{}, we hope ...
Let's keep it simple and say that is our whole pattern, then the data set in text form might be
Mrs
Moneypenny
The C program might translate this input data into a form, that is known by the C language:
struct greeting {
char* mrmrs;
char* name;
};
Now the purpose of the C program (or whatever) is to translate that into the LaTeX language
\def\MRMRS{Mr}
\def\NAME{Moneypenny}
You can now read in the processed data into the LaTeX program, that is a true LaTeX program, not a template to-be-processed by whatever and every step from the raw data to the output document can be debugged separated from the other processes.
Best Answer
This is a job for
tikz
:Notes:
Code: