Re: [Windows] Associate file extensions with a program
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 12, 2004
- 488 views
Juergen Luethje wrote: [snip] > > I'd be interested in your opinion about the following two > implementations. > > }}} <eucode> > -- Implementation #1 > integer ErrNo > ErrNo = 0 -- no error at the beginning > > procedure proc1() > if <some error> then > ErrNo = 27 > elsif <another error> then > ErrNo = 5 > else > ErrNo = 0 > end if > end procedure > > procedure proc2() > if <some error> then > ErrNo = 3 > elsif <another error> then > ErrNo = 22 > else > ErrNo = 0 > end if > end procedure > > proc1() > proc2() > </eucode> {{{ > > I think here is a problem, when there is an error in proc1(), and no > error in proc2(). proc2() then will clear the variable 'ErrNo', and the > information about the error in proc1() is lost. > > }}} <eucode> > -- Implementation #2 > integer ErrNo > ErrNo = 0 -- no error at the beginning > > procedure proc1() > if <some error> then > ErrNo = 27 > elsif <another error> then > ErrNo = 5 > end if > end procedure > > procedure proc2() > if <some error> then > ErrNo = 3 > elsif <another error> then > ErrNo = 22 > end if > end procedure > > proc1() > proc2() > </eucode> {{{ > > The same as above, but without > else ErrNo = 0. > In this case, 'ErrNo' never will be cleared, and it always holds the > number of the last error that occured. > > I can see that implementation #1 is not a good idea, but what about > implementation #2? Well we are using Euphoria so why not take advantage of that?
sequence ErrNo ErrNo = {} -- no error at the beginning procedure proc3() if <some error> then ErrNo &= {{"proc3",7}} elsif <another error> then ErrNo &= {{"proc3",8}} end if end procedure procedure proc1() if <some error> then ErrNo &= {{"proc1",27}} elsif <another error> then ErrNo &= {{"proc1",5}} end if end procedure procedure proc2() proc3() if <some error> then ErrNo &= {{"proc2",3}} elsif <another error> then ErrNo &= {{"proc2",22}} end if end procedure ErrNo = {} proc1() proc2() for i = 1 to length(ErrNo) do if equal("proc1", ErrNo[i][1]) then . . . elsif equal("proc2", ErrNo[i][1]) then . . . elsif equal("proc3", ErrNo[i][1]) then . . . end if end for
-- Derek Parnell Melbourne, Australia