Screen read/write


The screen terminal is at the same time both a simple console and a graphic screen.

Console

The console is 24x40 (24 lines and 40 characters on each line). Top left corner is position 1,1. Writing a newline at line 24 will make the console scroll up.
As default the console has a black background and text is written with color white.

PRINT

Print variables and text strings on the console at the cursor position. The cursor moves automatically to the start of the next line. Add a "," at the end of the line, and the cursor will not move to the next line.

Separate variables and strings to print with ","
10 PRINT "Hello world"
20 PRINT A
30 PRINT H$               // H$ is a text variable
40 PRINT 25+4
50 PRINT "My age is ",A
60 PRINT A," ",B," ",2019, // cursor is after 2019

COLOR

Select text and background colors. The background color is optional.

 Syntax:

    COLOR foreground, background

10 COLOR RED   
20 COLOR RED,BLACK   
30 COLOR WHITE   

CLS

Clear the screen using the background color. The color parameter to CLS is optional.

 Syntax:

    CLS color
10 CLS 
20 CLS RED   
    

CURSOR

Place the cursor on the console.

 Syntax:

    CURSOR column , row // x,y
10 CURSOR 2,10
20 CURSOR A,B
30 CURSOR A,B+20
40 CURSOR 50,10  // WRONG, max is 40,24

GET CURSOR

Get the cursor position.

 Syntax:

    GET CURSOR column , row // x,y
10 GET CURSOR A,B
20 GET CURSOR X,Y

SCROLL

Scroll the console. The graphic screen will be cleared.

 Syntax:

    SCROLL horizontal , vertical // x,y
10 SCROLL -1 , 0  // move screen 1 position to the left
20 SCROLL 0 , 2 // move screen 2 positions down
    

GET DATA

Get data from the console at a x,y position, and save it as either a variable or a text variable with length 1.

 Syntax:

    GET DATA column , row , variable // x,y,value
10 GET DATA A,B,C
20 GET DATA X,Y,S$
30 GET DATA 10,12,V
40 GET DATA 10,14,B$
If reading to a variable, the decimal ASCII character is used.
        
 Dec  Char     Dec Char      Dec Char
 ---------     --------      ---------
 32  SPACE     64  @         96  `
 33  !         65  A         97  a
 34  "         66  B         98  b
 35  #         67  C         99  c
 36  $         68  D         100  d
 37  %         69  E         101  e
 38  &         70  F         102  f
 39  '         71  G         103  g
 40  (         72  H         104  h
 41  )         73  I         105  i
 42  *         74  J         106  j
 43  +         75  K         107  k
 44  ,         76  L         108  l
 45  -         77  M         109  m
 46  .         78  N         110  n
 47  /         79  O         111  o
 48  0         80  P         112  p
 49  1         81  Q         113  q
 50  2         82  R         114  r
 51  3         83  S         115  s
 52  4         84  T         116  t
 53  5         85  U         117  u
 54  6         86  V         118  v
 55  7         87  W         119  w
 56  8         88  X         120  x
 57  9         89  Y         121  y
 58  :         90  Z         122  z
 59  ;         91  [         123  {
 60  <         92  \         124  |
 61  =         93  ]         125  }
 62  >         94  ^         126  ~
 63  ?         95  _         127  DEL

Graphic screen

The graphic screen is 400 x 400 pixels. Top left corner is position 0,0. Each pixel has a color value.

PSET

Write a to a pixel on the screen using the foreground color.

 Syntax:

    PSET column , row // x,y
10 COLOR RED   
20 PSET 2,10
30 PSET A,B
40 COLOR GREEN   
50 PSET A,B+20

BOX

Write a filled rectangle on the screen using the foreground color. x1,y1 is upper left corner, x2,y2 is lower right corner

 Syntax:

    BOX column , row , column,row // x1,y1,x2,y2
10 COLOR RED   
20 BOX 2,10,12,20
20 BOX A,B,C,D

Next