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

Re: EL Problem



PureBytes Links

Trading Reference Links

>Hello Colleagues!
>
>Could You explain the next EL problem?
>
>A Very Simple System:
>{-------------------}
>print("p1 ",TestFunc:2:0);
>print("p2 ",TestFunc:2:0);
>{-------------------}
>
>and a Very Simple Function
>
>{------------------------}
>vars: memo(0);
>
>if currentbar=1 then memo=1
>else if memo=1 then memo=0
>	else memo=1;
>TestFunc=memo;
>{------------------------}
>
>I have in the Print Log:
>p1 1
>p2 1
>p1 0
>p2 0
>p1 1
>p2 1
>p1 0
>p2 0
>...

I assume you were expecting the value of the variable "memo" to be shared
when you call the function twice on the same bar. That is not the case.
There are two different calls so two different variables called "memo" and
each work correctly.

The value of "memo" for each instantiation of the function is retained from
bar to bar so that when entering the function on bar 2 it has the same
value as it had on exiting on bar 1.

Bob Fulks