home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast.iso
/
pcmag
/
vol11n11.zip
/
CENTER.BAS
< prev
next >
Wrap
BASIC Source File
|
1992-01-25
|
2KB
|
59 lines
DEFINT A-Z
DECLARE SUB Center (Row, Text$)
DIM SHARED Foreground, Background
Message$ = "This is a test message to be centered"
Foreground = 15
Background = 1
COLOR Foreground, Background
CLS
Row = 10 'display the message on line 10 and return
CALL Center(Row, Message$)
Row = -12 'display the message and also wait for a key
CALL Center(Row, Message$)
Row = 14 + 100 'display the message in inverse, no wait
CALL Center(Row, Message$)
Row = 16 + 1000 'display the message blinking, no wait
CALL Center(Row, Message$)
Row = -(18 + 100) 'display the message in inverse and also wait
CALL Center(Row, Message$)
SUB Center (Row, Text$) 'centers text on given line
L = Row: T$ = Text$ 'protect incoming parameters
IF L < 0 THEN 'wait for a key before leaving
WaitKey = -1 'set a flag for later
L = -L 'revert to a positive value
END IF
IF L > 1000 THEN 'blink the message
COLOR Foreground + 16 'these are shared from main module
L = L - 1000 'normalize the row
END IF
IF L > 100 THEN 'print in inverse
COLOR Background, Foreground 'these are shared from main module
T$ = " " + T$ + " " 'extend highlight 1/2 space each end
L = L - 100 'normalize the row
END IF
LOCATE L, 41 - LEN(T$) \ 2 'position on line for centering
PRINT T$; 'display message
COLOR Foreground, Background 'restore normal colors
IF WaitKey THEN
WHILE LEN(INKEY$): WEND 'first clear the keyboard buffer
WHILE LEN(INKEY$) = 0: WEND 'then wait for a key press
END IF
END SUB