
GeoBASIC Reference Manual
2.GeoBasic Constructs
TPS1100-Version 1.30
2-31
DIM dSum
AS Double
'for the summation
DIM iIndex
AS Integer 'the running index
DIM iLastIndex
AS Integer 'index of last element
'
to add
DIM NumberArray (iMaxIndex) AS Double
'array with the numbers
Then the following
WHILE
loop sums up
iLastIndex
(
≤
iMaxIndex
)
numbers of the array
NumberArray
. The resulting sum will be in
dSum
.
dSum
= 0
'so far the sum is zero
iIndex = 1
'the first index is 1
DO WHILE iIndex <= iLastIndex
'as long as we are
'
not at the end
dSum = dSum + NumberArray(iIndex) 'add the
' current element
iIndex = 1
'compute next index
LOOP
♦
Every
WHILE
loop can be transformed in an equivalent
UNTIL
loop and vice
versa. Have a look at the following
UNTIL
version of the summation.
dSum
= 0
'so far the sum is zero
iIndex = 1
'the first index is 1
DO
'loop
dSum = dSum + NumberArray(iIndex) 'add the current
' element
iIndex = 1
'next index
LOOP UNTIL iIndex > iLastIndex
'until we exceed
' the last index
♦
These two loops (the
WHILE
and
UNTIL
version) perform exactly the same
computation for
iLastIndex
>
0
. But for
iLastIndex
<=
0
,
dSum
remains
0
and
iIndex
remains
1
in the
WHILE
example, while in the
UNTIL
version
dSum
is set to the value of
NumberArray(1)
, and
iIndex
is incremented once.
2.6.3.3 The FOR-Loop
The three
Integer
expressions (
Start
,
Finish
,
Step
) are evaluated at the
outset. If the
Step
part is omitted,
Step
is set to
+1
by default. The values thus
obtained for
Finish
and
Step
are used throughout execution of the
FOR
-loop,
Содержание tps1100
Страница 1: ...GeoBASIC FOR TPS1100 User Manual Version 2 10 1997 2001 Leica Geosystems AG Heerbrugg Switzerland ...
Страница 150: ...GeoBASIC FOR TPS1100 Reference Manual Version 2 10 1997 2001 Leica Geosystems AG Heerbrugg Switzerland ...
Страница 411: ...GeoBASIC Reference Manual 6 System Functions TPS1100 Version 1 30 6 7 6 5 35 CSV_LibCallAvailable 6 213 ...
Страница 620: ...TPS1100 Version 2 10 6 1 ...
Страница 621: ......
Страница 623: ...TPS1100 Version 2 10 6 1 ...
Страница 624: ......
Страница 1053: ...TPS1100 Version 1 30 E 1 Appendix E GEOFONT ...
Страница 1154: ...GeoBASIC Reference Manual Appendix J List of Predefined Identifiers TPS1100 Version 1 30 J 9 TMC_SetOffsetDist 6 128 ...