![QSI QTERM-R55 User Manual Download Page 19](http://html1.mh-extra.com/html/qsi/qterm-r55/qterm-r55_user-manual_3304037019.webp)
QTERM-R55 User's Manual
9
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
2.4.7
The ASCII Character Set Functions
qaBASIC offers two functions to work with the ASCII
character set.
asc()
converts a specific character to its ASCII value.
print asc("e")
returns 101 as a result (see Example
3), because the character
"e"
has position
101
within the
ASCII character set. Appendix A contains a complete 7-bit
ASCII chart.
Likewise the function
chr$()
returns the ASCII character
for a given position within the character set, e.g.
chr$(98)
returns
"b"
.
2.4.8
Escape Sequences
The most important non-printable characters can be con-
structed using escape sequences with the
\
character: The
sequence
\n
might be used instead of
chr$(10)
for the
newline character.
Table 2-1 lists all escape sequences of qaBASIC (these are
similar to the sequences used by the C-language).
These escape sequences are replaced within every pair of
double quotes (
""
), i.e. within literal strings. User input
read with the
input
statement is not affected in any way.
2.5
Conditions and Flow Control
Example 4:
input "Please enter a number" a
if (a>10) then
print "Hello ";
print "Your number is bigger than 10"
else
print "Byebye ";
print "Your number is less or equal 10"
endif
This program produces the following output:
Please enter a number
2
Byebye Your number is less or equal 10
Alternatively:
Please enter a number
11
Hello Your number is bigger than 10
Example 5:
input "Please enter a number" a
if a>10 and a<20 then
rem parentheses are optional
print "bigger than 10 ";
print "but less than 20"
fi
This program produces the following output:
Please enter a number
11
bigger than 10 but less than 20
Alternatively:
Please enter a number
10
Example 6:
label loop
? "Enter a string containing \"R55\""
input a$
if (instr(upper$(a$),"R55")<>0) then
gosub thanx
else
print "No, please try again !"
endif
goto loop
label thanx
print "Thanks a lot !"
return
This program produces the following output:
Enter a string containing "R55"
?thequickbrownfox
No, please try again !
Enter a string containing "R55"
?jumpedR55overthelazydog
Thanks a lot !
Table 2-1. Escape Sequences for qaBASIC.
Escape
Sequence
Resulting
Character
ASCII
Value
\n
newline
10
\t
tabulator
9
\b
vertical tabulator
11
\v
backspace
8
\r
carriage return
13
\f
form feed
12
\a
alert
7
\\
backslash
92
\‘
single quote
39
\”
double quote
34