Re: WISHLIST.TXT

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message -----
From: "Matthew Lewis" <matthewwalkerlewis at YAHOO.COM>
To: "EUforum" <EUforum at topica.com>
Subject: RE: WISHLIST.TXT


> > Not really. By "end loop" I assume you are telling the
> > interpreter to finish
> > looping through the current loop block. If so, what is the difference
> > between "end loop" and the current "exit" statement?
>
> No, he means to go back to the top of the loop for the next iteration.
> Here's a silly example:
>
> for i = 1 to 10
>   if remainder(i,3) = 0 then
>     resume
>   end if
>   printf(1, "%d is divisible by 3!\n", i)
> end for
>
> So you should see:
>
> 3
> 6
> 9
>
> I typically use a big if statement to do that sort of thing (of course
this
> is really trivial):
>
> for i = 1 to 10
>   if remainder(i,3) != 0 then
>     printf(1, "%d is divisible by 3!\n", i)
>   end if
> end for
>

Thanks Matt. I proposed a statement that is similar to 'exit <name>'. I
propose that we have a 'next <name>' statement. This would go to the *next*
iteration of the named loop block.

 Main:for j = 1 to 5 do
   sum = 0
   for i = 1 to 10
     if sequence(x[j][i]) then
        next Main
     end if
     if remainder(x[j][i],3) = 0 then
       next
     end if
     sum += x[j][i]
     printf(1, "%d is divisible by 3!\n", i)
   end for
   printf(1, "The sum is %d\n", sum)
 end for

----------------
cheers,
Derek Parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu