home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP09.EXE / CHP0903.PRG < prev    next >
Encoding:
Text File  |  1991-06-01  |  1.4 KB  |  59 lines

  1. /*
  2.    Listing 9.3. A function that uses an array to display messages.
  3.    Author: Craig Yellick
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11.  
  12. function Pugilist(r, c, msg_)
  13. /*
  14.    Display list of message lines in a box.
  15.    Start display at screen coordinates r,c.
  16.    Function will center message if r or c not specified.
  17.    Array msg_ contains message lines.
  18.  
  19.    Example:
  20.  
  21.    Pugilist(5, 20, {"That customer number",  ;
  22.                     "is not defined. Enter",;
  23.                     "another or press ESC",  ;
  24.                     "to return to the menu."})
  25. */
  26. local i, width := 0
  27.  
  28.   /*
  29.      Find length of longest line
  30.   */
  31.   for i := 1 to len(msg_)
  32.     width := max(width, len(msg_[i]))
  33.   next i
  34.  
  35.   /*
  36.      If row or column not specified,
  37.      Calculate starting row and column
  38.      that will center message on screen
  39.      (maxRow and maxCol are supplied by the system)
  40.   */
  41.   if r = nil
  42.     r := (maxRow() -len(msg_)) /2
  43.   endif
  44.   if c = nil
  45.     c := (maxCol() -width) /2
  46.   endif
  47.  
  48.   /*
  49.      Draw box large enough to contain message,
  50.      then display each message line
  51.   */
  52.   @ r -1, c -1 to r +len(msg_), c +width
  53.   for i := 1 to len(msg_)
  54.     @ r +(i -1), c say msg_[i]
  55.   next i
  56. return nil
  57.  
  58. // end of file CHP0903.PRG
  59.