[GAP Forum] Change line width when using PrintTo
Frank Lübeck
frank.luebeck at math.rwth-aachen.de
Thu Jul 30 12:57:16 BST 2009
On Wed, Jul 29, 2009 at 11:57:35AM -0500, Joe Bohanon wrote:
> Is there any way to extend the length of a line when I print to a file
> using PrintTo (or AppendTo)? I'm using GAP to auto-generate some html
> pages (I know, it's a non-standard use) and the backslash characters
> that come up for line breaks mess with the output. It's not that hard
> to fix, but it would save time if there was a way to change it.
Dear Joe, dear Forum,
Check out the documentation of 'SetPrintFormattingStatus', it also contains
an example.
It is quite reasonable to use GAP for this sort of task, the string
processing is reasonably fast and there is some text processing
functionality in the GAPDoc package.
Alternatively, you can first collect your output in a GAP string and
write it in the end to a file using 'FileString'.
If you have many Print statements writing small output it can be much more
efficient to use 'PrintTo1'.
This can also be combined, for example
gap> f := function() local i; for i in [1..100000] do Print(i," "); od; end;;
gap> out:=OutputTextFile("nonsense",false);;
gap> SetPrintFormattingStatus(out,false);
gap> PrintTo1(out, f);
gap> CloseStream(out);
produces a file without linebreak (and no backslashes).
Hope this helps, best regards,
Frank
--
/// Dr. Frank Lübeck, Lehrstuhl D für Mathematik, Templergraben 64, ///
\\\ 52062 Aachen, Germany \\\
/// E-mail: Frank.Luebeck at Math.RWTH-Aachen.De ///
\\\ WWW: http://www.math.rwth-aachen.de/~Frank.Luebeck/ \\\
More information about the Forum
mailing list