For Programmers: Free Programming Magazines  


Home > Archive > AWK > October 2004 > question for doing macros.









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 question for doing macros.
Steve

2004-10-12, 3:55 am

Hi, I did a macro assembler in awk, but it was unsatisfactorily
complex. The key issue is having one input line from a source file
generate multiple lines that then should be processed by the main
loop.

For example:

<input file>
THISISAMACRO "test",2,xxx
</input file>

And after this I would like to process 2-to-n different $0 lines in my
main awk pattern testing loop. So THISISAMACRO might emit

$0 = command "test",2
then
$0 = command2 "test",xxx

etc.

So maybe my awk code is

/THISISAMACRO/ { for (i=0;i<3;i++) { $0="command" $i; next;} }

and this wont work because "next" will rip me out of the for loop and
at best I will get only the first line of the expansion, and maybe it
will not even get this if it overwrites my $0 with the next input
line.


Any ideas?
Sponsored Links







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

Copyright 2008 codecomments.com