home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION CENTERON (line_num, string, new_color)
- *****************************************************************
-
- * Center a string on selected line in selected color
-
- * Copyright(c) 1991 - James Occhiogrosso
-
- LOCAL end_col := MAXCOL(), horz_pos, old_color, string_len
-
- * Get the length of the passed string data
- string_len = LEN(string)
-
- * If window color is undefined, initialize it
- colwindow := IF (TYPE('colwindow') != 'C', SETCOLOR(), colwindow)
-
- DO CASE
-
- CASE string_len > end_col .OR. string_len < 1
- * Invalid length, abort.
- RETURN NIL
-
- * The CASES below pad the displayed string with up to 10
- * spaces. The number of spaces increases as the length of
- * the passed string decreases. This produces an attractive
- * display for all string lengths.
-
- CASE string_len > end_col-10 .AND. string_len <= end_col-2
- string = ' ' + string + ' '
- horz_pos = INT((end_col - LEN(string))/2)
-
- CASE string_len > end_col-20 .AND. string_len <= end_col-10
- string = ' ' + string + ' '
- horz_pos = INT((end_col - LEN(string))/2)
-
- CASE string_len > end_col-30 .AND. string_len <= end_col-20
- string = ' ' + string + ' '
- horz_pos = INT((end_col - LEN(string))/2)
-
- CASE string_len > end_col-40 .AND. string_len <= end_col-30
- string = ' ' + string + ' '
- horz_pos = INT((end_col - LEN(string))/2)
-
- CASE string_len <= 40
- string = ' ' + string + ' '
- horz_pos = INT((end_col - LEN(string))/2)
-
- OTHERWISE
- * String is almost width of screen, do not pad
- horz_pos = 0
- ENDCASE
-
- * Clear the line using current color setting
- @ line_num, 0
-
- * Save old color and set message color
- old_color = IF(new_color == NIL, SETCOLOR(colwindow), ;
- SETCOLOR(new_color) )
-
- * Display padded string
- @ line_num, horz_pos SAY string
-
- * Restore entry color
- SETCOLOR(old_color)
- RETURN NIL
-
-
-
-
-