From: Philip Rhoades Date: 2012-11-17T22:50:00+09:00 Subject: Re: Alternatives to methods for large number of nested "ifs" People, Thanks to the people who responded - I looked at everything but nothing really suited what I was trying to do but see below for some progress that I made and another question: On 2012-11-17 01:35, Philip Rhoades wrote: > People, > > I have an existing script that looks like: > > lots of code > . > . > . > if .. > some lines of code > if .. > some lines of code > if .. > some lines of code > if .. > some lines of code > if .. > some lines of code > etc > > This makes it difficult to see the overall logic so I want to change > it to something like: > > lots of code > . > . > . > if .. > call something > if .. > call something > if .. > call something > if .. > call something > if .. > call something > etc > > but if I use methods I will have to pass lots of variables or use > global variables and then it gets clumsy changing everything - is > there some way of simply calling a block of code and then returning > to > the same position in the nested "ifs"? I found that I could use sequential "ifs" instead of nested "ifs" by using "exit" statements in each "if" block - the script is processing incoming mails and can exit when a mail has been satisfactorily classified. I still have something like this: lots of code if block - small lots of code if block - small if block - large if block - small if block - large . . etc What I want is to be able to see the whole logic of the program in about 25 lines (ie one screenfull of code - ie all the "if" statements) - I could probably use standard methods for the repetitive small "if" blocks but for the large "lots of code" and "if block - large" I definitely can't. Is it possible that a method can be forced to NOT use local variables? - then I could replace the large blocks with these sorts of methods. Thanks, Phil. -- Philip Rhoades GPO Box 3411 Sydney NSW 2001 Australia E-mail: phil@pricom.com.au