Q(uick)BASIC Function: SCREEN

Quick View

SCREEN

A graphics function that reads a character's ASCII value or its color from a specified screen location

Worth knowing

Useful and cross-version information about the programming environments of QBasic and QuickBasic.

Syntax
  • SCREEN (row%,column% [,colorflag%])
Description/Parameter(s)
row% The row coordinate of a character.
column% The column coordinate of a character.
colorflag% A value (0 or 1) that specifies what is returned.
ValueReturns
0 (or omitted)The character's ASCII code.
1The character's color attribute.
Example
CLS PRINT "Hello" PRINT "The ASCII value of character at 1,1 is"; SCREEN(1, 1)
Syntax
  • SCREEN (row,column[,colorflag])
Description/Parameter(s)
Argument Description
row The row number of the screen location. The row is a numeric expression that evaluates to an unsigned integer.
column The column number of the screen location. The column is a numeric expression that evaluates to an unsigned integer.
colorflag A numeric expression. When colorflag is nonzero, SCREEN returns the number of the color at the screen location. If the colorflag is zero or absent, the ASCII code of the character at the location is returned as an integer.

If the character at (10,10) is A, in the following examples, then the function would return 65, the ASCII code for A:

  • X=SCREEN(10,10)
Example

The following example returns the color attribute of the character in the upper-left corner of the screen:

X=SCREEN(1,1,1)
Syntax
  • SCREEN (line%,column% [,colorflag%])
Description/Parameter(s)
line% The character location; an integer expression whose valid range depends on the number of lines on screen.
column% The character location; an integer expression with a value between 1 and 80, inclusive.
colorflag% An optional numeric expression that determines which information is returned:
Not used or 0 = return ASCII code
= return foreground color code

Usage Notes

  • If the character at (10,10) is A, the following statement would return 65, the ASCII code for A, to the variable X:

  • X = SCREEN(10, 10)

  • Note: In graphics screen modes, if the pattern on the screen at the given character location does not exactly match any pattern in the current ASCII character set, the SCREEN function returns the ASCII code for a space. If colorflag% is nonzero, the SCREEN returns 0.
Example

This example uses the SCREEN function to return the color attribute of the character in the upper-left corner of the screen.

X = SCREEN(1, 1, 1)