home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / INVCLR.PRG < prev    next >
Text File  |  1991-08-16  |  3KB  |  78 lines

  1. /*
  2.  * File......: InvClr.Prg
  3.  * Author....: David Husnian
  4.  * Date......: $Date:   15 Aug 1991 23:03:44  $
  5.  * Revision..: $Revision:   1.2  $
  6.  * Log file..: $Logfile:   E:/nanfor/src/invclr.prv  $
  7.  * 
  8.  * This is an original work by David Husnian and is placed in the
  9.  * public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   E:/nanfor/src/invclr.prv  $
  15.  * 
  16.  *    Rev 1.2   15 Aug 1991 23:03:44   GLENN
  17.  * Forest Belt proofread/edited/cleaned up doc
  18.  * 
  19.  *    Rev 1.1   14 Jun 1991 19:52:00   GLENN
  20.  * Minor edit to file header
  21.  * 
  22.  *    Rev 1.0   01 Apr 1991 01:01:30   GLENN
  23.  * Nanforum Toolkit
  24.  *
  25.  */
  26.  
  27.  
  28. /*  $DOC$
  29.  *  $FUNCNAME$
  30.  *     FT_INVCLR()
  31.  *  $CATEGORY$
  32.  *     Conversion
  33.  *  $ONELINER$
  34.  *     Get the inverse of a color
  35.  *  $SYNTAX$
  36.  *     FT_INVCLR( [ <cDsrdColor> ] ) -> cColor
  37.  *  $ARGUMENTS$
  38.  *     <cDsrdColor> is the color to get the inverse of.  Defaults to
  39.  *     current color.
  40.  *  $RETURNS$
  41.  *     The inverse of the passed color.
  42.  *  $DESCRIPTION$
  43.  *     This function inverts a passed color (in the Clipper format: ??/??),
  44.  *     e.g., "W/N" is converted to "N/W".
  45.  *  $EXAMPLES$
  46.  *     cInverse := FT_INVCLR()            // Get Inverse of Current Color
  47.  *     cInvErr  := FT_INVCLR( cErrColor ) // Get Inverse of cErrorColor
  48.  *  $END$
  49.  */
  50.  
  51. #Command    DEFAULT <Param1> TO <Def1> [, <ParamN> TO <DefN> ] ;
  52.             => ;
  53.             <Param1> := IF(<Param1> == NIL,<Def1>,<Param1>) ;
  54.          [; <ParamN> := IF(<ParamN> == NIL,<DefN>,<ParamN>)]
  55.  
  56. #define     NULL    ""
  57.  
  58. FUNCTION FT_INVCLR(cDsrdColor)
  59.  
  60.    LOCAL cBackground, ;                 // The Background Color, New Foreground
  61.          cForeground, ;                 // The Foreground Color, New Background
  62.          cModifiers                     // Any Color Modifiers (+*)
  63.  
  64.    DEFAULT cDsrdColor TO SETCOLOR()
  65.                                         // Remove Anything Past 1st Color
  66.    cDsrdColor := LEFT(cDsrdColor, AT(",", cDsrdColor+",")-1)
  67.  
  68.                                         // Get Any Modifiers
  69.    cModifiers := IF("*" $ cDsrdColor, "*", NULL) + ;
  70.                  IF("+" $ cDsrdColor, "+", NULL)
  71.  
  72.                                         // Separate the Fore/Background Colors
  73.    cForeground := ALLTRIM(LEFT(cDsrdColor,   AT("/", cDsrdColor) - 1))
  74.    cBackground := ALLTRIM(SUBSTR(cDsrdColor, AT("/", cDsrdColor) + 1))
  75.  
  76.    RETURN (STRTRAN(STRTRAN(cBackground, "+"), "*") + cModifiers + "/" + ;
  77.            STRTRAN(STRTRAN(cForeground, "+"), "*"))
  78.