I have a program with an infinite loop that prints the current motor position to the screen. However, when I run it, it resets to zero through every iteration.
One of the problems I see is you have no constant set for the power associated with your motor, so it shouldn't move. This may give you a value of zero and appear that it is resetting.