Hi prof!

I adapted the logic into the codes,

where d1 = distance traveled

x1s = x1 slider position
x1area = dummy variable for x1s counting of line integral

d1 = d1 + Math.sqrt((x1s-x1area)*(x1s-x1area)); // same as +=
// d1 += Math.sqrt((x1-x1area)*(x1-x1area));
x1area=x1s; // x1area is just a way to do line integral

The problem:
as I slide the time slider bar that controls ts = time slider variable.
The value of d1 is still counting as I slide time variable ts, which makes the value run continually which is not was i wanted.

I want to make it give the value for d1 = distance travel for time ts = 0 to ts = current position.

I tested these codes and they work fine in normal situation/simulation without the slider "ts".

Any tips how to trick the program into replay the value of d1 and ts ?

or do i need a different approach or strategy?

in case u need, the source code is attached :)