home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 9.3. A function that uses an array to display messages.
- Author: Craig Yellick
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
-
- function Pugilist(r, c, msg_)
- /*
- Display list of message lines in a box.
- Start display at screen coordinates r,c.
- Function will center message if r or c not specified.
- Array msg_ contains message lines.
-
- Example:
-
- Pugilist(5, 20, {"That customer number", ;
- "is not defined. Enter",;
- "another or press ESC", ;
- "to return to the menu."})
- */
- local i, width := 0
-
- /*
- Find length of longest line
- */
- for i := 1 to len(msg_)
- width := max(width, len(msg_[i]))
- next i
-
- /*
- If row or column not specified,
- Calculate starting row and column
- that will center message on screen
- (maxRow and maxCol are supplied by the system)
- */
- if r = nil
- r := (maxRow() -len(msg_)) /2
- endif
- if c = nil
- c := (maxCol() -width) /2
- endif
-
- /*
- Draw box large enough to contain message,
- then display each message line
- */
- @ r -1, c -1 to r +len(msg_), c +width
- for i := 1 to len(msg_)
- @ r +(i -1), c say msg_[i]
- next i
- return nil
-
- // end of file CHP0903.PRG
-