Retrieving data from previous frames

I am trying to “flick” a ball in a certain direction and have it slow down the longer it travels. My idea of how to do this is to say something like if ballX > previousBallX then ballX = ballX - 1 (a very basic description), but I don’t know how to retrieve data from past frames.

keep a velocity variable vx and position x.
set vx = v0 at the beginning.
compute new position at each draw with x = x + v * ElapsedTime.
and update v with v = v * a, with a between 0.9 and 0.99, depending on the decay you want.

@Staples - the way to think about Codea is that the screen has no “memory”, and the frames are lost when they are replaced by new ones. So you have to remember and store everything you need, using variables, tables, etc, so as to figure out what to draw in the next frame.