SCREEN function
Purpose: SCREEN returns the ASCII value of the character located at coordinates vertical y%, horizontal x%. If the optional Mode% parameter is set to 1 then the color attributes of the character located at coordinates y%, x% is returned. This function works only in console mode programs.
Syntax: RetVal% = SCREEN(y%, x% [, Mode%]) Parameters:
|
The following program demonstrates how to extract foreground and background color information from RetVal% when Mode% is set to 1.
'Written by Robert Wishlaw December 31, 2001.
DIM
a$, b%, c%, d$CLS
COLOR
15
,4
a$=
"B"
LOCATE
2
,11
,0
COLOR
4
,7
a$=
"C"
LOCATE
2
,12
,0
COLOR
15
,4
a$=
"X"
LOCATE
2
,13
,0
COLOR
7
,0
a$=
" "
LOCATE
2
,14
,0
=
SCREEN
(
2
,11
)
' Note third OPTIONAL parameter is not used
' when retrieving the ASCII value of the character
d$=
STR$
(
b%)
&
" is the ASCII value of char "
&
CHR$
(
b%)
LOCATE
4
,1
,0
=
" at coordinates vertical 2, horizontal 11"
=
SCREEN
(
2
,11
,1
)
' NOTE use of the third OPTIONAL parameter
' to signal retrieval of character attributes.
c%=
b%AND
15
' Calculates FOREGROUND color value
SELECT
CASE
c%CASE
0
" FOREGROUND COLOR is Black"
CASE
1
" FOREGROUND COLOR is Blue"
CASE
2
" FOREGROUND COLOR is Green"
CASE
3
" FOREGROUND COLOR is Cyan"
CASE
4
" FOREGROUND COLOR is Red"
CASE
5
" FOREGROUND COLOR is Purple"
CASE
6
" FOREGROUND COLOR is Brown"
CASE
7
" FOREGROUND COLOR is Light Grey"
CASE
8
" FOREGROUND COLOR is Dark Grey"
CASE
9
" FOREGROUND COLOR is Bright Blue"
CASE
10
" FOREGROUND COLOR is Bright Green"
CASE
11
" FOREGROUND COLOR is Bright Cyan"
CASE
12
" FOREGROUND COLOR is Bright Red"
CASE
13
" FOREGROUND COLOR is Bright Purple"
CASE
14
" FOREGROUND COLOR is Yellow"
CASE
15
" FOREGROUND COLOR is White"
END
SELECT
c%=
(
b%AND
112
)
/
16
' Calculates BACKGOUND color value.
SELECT
CASE
c%CASE
0
" BACKGROUND COLOR is Black"
CASE
1
" BACKGROUND COLOR is Blue"
CASE
2
" BACKGROUND COLOR is Green"
CASE
3
" BACKGROUND COLOR is Cyan"
CASE
4
" BACKGROUND COLOR is Red"
CASE
5
" BACKGROUND COLOR is Purple"
CASE
6
" BACKGROUND COLOR is Brown"
CASE
7
" BACKGROUND COLOR is Light Grey"
END
SELECT
END
BCX Console Sample Programs using SCREEN function.