series() is already context-based, and so is SeriesLength.

A C++ script writer can write one function that returns a struct/tuple of vars and int by wrapping series() and SeriesLength.