home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / WAITON.PRG < prev    next >
Encoding:
Text File  |  1991-07-31  |  2.5 KB  |  81 lines

  1. /*
  2.      Function: WaitOn()
  3.      System: GRUMPFISH LIBRARY
  4.      Author: Greg Lief
  5.      Copyright (c) 1988-90, Greg Lief
  6.      Clipper 5.01 Version
  7.      Compile instructions: clipper waiton /n/w/a
  8.  
  9.      Display a wait message on the screen -- ideal for any tedious
  10.      process.  If first parameter passed to this function is of logical
  11.      type, it will assume that your tedious process has ended and will
  12.      thus restore the affected portion of the screen.
  13.  
  14.      Calls: ShadowBox()    (function contained in SHADOWBO.PRG)
  15.             ByeByeBox()    (function contained in BYEBYE.PRG)
  16. */
  17.  
  18. //───── begin preprocessor directives
  19.  
  20. #include "grump.ch"
  21.  
  22. //───── end preprocessor directives
  23.  
  24. function waiton(msgs, lsound, ccolor, ntop, nleft)
  25. local x := 0, mlen
  26. static waitsound, waitstack_ := {}
  27.  
  28. //───── if the first parameter passed was of logical type, that means
  29. //───── that the tedious process is over and we are to restore the screen
  30. if valtype(msgs) == "L"
  31.    //───── make sure that WAITON() was called first -- if it was not,
  32.    //───── the waitstack_ array will be empty
  33.    if ! empty(waitstack_)
  34.       if waitsound .or. (lsound != NIL .and. lsound)
  35.          tone(MUSIC_WAITON[2], 1)
  36.          tone(MUSIC_WAITON[1], 1)
  37.       endif
  38.       ByeByeBox(atail(waitstack_))
  39.       truncate(waitstack_)
  40.    endif
  41. else
  42.    //───── establish message -- use default if not passed
  43.    default msgs to { 'Now printing... please wait' }
  44.    default lsound to .t.
  45.  
  46.    //───── if message passed was a character string, convert to array
  47.    if valtype(msgs) == "C"
  48.       msgs := { msgs }
  49.    endif
  50.    mlen := len(msgs)
  51.  
  52.    gfsaveenv( , 0)             // shut off cursor
  53.    //───── use color default if not passed
  54.    ColorSet(IF(ccolor == NIL, C_WAITMESSAGE, ccolor))
  55.    //───── use default coordinates (centered on screen) if not passed
  56.    default ntop to maxrow() / 2 - len( msgs )
  57.  
  58.    //───── determine width of longest message in array
  59.    aeval(msgs, { | a | x := max(len(a), x) } )
  60.  
  61.    default nleft to int(maxcol() - 3 - x) / 2
  62.    aadd(waitstack_, shadowbox(ntop, nleft, ntop + mlen + 1, nleft + 4 + x, 1))
  63.    waitsound := lsound
  64.    if ccolor == NIL
  65.       ColorSet( C_WAITMESSAGEBLINK )
  66.    endif
  67.    setpos(ntop, 0)
  68.    aeval(msgs, { | line | setpos(row() + 1, nleft + 2), dispout(line) } )
  69.    if waitsound
  70.       tone(MUSIC_WAITON[1], 1)
  71.       tone(MUSIC_WAITON[2], 1)
  72.    endif
  73.    gfrestenv()
  74. endif
  75. return NIL
  76.  
  77. * end function WaitOn()
  78. *--------------------------------------------------------------------*
  79.  
  80. * eof waiton.prg
  81.