Forum OpenACS Development: writing a TCL string to a file

Collapse
Posted by Daniel Comer on
I am still new to OpenACS, and TCL for that matter.  Anyway, I am using:

template::util::write_file

to write a tcl string to a file.  The problem I am having is making new line in the text file.  if I do a \", the double quote will show up in the file, however if I do a \n, \r, \n\r, \0A\0E, I am not getting a carriage return or line feed to advance to the next line.  I may be going about this the wrong way and would greatly appreciate any advice on the right way to go about this.

Thanks in advance.

Daniel

Collapse
Posted by Andrew Piskorski on
The template::util::write_file proc is basically just using puts to write your string to a file. So you need to have actual linefeeds in the string you pass to it, not the literal string "\n". Either make sure your "\n" is interpreted at the time you set your string, or if necessary (unlikely), call subst on the string later on, just before you pass it to template::util::write_file.

Also, my advice is when you have a chance, review Tcl's rules for parsing and evaluation, as this sort of problem indcates you haven't become completely familiar with them yet.