Why bother to use an expression? You can do the same thing with keyframes and a little bit of arithmetic.
Your expression needs a time reference, which returns one value, and a position reference which is either a 2 or 3 place array written like this [100, 300]
If you want to write an expression that moves a layer from it's original position 500 pixels to the left in 3 seconds then you just have to divide 500 X 3 then use time * the result and add that value to the current position of X. I'd write it something like this:
d = 500; // distance in pixels
s = 3; // time in seconds
r = d / s; // pixels per second
cv = value; // current value of x
nx = cv + (time * r); // add movement to the right
Movement will start from at the first frame of the comp. You can use valueAtTime or inPoint or even the position of a marker to start the movement by simply doing a little more coding.
Thank you for the answer, I will try it at home the same.
it will certainly help me
Now I understand the principle better already and have learned something