![QSI QTERM-R55 User Manual Download Page 16](http://html1.mh-extra.com/html/qsi/qterm-r55/qterm-r55_user-manual_3304037016.webp)
6
QTERM-R55 User's Manual
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
2.2.1
REM
The
REM
statement introduces comments. Everything after
REM
up to the end of the line is ignored. The
’
(apostrophe)
is an abbreviated replacement for
REM
.
2.2.2
Input
This statement reads one or more variables from the user.
The syntax for this command is
input [prompt] var1[,var2,...]
The optional [prompt] string after the
input
statement
(
"Enter two numbers:"
) is printed on the terminal
prior to reading any input. If the prompt string is omitted,
the terminal uses the “?” character to prompt the user. Note
that there is no semicolon or comma after this prompt
string. If multiple variables are requested, they are listed
after the prompt string, separated by commas.
The default input source is the keypad. This command may
also be used to read input from a serial port or the non-vol-
atile file store. See Serial Communication (section 2.8.4)
and Nonvolatile Storage of Data (section 2.10) for details.
2.2.3
The
statement writes all its arguments to the dis-
play. After writing its last argument,
advances the
cursor to the next line (as in
print "Hello ",a$,"
!"
). To do this, the QTERM-R55 inserts a carriage return
character (0x0D) and a linefeed character (0x0A) after the
string. To avoid this behavior, place a semicolon after the
last argument (as in
print "Please enter your
Name:";
).
Note that print can be abbreviated with a single question
mark (?). If you want to print (or input) at a specific loca-
tion, refer to Printing and Controlling the Screen (section
2.9).
The default output destination is the display. This com-
mand may also be used to send output to a serial port or the
non-volatile file store. See Serial Communication (section
2.8.4) and Nonvolatile Storage of Data (section 2.10) for
details.
2.3
Arithmetic
Example 2:
print 1+2,2*3,4/2,2^3
print sin(1.0),cos(pi),tan(3)
print asin(0.5),acos(0.7)
print atan(2),atan(1,2)
print exp(1),log(2),log(euler)
print int(2.34),frac(2.34)
mod(11,4)
print min(2,3),max(2,3)
print sqrt(2)
This program produces the following output:
3 6 2 83
0.841471 -1 -0.142547
0.523599 0.795399
1.10715 0.463648
2.71828 0.693147 1
2 0.34
3
2 3
1.41421
2.3.1
Operations
qaBASIC has five arithmetic operators:
+
(addition),
-
(subtraction),
*
(multiplication),
/
(division) and
^
(power); they all behave as expected, as in Example 2.
Note that the power operator (
^
) handles fractional powers:
8
^
(1/3)
returns
2
as a result.
2.3.2
Functions
This section demonstrates and explains the arithmetic func-
tions of qaBASIC.
2.3.2.1
Trigonometric Functions
Example 2 illustrates the six supported trigonometric func-
tions.
qaBASIC can calculate sine, cosine, tangent and their
inverses. All these functions expect their argument in radi-
ans; to facilitate the transformation from degrees to radians
(
radian=degree
*
pi/180
), there is a predefined vari-
able named
pi
(or
PI
) which has an initial value of
3.14159.
The
atan()
function has two forms. Called with a single
argument (e.g.
atan(2)
)
atan()
returns a value between
-pi/2 ... +pi/2. Called with two arguments (e.g.
atan(2,-
1)
)
atan()
returns a value between -pi and +pi. (This can
be useful when transforming from cartesian to polar coordi-
nates).
2.3.2.2
Exponentiation
The
exp()
functions comes with its inverse: the
log()
function. l
og()
and
exp()
operate with the base e