![QSI QTERM-R55 User Manual Download Page 18](http://html1.mh-extra.com/html/qsi/qterm-r55/qterm-r55_user-manual_3304037018.webp)
8
QTERM-R55 User's Manual
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
More examples are listed in Table 2-0.
Further information can be found in any textbook on the C
programming language.
The
val()
function converts its string argument to a num-
ber (see conversion of
"23"
in the Example 3). Note that
"e2"
is converted to
0
because this string is not a valid
number.
2.4.4
Finding Strings in Strings
The
instr()
function returns the position of its second
string argument within the first.
instr()
returns zero if
the string cannot be found.
instr("Hallo","al")
in Example 3 returns 2
because
"al"
appears at position 2 within
"Hallo"
.
instr("Hallo","Al")
returns 0, because
"Al"
is not
contained in
"Hallo"
(the case doesn't match).
2.4.5
Changing the Case of Strings
lower$()
and its counterpart
upper$()
convert their
string argument to all lower or all upper case characters
respectively.
lower$("aBcD12fG")
returns
"abcd12fg"
as
shown in Example 3.
2.4.6
Removing Spaces
ltrim$()
and
rtrim$()
are two functions to remove
leading or trailing spaces from a string.
trim$()
removes
both leading and trailing spaces.
ltrim$(" foo ")
returns
"foo "
and
rtrim$(" foo ")
returns
" foo"
.
trim$(“
foo “)
returns “foo”.
Value
Value is the variable to be con-
verted
Flag
OPTIONAL – One or more flags
can be used to modify the result of
the output, as follows
–
Left adjustment of the output in
the specified field width
+
Number will be printed with a
sign
space
If the first character does not con-
tain a sign, a space will be added
0
Leading zeros will pad the field
#
A decimal point will always be
added. For
g
and
G
formats (see
below), trailing zeros will be
removed
Fieldwidth
REQUIRED – A number that
specifies the minimum width of
the field. The output will be
printed in a field at least this wide,
wider if necessary. The fewer
characters than specified. Padding
on the right will occur if left
alignment (– ) was used.
. (period)
OPTIONAL (required if precision
is used) – Separates the
Field-
width
from the
Precision
.
Precision
OPTIONAL – Maximum number
of characters to be printed after
the decimal point for
e
,
E
, and
f
output. For
g
and
G
, it represents
the number of significant digits.
Argument
f
f
Floating point ouput:
(
–)xxx.yyy
The number of
y
digits is
specified
by the
Precision
6 is the default precision, 0
will suppress the decimal
point unless the # flag is used
e
,
E
Floating point ouput:
(–)xx.yyyye
zz
or
(–)xx.yyyyE zz
The number of y digits is
specified by
the
Precision
6 is the default precision, 0
will suppress the decimal
point
g
,
G
Floating point ouput:
%e
or
%E
are used if the
exponent is less than
-4
or
greater than or equal to the
Precision
, otherwise use
%f
. Trailing zeros and deci-
mals are not printed.
Table 2-0. More Examples Using the str$ Function.
Print Statements
Output
Produced
print "="
str$(12.12345,"%08.3f");
print "="
=0012.123=
print "=",
str$(12.12345,"%8.2f");
print "="
= 12.12=
print "=",
str$(12.12345,"%-6.2f");
print "="
=12.12 =