For Programmers: Free Programming Magazines  


Home > Archive > AWK > November 2004 > PRINTING LOTS OF OUTPUT









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PRINTING LOTS OF OUTPUT
James Pascoe

2004-11-21, 3:57 am

Dear All,

Apologies if this is OT or answered elsewhere, but I am looking for
some help.

I am using gawk to generate a C file as part of a build process, and
as such, the gawk script
does a lot of printing. Currently, I am using lots of print statements
(1 per line) to actually output the text. The body of my script looks
similar too:

print "int main(void) "
print "{"
....
print " return (0);"
print "}"

.... and basically, I was wondering if there is a better way to produce
lots of static text ?

Many thanks,

James
Kenny McCormack

2004-11-22, 3:56 am

In article <fe6eb44f.0411150757.5f62fd22@posting.google.com>,
James Pascoe <james@james-pascoe.com> wrote:
>Dear All,
>
>Apologies if this is OT or answered elsewhere, but I am looking for
>some help.
>
>I am using gawk to generate a C file as part of a build process, and
>as such, the gawk script
>does a lot of printing. Currently, I am using lots of print statements
>(1 per line) to actually output the text. The body of my script looks
>similar too:
>
>print "int main(void) "
>print "{"
>...
>print " return (0);"
>print "}"
>
>... and basically, I was wondering if there is a better way to produce
>lots of static text ?


The short answer is "not really". There's nothing really wrong with the
above, but sometimes I bunch them together, like this:

print "int main(void)\n{\n return (0);\n}"

at some cost in readability. Or, you could try:

OFS="\n"
print "int main(void)",
"{",
" return (0);",
"}"

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com