how to nest while loops 
Author Message
 how to nest while loops

I written an awk script to parse data from one command to use as input
to another command which is used as input to a 3rd command. for example
(real script too long):
while ("command one" |getline) {
    parse data
    print parsed data
        while ("command two" |getline) {
            parse data
            print parsed data
                while ("command three" |getline) {
                    parse data
                    print parsed data
            }
    }
Quote:
}

the output results are:
command one data
    command two data
        command three data
command one data
<end of report>
I suspect that the "while" conditions don't get reset when exiting a
higher loop. Question is how do I fix the coding error?
Any help would be appreciated.
HT


Sat, 03 Jan 2004 13:11:02 GMT  
 how to nest while loops
I written an awk script to parse data from one command to use as input
to another command which is used as input to a 3rd command. for example
(real script too long):
while ("command one" |getline) {
    parse data
    print parsed data
        while ("command two" |getline) {
            parse data
            print parsed data
                while ("command three" |getline) {
                    parse data
                    print parsed data
            }
    }
Quote:
}

the output results are:
command one data
    command two data
        command three data
command one data
<end of report>
I suspect that the "while" conditions don't get reset when exiting a
higher loop. Question is how do I fix the coding error?
Any help would be appreciated.
HT


Sat, 03 Jan 2004 13:12:46 GMT  
 how to nest while loops


% while ("command one" |getline) {
%     parse data
%     print parsed data
%         while ("command two" |getline) {
%             parse data
%             print parsed data
%                 while ("command three" |getline) {
%                     parse data
%                     print parsed data
%             }
              close("command three")
%     }
      close("command two")
% }
  close("command one")

Note that the string passed to close() must exactly match the
string to the left of the pipe operator.
--

Patrick TJ McPhee
East York  Canada



Sun, 04 Jan 2004 00:25:54 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. nested while loops, inside loop not stopping correctly

2. That nested nested nested if statement...

3. A puzzle - nested for-loops

4. Smalltalk rocks, and a newbie question ( nested loops ).

5. Nested Awk loops?

6. Nested ACCEPT loops with ROUTINE

7. Smalltalk rocks, and a newbie question ( nested loops ).

8. Help with unique attributes and nested loops

9. problem with nested while-loops

10. FP vs assembly programming for super-scalar CPUs [Was: Nested Loops in Clean]

11. Nested Loops in Clean

12. Is there a break-type event to exit out of nested while loops

 

 
Powered by phpBB® Forum Software