Avisynth has no frame properties like Vapoursynth has. The method of filling the variable is a workaround hack which probably works only when the variable is constant.
You can define a filter to NonCachedGenericVideoFilter, like Reverse or
Loop works internally.