EasyManua.ls Logo

Commodore VIC-20 - Page 142

Commodore VIC-20
404 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
128
The
VIC
20
User
Guide
This cursor movement subroutine will be an integral part
of
creating
and using formatted displays.
The
CHR$
Function:
Programming
Characters
In
ASCII
If
you cannot presS a key to include a character within a text string, you
can still select the character by using its ASCII value.
The CHR$ function translates an ASCII code number into its charac-
ter equivalent. This
is
the format
of
the CHR$ function.
PRINT
CHR$(xx)
tL-----ASCII
number from 0 to
255
of
desired character or control
To
obtain the ASCII code for a character, refer to Appendix
B.
Scan
the columns until you find the desired character
or
cursor control, then note
the corresponding ASCII code number. Insert this number between the two
parentheses of the CHR$ function.
For
example,
to
create the symbol $
from its ASCII code, look up ASCII code for $ in Appendix
B. You will
notice that $ has two ASCII values:
36
and
100.
Which value should you use?
Either number works. But for good programming technique, once you select
one number over the other, use that number consistently throughout the
program. Insert
36
into the CHR$ function as follows:
PRINT
CHRt(36)
Try displaying this character ($) in immediate mode:
PRHIT
CHR~(36)
$
Now try displaying ASCII code
100.
PRINT
CHR$(
Hl0)
$
The result
is
the same. Experiment in immediate mode using any ASCII
code from 0 to 255.
You can use the CHR$ function in a
PRINT
statement as follows:
10
PRINT
CHRt(36)iCHR$(42)iCHR$(166)
RUN
$*-

Other manuals for Commodore VIC-20

Related product manuals