The window vector obtained from the DEVICE command is not always the same length. It
is normally (on my machine) 65 elements long, but can be much longer if you have lots
of IDL windows open (by calling cgPickColorName, for example). But if no windows with
index numbers greater than 65 are open, IDL shinks the larger vector to the smaller one
as part of its housekeeping operations, which means it happens on their timetable, not yours.
This can result in the user having "stale" index numbers greater than 65, but no larger vector
to check them against. I have modified the code to return a 0 in this case, assuming that
whatever window your index number points to is long gone. I have not experience any ill effects
by doing this, but I STRONGLY advice you to ALWAYS know what window you are drawing into
when you issue a graphics command.