[texhax] read file content as parameter until EOF?

Torsten Wagner torsten.wagner at fh-aachen.de
Mon Jul 4 12:50:04 CEST 2005


.....only the feedback ;)
Alexander Grahn pointed the (for me) correct solution.

>\documentclass{article}
>
>\def\formatparline#1;;#2;;#3;;{\noindent#1, #2, #3\\}
>
>\def\createparlist{%
>  \newread\parlistin%
>  \openin\parlistin=participants.part%
>  \loop%
>    \read\parlistin to \temp%
>  \if\temp\relax\else%
>    \expandafter\formatparline\temp%
>  \repeat%
>  \closein\parlistin%

Thanks Alexander

Bye
Torsten


Torsten Wagner wrote:

> Hello everybody,
>
> first I like to thank you for the replies of my last message (Read and
> process single characters). It works fine know. Uwe Lück was right,
>
>> ? It seems that you have an unusual understanding of "token". 
>
>
> Yes indeed, I assume that I'm wrecked with all this "modern" object
> oriented programming languages ;) I have to learn that the TeX world is
> different sometimes. (Do not shout to me but after several hours happy
> TeXing it seems often to me like Texing is "ordinary" programming just
> on drugs ;) )
>
> Now let's come to my new lovely problem.
>
> I have a file which contains the following data line by line
>
> Name, First Name;; Email-Address;; Post-Address;;
> ..
>
> Now I like to read this file and format the input until I reached the EOF
>
> I used roughly....
>
> \def\formatparline#1;;#2;;#3;;{#1, #2, #3} % will be replaced by a more
> complex macro
>
> \providecommand{\createparlist}{
> \newboolean{breakcond}
> \setboolean{breakcond}{true}
> \newread\parlistin
> \openin\parlistin = participants.part
> \whiledo{\boolean{breakcond}}{\ifeof\parlistin\setboolean{breakcond}{false} 
>
> \else \read\parlistin to \temp \expandafter\formatparline\temp \fi}
>
> I aspect, that the whole file will be read one by one until EOF, as I
> understood, the single file-line will be written as macro to \temp like
> in the same way as \def\temp{file-line}
>
> therefore, if I use \expandafter the token \temp should be resolved to
> the following line
>
> \formatparline Name, First Name;; Email-Address;; Post-Address;;
>
> and this should be fine to resolve the command \formatparline.
> However, this is not working. TeX shout that \par end before \formatline
> was finished. (I assume it didn't get all paramters)
>
> strange effect, without the while loop TeX runs fine and resolve
> \expandafter\formatparline\temp correctly.
>
> Any suggestion how can I read the file information and use them as
> parameters directly.
>
>
> Thanks for your help
>
> Torsten
>
>
>
>



More information about the texhax mailing list