Tandy 1000 Basic Reference Manual page 100

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I BASIC Keywords
ASC
Function
ASC(strZng)
Returns the ASCII code for the first character of
string.
ASC returns the value as a decimal number. If
string
is null, an
"Illegal function call" error occurs.
Example
P R I N T A S C ( " A " 1
prints 65, the ASCII code for A.
Sample Program
You can use ASC to be sure a program is receiving proper input.
Suppose you want to write a program that requires the user to
input hexadecimal digits
(0-9,
A-F). To be sure that only those
characters are input, and all other characters are excluded, you
can insert the following routine.
1 0 0 I N P U T "ENTER
A H E X A D E C I M A L V A L U E " ; N $
1 1 0
A
=
A S C C N $ )
' g e t
A S C I I c o d e
1 2 0 I F A > 4 7 AND A < 5 8 O R A > 6 4 AND A < 7 1 THEN P R I N T
" O K . " :
GOTO 1 0 0
1 3 0 P R I N T " V A L U E
NOT O K . "
:
GOTO 1 0 0
98

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents