# [texhax] Writing verbatim to file

Mike B. mb78aa at yahoo.com
Mon Mar 7 02:28:12 CET 2011

Hi All,

I'm trying achieve the following sequence:
1. a variable l is assigned some length.
2. if some condition is true then the following line should be written to a file
\setlength{x}{<length of l>}

A psuedo-code for this seems to be:
\ifthenelse{ condition is true }{
write to file as verbatim: \setlength{x}{
write to file the value of l: \the\l
write to file as verbatim (close braces): }
}{}

The newfile package allows to output to a file but:
- not inside an argument to another command (I need this inside an \ifthenelse structure)
- verbatim text must have balanced curly braces

Would appreciate advice how to solve this.

Thanks,
Mike.