nested while loop

Douglas Clark dbcl at CEH.AC.UK
Tue Mar 7 06:01:59 EST 2006


This error is still the one that Bernd indicated:

bernd.becker at METOFFICE.GOV.UK wrote:
> Initialize c=0 in the loop over r?

e.g.

while(r < rows)
  say 'row '%r
  c=0
  while(c < columns)
    say 'column '%c



>>> knilssen at WEATHER3000.COM 07/03/2006 10:54:04 >>>
The following script should produce output which shows that a nested
loop is executing. However, the inner loop only executes once.

columns = 4
rows = 5
c = 0
r = 0

while(r < rows)
  say 'row '%r
  while(c < columns)
    say 'column '%c
    c = c + 1
  endwhile
  r = r + 1
endwhile

output...
row 0
column 0
column 1
column 2
column 3
row 1
row 2
row 3
row 4


--
This message (and any attachments) is for the recipient only. NERC
is subject to the Freedom of Information Act 2000 and the contents
of this email and any reply you make may be disclosed by NERC unless
it is exempt from release under the Act. Any material supplied to
NERC may be stored in an electronic records management system.



More information about the gradsusr mailing list