Re: ebasic goto
- Posted by jbrown105 at hotpop.com Jul 21, 2001
- 354 views
On 0, David Cuny <dcuny at LANSET.COM> wrote: > jbrown105 wrote: > > > I believe David Cuny figured out how to > > emulate a goto in Euphoria for his old > > ebasic program. > > > > David, how did you do it? > > Hrm... It's not currently on my machine. It was a real nasty hack, though. > If you had a routine like this: > > procedure foo() > print "this" > if a then goto b > print "that" > b: > print "the other" > end procedure > > The code is then broken up into segments (defined by the lables and where > the goto statements appear): > > procedure foo() > label = 1 > goto = 0 > while 1 do > > -- controller > if goto then > lable = goto > goto = 0 > else > label += 1 > end if > > -- code segments > if lable = 1 then > print "this" > if a then > goto = 2 > exit > end if > exit > > elsif label = 2 then > print "that" > exit > > elsif label = 3 then > print "the other" > exit > > elsif label = 4 then > return > end if > > end while > end procedure > > There are serious limits to this method - for example, you can't jump in or > out of structures. So you can't write: > > for i = 1 to 100 > if i < 3 then > -- can't jump out of a structure! > goto finished > end if > end for > > Did that answer the question? > > -- David Cuny > Mostly. However, looking at the converted code gives me a headace. jbrown105 -- Linux User:190064 Linux Machine:84163 http://jbrown105.1avenue.com