[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

No GoTo function



PureBytes Links

Trading Reference Links

EL uses basic configurations of code that can be used in many different
applications. An obvious example is the "if - then" statement. But a
function that I miss is the GoTo function. It has been discussed in the
past on this list and it seems most of the writers are glad to see it
gone. But it was simple and clear to use. It can be simulated with the
IFF function as shown below.  It would be interesting and useful if
others post code which accomplishes the same thing.  Namely, stepping
over several different "if conditionZ then begin" where conditionZ is
different for each "if - then begin". The different conditionZs
determine if a block of code, say 20 lines, gets executed. Code that
does NOT work is :

If cond1 then 
     if cond1=true and cond2 then begin
        if cond1=false and cond3 then begin
	    if cond4 then begin
                block of code;
	    end;
     end;
end;

I want cond2 OR cond3 and cond4 to decide if the block of code is
executed.  Cond1 is just to decide if cond2 or cond3 is tested but not
both. If cond1 is true and cond2 false then cond4 never gets tested.  If
both cond1 and cond2 are true then cond4 never gets tested. The problem
is stepping over either cond2 or cond3. The following code will do this
feat.

Var: x(0), K(0);
If cond1 then x=1
else x=2;
	if x=1 then K= IFF(cond2, 1, 0);
	if x=2 then K= IFF(cond3, 1, 0);
	If K=1 and cond4 then begin
		block of code;
	End;

If cond1 is true then only cond2 is tested and depending on the out come
with cond4 decide if the block of code is executed. If cond1 is false
then only cond3 and cond4 decide if the block of code is executed. The
key here is having only one "begin". Of course, cond1 can replace x in
the above as it did in the top code.

A variation on the above is:

var: x(0), K(0);
K=0;
If cond1 then x=1
else x=2;
	if IFF((x=1, iff(cond2, 1, 0), iff( cond3, 1, 0))=1 then K=1;
	if K=1 and cod4 then begin
		block of code;
	End

K=0; is needed here due to K defined =1 at some bar. Since it is a
SERIES variable its value is carried over from the previous bar and
therefore it must be set to 0 for each bar. In the middle code IFF is a
SIMPLE function, therefore so is K and as pointed out on this list, the
value is not carried over and will be calculated (reinitialized?) on
each bar. 

Reinventing the wheel again,

Wayne