Control characters

From DenialWIKI
Jump to navigation Jump to search

When programming the VIC-20 in BASIC, special control characters can be used to tell the VIC to execute specific tasks when the program is run. These special control characters appear as reverse-video symbols that will, upon execution, cause the cursor to move in a specific direction, change the colour of text output, or cause the screen to clear.

The control characters are obtained by pressing the SHIFT, CTRL or Commodore key at the same time another key is pressed (numbers 1 to 8 create colour control characters, for example). However, control characters can only be used WITHIN a pair of quotation marks. In most cases, this means that they are intended for use in conjunction with a PRINT or INPUT statement. The key combinations used to obtain control characters only work after the first quotation mark of a pair has been typed.

(NOTE: in the chart accompanying this article the Commodore + Number key colour combinations are intended for the C64 computer and will not work on a VIC-20).

COMPUTE control character chart.gif

An alternative way to get control codes:

  1. PRINT""
  2. Delete the last quote character
  3. Press CTRL+9 (RVS ON)
  4. Type the desired control code character
  5. Press CTRL+0 (RVS OFF)
  6. If you want to stay in quote mode, make one " and go on
  7. If you want to end the PRINT statement, make two "" and delete one

Now you may ask what nice little secrets you can obtain. Here is a possibly incomplete list, where CTRL is used to clarify it is a control code:

  • CTRL+H : Locks switching upper/lower case (C= + SHIFT)
  • CTRL+I : Unlocks case switching
  • CTRL+M : Carriage return, will be converted to a such in listings
  • CTRL+N : Switch to lower case
  • CTRL+R : RVS ON (duh)
  • CTRL+S : Home cursor (duh)
  • CTRL+SHIFT+N : Switch to upper case
  • CTRL+SHIFT+R : RVS OFF
  • CTRL+SHIFT+S : Clear screen