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:
Return Value:
|
The following program demonstrates how to extract foreground and background color information from RetVal% when Mode% is set to 1.
DIMa$, b%, c%, d$CLSCOLOR15,4a$="B"LOCATE2,11,0COLOR4,7a$="C"LOCATE2,12,0COLOR15,4a$="X"LOCATE2,13,0COLOR7,0a$=" "LOCATE2,14,0=SCREEN(2,11)' Note that the third OPTIONAL parameter is not used' when retrieving the ASCII value of the characterd$=STR$(b%)&" is the ASCII value of char "&CHR$(b%)LOCATE4,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%AND15' Calculates FOREGROUND color valueSELECTCASEc%CASE0" FOREGROUND COLOR is Black"CASE1" FOREGROUND COLOR is Blue"CASE2" FOREGROUND COLOR is Green"CASE3" FOREGROUND COLOR is Cyan"CASE4" FOREGROUND COLOR is Red"CASE5" FOREGROUND COLOR is Purple"CASE6" FOREGROUND COLOR is Brown"CASE7" FOREGROUND COLOR is Light Grey"CASE8" FOREGROUND COLOR is Dark Grey"CASE9" FOREGROUND COLOR is Bright Blue"CASE10" FOREGROUND COLOR is Bright Green"CASE11" FOREGROUND COLOR is Bright Cyan"CASE12" FOREGROUND COLOR is Bright Red"CASE13" FOREGROUND COLOR is Bright Purple"CASE14" FOREGROUND COLOR is Yellow"CASE15" FOREGROUND COLOR is White"ENDSELECTc%=(b%AND112)/16' Calculates BACKGOUND color value.SELECTCASEc%CASE0" BACKGROUND COLOR is Black"CASE1" BACKGROUND COLOR is Blue"CASE2" BACKGROUND COLOR is Green"CASE3" BACKGROUND COLOR is Cyan"CASE4" BACKGROUND COLOR is Red"CASE5" BACKGROUND COLOR is Purple"CASE6" BACKGROUND COLOR is Brown"CASE7" BACKGROUND COLOR is Light Grey"ENDSELECTEND
BCX Console Sample Programs using SCREEN function.