home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / TTY2.PRG < prev    next >
Encoding:
Text File  |  1991-04-29  |  2.1 KB  |  67 lines

  1. /*
  2.     Function: TTY2()
  3.     System:   GRUMPFISH LIBRARY
  4.     Author:   Greg Lief, with help from Dennis Levin
  5.     Copyright (c) 1988-90, Greg Lief
  6.     Clipper 5.x Version
  7.     Compile instructions: clipper tty /n/w/a
  8.  
  9.     Displays message on screen "teletype" style until keypress
  10. */
  11.  
  12. //───── begin preprocessor directives
  13.  
  14. #include "grump.ch"
  15.  
  16. //───── end preprocessor directives
  17.  
  18.  
  19. function tty2(nrow, cmsg, ndelay, ccolor)
  20. local nlen, leftcol, xcol, nstart, mstring, yy, maxcol := maxcol()
  21.  
  22. if nrow <= maxrow()
  23.    GFSaveEnv( { nrow, 0, nrow, maxcol() } )
  24.  
  25.    //───── use default message if a null string was passed
  26.    default cmsg to 'Press any key to continue'
  27.    //───── truncate the message if longer than 70 characters
  28.    cmsg := substr(cmsg, 1, 70)
  29.  
  30.    //───── set ndelay factor to 0 if not passed and make sure it is a numeric!
  31.    default ndelay to 0
  32.  
  33.    setcolor(ccolor)
  34.    nlen := len(cmsg) + 10            // determine how many dots to use
  35.    leftcol := int((maxcol + 1 - nlen) / 2)
  36.    @ nrow, leftcol ssay replicate(chr(46), nlen)
  37.    xcol := leftcol + nlen - 6        // start five columns from the right
  38.    nstart := 1                       // substring ptr for when we hit the left
  39.    do while inkey() = 0
  40.       mstring := substr(cmsg, nstart, nlen + leftcol - xcol - 5) + ;
  41.                  if(nstart > 1, replicate(chr(46), nstart - 1), '')
  42.       @ nrow, xcol ssay mstring
  43.       if ndelay == 0            && use sound
  44.          tone(MUSIC_TTY, 1)
  45.       else
  46.          for yy = 1 to ndelay
  47.          next
  48.       endif
  49.       if xcol == leftcol + 5                    // we're at the left side
  50.          if ++nstart > nlen - 10                // time to go back to the right
  51.             @ nrow, xcol ssay chr(46)           // clear remainder of message
  52.             xcol := leftcol + nlen - 5          // reset column pointer
  53.             nstart := 1                         // reset substring pointer
  54.          endif
  55.       else
  56.          xcol--
  57.       endif
  58.    enddo
  59.    GFRestEnv()
  60. endif
  61. return NIL
  62.  
  63. * end function TTY2()
  64. *--------------------------------------------------------------------*
  65.  
  66. * eof tty2.prg
  67.