Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - savecolors() save current color settings http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 savecolors()        Save current color settings
------------------------------------------------------------------------------
 Declaration
   color.hdr

 Syntax
   proc savecolors extern

 Arguments
   None.

 Return
   None.

 Description
   This procedure saves the current color settings contained in the
   __syscolor[] system variable to an internal buffer for later use by
   restcolors(). This pair of routines is handy if you need to
   save, and later restore color attributes.

   Force makes use of one internal buffer only, i. e. savecolors() calls
   cannot be nested. If you call savecolors() several times and then
   restcolors(), the color attributes which were saved last will be
   restored.

 Example
   #define EXAMPLE_SCREEN
   #include example.hdr

   proc Test_savecolors
   vardef
      byte bColorStd, bColorEnhcd
   enddef
   ? "Original color"
   
   // The conventional way to save/restore colors
   bColorStd   := __syscolor[ CLR_STD ] // save the current color attributes
   bColorEnhcd := __syscolor[ CLR_ENHCD ]
   __syscolor[ CLR_STD ] := RED_LIGHT_CYAN
   ? "Colors changed"
   __syscolor[ CLR_STD ]   := bColorStd // restore the old cursor position
   __syscolor[ CLR_ENHCD ] := bColorEnhcd
   ? "Colors restored"
   
   // The shorter way to save/restore colors
   savecolors()                         // save the current colors
   __syscolor[ CLR_STD ] := RED_LIGHT_CYAN
   ? "Colors changed"
   restcolors()                         // restore the old colors
   ? "Colors restored"
   endproc

   proc main
   Test_savecolors()
   endproc

See Also: __syscolor restcolors()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson