Skip to main content

Arraybase

ArrayBase (Statement)

Format

arraybase 0 or 1
array base 0 or 1

Description

By default an integer from 0 to one less than the length of an array is used to index values within an array. This behavior can be modified with the arraybase statement. You may specify either a zero (for default indexing) or 1 for indexing starting at 1 and going to the length of the array.

Example

arraybase 1
ar = {44,55,66,77,88}
for i = 1 to ar[?]
? i, ar[i]
next i

1 44
2 55
3 66
4 77
5 88

GetArrayBase (Function)

Format

getarraybase
getarraybase ( )

returns integer_expression

Description

Returns the array base currently in effect — 0 or 1 — as set by the ArrayBase statement. The default is 0.

This is useful in a Function, Subroutine, or Module that must index arrays correctly no matter which base the calling program has chosen.

Example

b = getarraybase
print "indexing starts at " + b

arraybase 1
print "indexing starts at " + getarraybase()

will print

indexing starts at 0
indexing starts at 1

See Also

ArrayBase, ArrayLength, Assigned, Dim, Fill, GetArrayBase, Map, Redim, TypeOf, Unassign, VariableWatch

History

2.0.0.0New To Version