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

  1. /*
  2.  * File......: PENDING.PRG
  3.  * Author....: Isa Asudeh
  4.  * CIS ID....: 76477,647
  5.  * Date......: $Date:   15 Aug 1991 23:05:20  $
  6.  * Revision..: $Revision:   1.1  $
  7.  * Log file..: $Logfile:   E:/nanfor/src/pending.prv  $
  8.  * 
  9.  * This is an original work by Isa Asudeh and is placed in the
  10.  * public domain.
  11.  *
  12.  * Modification History
  13.  * --------------------
  14.  *
  15.  * $Log:   E:/nanfor/src/pending.prv  $
  16.  * 
  17.  *    Rev 1.1   15 Aug 1991 23:05:20   GLENN
  18.  * Forest Belt proofread/edited/cleaned up doc
  19.  * 
  20.  *    Rev 1.0   31 May 1991 21:18:04   GLENN
  21.  * Initial revision.
  22.  *
  23.  */
  24.  
  25.  
  26. /*  $DOC$
  27.  *  $FUNCNAME$
  28.  *     FT_PENDING()
  29.  *  $CATEGORY$
  30.  *     Menus/Prompts
  31.  *  $ONELINER$
  32.  *     Display same-line pending messages after a wait.
  33.  *  $SYNTAX$
  34.  *     FT_PENDING ( <cMsg>, [ <nRow> ], [ <nCol> ], ;
  35.  *                       [ <nWait> ], [ <cColor> ] ) -> NIL
  36.  *  $ARGUMENTS$
  37.  *     <cMsg> is the message string to display.
  38.  *
  39.  *     <nRow> is an optional screen row for message display, default row 24.
  40.  *
  41.  *     <nCol> is an optional screen col for message display, default col 0.
  42.  *
  43.  *     <nWait> is an optional wait (sec) between messages, default 5 sec.
  44.  *
  45.  *     <cColor> is an optional color string for displayed messages, default 
  46.  *              is white text over red background.
  47.  *  $RETURNS$
  48.  *     NIL
  49.  *  $DESCRIPTION$
  50.  *     A good way to display information messages during the running
  51.  *     of an application is to send them all to the SAME line on the
  52.  *     screen where users are expected to look for them. In order to
  53.  *     give users a chance to read the current message before the next one
  54.  *     is displayed we may need to insert a delay after each message.
  55.  *
  56.  *     FT_PENDING() function displays messages by keeping track of
  57.  *     the time of the last message and providing a delay ONLY if the next
  58.  *     pending message is issued much too soon after the current one.
  59.  *
  60.  *  $EXAMPLES$
  61.  *     FT_PENDING("Message one",20,0,3,"W+/G") // Displays "Message one."
  62.  *                                             // sets row to 20, col to 0.
  63.  *                                             // wait to 3 and color to
  64.  *                                             // bright white over green.
  65.  *     FT_PENDING("Message two")   // Displays "Message two", after 5 sec.
  66.  *     FT_PENDING("Message three") // Displays "Message three", after 5 sec.
  67.  *
  68.  *
  69.  *     Note that default row, col, wait time and color need to be set only
  70.  *     once in the very first call to FT_PENDING() and only if the internal
  71.  *     default values are not appropriate.
  72.  *
  73.  *  $END$
  74.  */
  75.  
  76. #ifdef FT_TEST
  77.   FUNCTION MAIN()
  78.      @0,0 CLEAR
  79.      FT_PENDING("Message one",20,0,3,"W+/G") // Displays "Message one."
  80.                                              // sets row to 20, col to 0.
  81.                                              // wait to 3 and color to
  82.                                              // bright white over green.
  83.      FT_PENDING("Message two")   // Displays "Message two", after 5 sec.
  84.      FT_PENDING("Message three") // Displays "Message three", after 5 sec.
  85.      return ( nil )
  86. #endif
  87.  
  88. FUNCTION FT_PENDING (cMsg, nRow, nCol, nWait, cColor)
  89.  STATIC nLast_Time := 0, nRow1 := 24, nCol1 := 0
  90.  STATIC nWait1 := 5, cColor1 := 'W+/R,X'
  91.  LOCAL  nThis_Time, nTiny := 0.1, cSavColor
  92.  
  93. *
  94. * cMsg        Message to display
  95. * nRow        Row of displayed message
  96. * nCol        Col of displayed message
  97. * nWait       Wait in seconds between messages
  98. * cColor      Color of displayed message
  99. *
  100.  
  101.  IF (cMsg == NIL )                       //if no message, no work
  102.     RETURN NIL
  103.  ENDIF
  104.  
  105.  nRow1 := IIF( nRow <> NIL, nRow, nRow1 )  //reset display row
  106.  nCol1 := IIF( nCol <> NIL, nCol, nCol1 )  //reset display col
  107.  
  108.  nWait1 := IIF ( nWait <> NIL, nWait, nWait1)     //reset display wait
  109.  cColor1 := IIF (cColor <> NIL, cColor, cColor1)  //reset display color
  110.  
  111.  nThis_Time := SECONDS()                //time of current message
  112.  
  113.  IF nLast_Time == 0 
  114.     nLast_Time := nThis_Time - nWait1   //for first time round.
  115.  ENDIF
  116.  
  117.  IF (nThis_Time - nLast_Time) < nTiny   //if messages are coming too fast,
  118.     nLast_Time := nThis_Time + nWait1   //set time counter and then
  119.     INKEY (nWait1)                      //wait a few seconds.
  120.  ELSE
  121.     nLast_Time := nThis_Time            //set time counter for next message.
  122.  ENDIF
  123.  
  124.  @nRow1,0 clear to nRow1,80             //clear the display line
  125.  
  126.  cSavColor := SETCOLOR(cColor1)         //save current and set display color
  127.  
  128.  @nRow1,nCol1 SAY cMsg                  //display message
  129.  
  130.  SETCOLOR( cSavColor )                  //restore colors.
  131.  
  132.  RETURN NIL
  133.