# coyote: WINDOWAVAILABLE

- coyote/Utilities
- [Source code]

NAME

      WindowAvailable

PURPOSE

      This function returns a 1 if the specified window index number is
      currently open or available. It returns a 0 if the window is currently
      closed or unavailable.

AUTHOR

      FANNING SOFTWARE CONSULTING
      David Fanning, Ph.D.
      1645 Sheely Drive
      Fort Collins, CO 80526 USA
      Phone: 970-221-0438
      E-mail: david@idlcoyote.com
      Coyote's Guide to IDL Programming: http://www.idlcoyote.com

CATEGORY

      Utilities

CALLING SEQUENCE

      available = WindowAvaiable(windowIndexNumber)

INPUTS

      windowIndexNumber:   The window index number of the window you wish to
                           know is available or not.

KEYWORDS

      None.

NOTES

      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.

MODIFICATION HISTORY

      Written by David W. Fanning, June 2005.
      Modified to return 0 if the window index number is larger than the number of elements
            in the WINDOW_STATE array. 25 June 2008. DWF.