Avoid inputting a file multiple times describes how to prevent a file from being
\input more than once. I wonder, though, if there is a way to limit this to only preventing a file from being
input if and only if it has been
\input within the last, say, five pages... but allowing it to be
\input if there are at least five pages since the last time.
I have a data set that associates files to be
\input (diagrams) with data objects. I don't want to see the same diagram input multiple times in close succession (seeing the same diagram more than once on the same page, or within a few pages, is unpleasant), but am happy to see the diagram included again if associated with a data element sometime later.
For example, an atlas of US cities ordered by name might display a small map of the state the city is in. It's dead easy to always include the map, it's slightly trickier but not hard to include a map once and only once. I'm wondering if it's possible to make it so the map gets included the first time, then any attempt to
\input it again ignored unless there are at least (some number) of pages between the current page and the last time it was