Re: goto's, and loops

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

Hello,

Kat you wrote:

>Hi all,
>
>Why is there no "goto" in Euphoria? It would be easy enough to implement,
>and if you don't want to use it, you don't haveto. I've used it sparingly
>in
>other languages, for the example below, for example. Maybe i am in a rut,
>but i don't see an nice way to do this example in Euphoria, can you help,
>please? ( Without making another procedure and all the vars global. )
>
>loop1
>some code
>loop2
>test var, maybe goto target
>-- an "exit" here would get you out of loop2, not loop1
>EndOfLoop1
>more code
>EndOfLoop2
>:target
>
>thanks,
>Kat

well I could do this easily with a routine but lets try this:

integer i i = 0
while x do  -- loop1
  ..some_code..
  while y do  -- loop 2
    if test_var then
      exit
    end if
    if want_out_of_loop_2 then
      i = 1
    end if
  end while  -- end of loop 2
  if i then
    exit
  end if
  ..more_code..
end while  -- end of loop 1
..target..

hope this helps,
Lewis Townsend


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu