EasyManua.ls Logo

Sinclair QL - Page 202

Sinclair QL
422 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...
If
necessary SuperBASIC
will
convert the type of
unSUItable
data
to
a type which
will
allow the specified operation
to
proceed.
The
operators used determine the conversion required. For example,
If
an operation
requires a
stnng parameter and a numeric parameter
is
supplied then SuperBASIC will
first
convert the parameter
to
type string.
It
is
not always possible
to
convert data
to
the
required form and
if
the data cannot be converted
an
error
is
reported.
The type of a
function
or
procedure parameter can also be converted
to
the correct
type.
For
9xample, the SuperBASIC LOAD command requires a parameter of type name
but can accept a parameter of type string and which
will
be converted
to
the correct
type by the procedure Itself Coercion
of
this form
IS
always dependent
on
the way the
function or procedure was implemented.
There
is
a a natural ordering of data types
on
the OL, see figure. String
is
the most
general type since
It
can represent names, floating
pOint
and mteger numbers. Floating
point
is
not
as
general as string but
It
is
more general than integer since floating
pOint
data can represent Integer data (almost exactly). The figure below shows the ordering
diagramatlcally. Data can
always
be converted moving up the diagram but
It
is
not
always
possible moving down.
not
always
possible
string
/'-
floating
point
integer
always
possible
.
coercion
a
:::
b + c
a%
= b + c
a$
=
b$
+
c$
LOAD
"mdv1
dat
a"
(no conversion
is
necessary before performing the
example
addition. Conversion
is
not necessary before assigning
the result
to
a.)
(no conversion
is
necessary before performing the
addition but the result
is
converted
to
integer before
assigning)
(b$ and c$ are converted
to
floating point,
if
possible,
before being added together. The result
is
converted
to
string before assigning.)
(the string
"mdv1_data"
is
converted
to
type name by
the load procedure before
it
IS
used.)
Statements can be written
in
SuperBASIC which would generate errors
in
most other
comment
computer languages.
In
general
it
is
possible
to
mix data types
In
a very flexible manner:
12/84
i.
ii.
PRINT
"1
11
+ 2 + "3"
LET a$
:::
1 + 2 + a$ +
"4"
11

Other manuals for Sinclair QL

Related product manuals