Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- RLIB 3.0a Reference - <b>function:</b> center() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function:    CENTER()

Purpose:     Center a string and/or get the center position.

Syntax:      CENTER( [ row ,] string [, color ] )

Arguments:   row         - Optional numeric value which, if passed, will
                           cause CENTER() to print <string> centered on
                           row number <row>.  Value checked to be between
                           0 and 24, or MAXROW() in the Clipper 5.0
                           version.

             string      - Target character string used to determine
                           center position, and optionally, to print on
                           row number <row> if <row> is given as a
                           parameter.

             color       - Optional character color string (in Clipper
                           format) used to display <string> on screen.

Returns:     The column number to center <string> on an 80 column monitor.
             If <row> is specified, it displays <string> centered on
             <row>.

Description: Almost everyone has a function to center text on the screen.
             So why should RLIB have one also?  This does just what you
             think; it takes the string provided, and returns the numeric
             column position to center the text on an 80 column display.
             Only this center can also do the displaying, and can do that
             job in the color you select.  All this helps cut down on the
             amount of code.

Notes:       The maximum string length supported, naturally, is 80 since
             that is the maximum screen width.

Example:     *-- this method requires two lines of code and a memvar
             memvar = 'This is the string to center on row 23'
             @ 23,CENTER(memvar) SAY memvar

             *-- or without assigning string to memvar (very wordy)
             @ 23,CENTER('This is the string to center on row 23') ;
             SAY 'This is the string to center on row 23'

             *-- the simpler way
             CENTER(23,'This is the string to center on row 23')

             *-- and if you want it in another color..  the old way
             save_color = SETCOLOR("R/W")
             @ 23,CENTER("Please wait...") SAY "Please wait..."
             SETCOLOR(save_color)

             *-- CENTER() cuts down the SLOCs (Source Lines Of Code)
             CENTER( 23, "Please wait...", "R/W" )

Source:      RL_CENTE.PRG

See also:    MIDDLE()

See Also: MIDDLE()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson