The variables astart and aend are not assigned values until right before the last time gcoder is called.
What do you expect them to be the first time the program runs since they are uninitialized?