home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol11n11.zip / CENTER.BAS < prev    next >
BASIC Source File  |  1992-01-25  |  2KB  |  59 lines

  1. DEFINT A-Z
  2.  
  3. DECLARE SUB Center (Row, Text$)
  4. DIM SHARED Foreground, Background
  5.  
  6. Message$ = "This is a test message to be centered"
  7. Foreground = 15
  8. Background = 1
  9.  
  10. COLOR Foreground, Background
  11. CLS
  12.  
  13. Row = 10                    'display the message on line 10 and return
  14. CALL Center(Row, Message$)
  15.  
  16. Row = -12                   'display the message and also wait for a key
  17. CALL Center(Row, Message$)
  18.  
  19. Row = 14 + 100              'display the message in inverse, no wait
  20. CALL Center(Row, Message$)
  21.  
  22. Row = 16 + 1000             'display the message blinking, no wait
  23. CALL Center(Row, Message$)
  24.  
  25. Row = -(18 + 100)           'display the message in inverse and also wait
  26. CALL Center(Row, Message$)
  27.  
  28. SUB Center (Row, Text$)             'centers text on given line
  29.    
  30.   L = Row: T$ = Text$               'protect incoming parameters
  31.  
  32.   IF L < 0 THEN                     'wait for a key before leaving
  33.     WaitKey = -1                    'set a flag for later
  34.     L = -L                          'revert to a positive value
  35.   END IF
  36.  
  37.   IF L > 1000 THEN                  'blink the message
  38.     COLOR Foreground + 16           'these are shared from main module
  39.     L = L - 1000                    'normalize the row
  40.   END IF
  41.  
  42.   IF L > 100 THEN                   'print in inverse
  43.     COLOR Background, Foreground    'these are shared from main module
  44.     T$ = " " + T$ + " "             'extend highlight 1/2 space each end
  45.     L = L - 100                     'normalize the row
  46.   END IF
  47.  
  48.   LOCATE L, 41 - LEN(T$) \ 2        'position on line for centering
  49.   PRINT T$;                         'display message
  50.   COLOR Foreground, Background      'restore normal colors
  51.  
  52.   IF WaitKey THEN
  53.     WHILE LEN(INKEY$): WEND         'first clear the keyboard buffer
  54.     WHILE LEN(INKEY$) = 0: WEND     'then wait for a key press
  55.   END IF
  56.  
  57. END SUB
  58.  
  59.