B
Ben Engbers
Hi,
In my program, I know that at some moment the value of a variable X will
change from value 1 to value 2. I am not interested in the value of X
itself but the transition should trigger an event. Example, if the value
of a stock will reach a certain value, I want to sell but after that I'm
not interested in the value anymore (until it might reach another
break-value).
Of course I could program this as:
if oldvalue <= testvalue and newvalue > testvalue then
do something;
oldvalue = newvalue;
end
But suppose that there are a lot of variables that I need to watch and I
don't want to write a test for every one.
Wat is the best strategy to watch the transition?
Ben
In my program, I know that at some moment the value of a variable X will
change from value 1 to value 2. I am not interested in the value of X
itself but the transition should trigger an event. Example, if the value
of a stock will reach a certain value, I want to sell but after that I'm
not interested in the value anymore (until it might reach another
break-value).
Of course I could program this as:
if oldvalue <= testvalue and newvalue > testvalue then
do something;
oldvalue = newvalue;
end
But suppose that there are a lot of variables that I need to watch and I
don't want to write a test for every one.
Wat is the best strategy to watch the transition?
Ben