array Definition/BASIC Program, array Definition/BASIC Program

array

Command array Definition/BASIC Program
Applicable release versions: AP, R83
Category BASIC Program (486)
Description tables of values of any data type.

Each value in an array is called an "element" of the array and the elements are ordered. An array element is accessed by specifying its position in the array using a subscript variable. The variable must have one subscript for each dimension of the array. For example, in a two-dimensional array, the first subscript specifies the row, while the second specifies the column. If the second subscript is missing, it defaults to 1.

Pick/BASIC has two types of arrays:

Dynamic arrays:

A string can be handled as a three-dimensional array based on the three main system delimiters; attribute marks, value marks, and subvalue marks. These are called "dynamic arrays". "Dynamic" for the ability to insert and delete array elements without having initially declared the array size. A dynamic array is nothing more than a string.

Dimensioned arrays:

Dimensioned arrays are a one or two-dimensional array of separate variables. These are called "dimensioned" arrays due to the need to declare the number of array elements to the compiler or runtime with the "dim" statement.

Dimensioned arrays are also defined by the "file" statement. In this case, the Pick/BASIC compiler dimensions the array, using the file name as the array name. It determines the number of elements in the array from the program itself and the file dictionary. The array is dimensioned based on the maximum attribute number addressed in the program, plus 1.

Subscripts in dimensioned arrays are enclosed in parentheses.

Dimensioned arrays are limited to two dimensions (rows and columns). Additional dimensions can be obtained by referencing dynamic arrays from elements in a dimensioned array.

All elements within dynamic arrays are separated by delimiters. Dynamic arrays consist of fields (or sets of values) separated by attribute marks (char(254)). Each attribute or field in a dynamic array may consist of a number of values separated by value marks (char(253)). Each value may contain several subvalues separated by subvalue marks (char(252)).

Dynamic arrays do not have a fixed size, nor are they pre-dimensioned.

Subscripts in dynamic arrays are enclosed in angle brackets (<>). Dynamic arrays are limited to three dimensions (attribute, value, and subvalue). They are called dynamic because the number of elements can increase or decrease automatically.

In most cases, accessing a dimensioned array is significantly faster than accessing the same size dynamic array.

A dynamic array may be an element in a dimensioned array, in which case the dynamic array subscripts are specified following the dimensioned array subscript.

The following is a dynamic array element that has been referenced from the dimensioned array, "m":

m(a,b)<x,y,z>

where:

"a" is the row number of the dimensioned array
"b" is the column number of the dimensioned array
"x" is the attribute number of the dynamic array
"y" is the value number of the attribute
"z" is the subvalue number of the value

The element "m(a,b)" of the dimensioned array points to the beginning of the dynamic array.

In AP, dimensioned arrays may be re-dimensioned as many times as desired. See the example.
Syntax
Options
Example
max = 100
n = 1
dim a(max)
execute "select md"
loop
  readnext id else exit
  a(n) = id
  if (n >= max) then
    max += 100
    dim a(max)
  end
  n += 1
repeat

This loads all the item-ids from the current md into the dimenisoned array, 
"a".
Purpose
Related basic.dim
basic.array.dynamic
basic.lt
basic.read
basic.<
basic.assignment
basic.array.variable
basic.(
basic.)

array

Command array Definition/BASIC Program
Applicable release versions: AP, R83
Category BASIC Program (486)
Description tables of values of any data type.

Each value in an array is called an "element" of the array and the elements are ordered. An array element is accessed by specifying its position in the array using a subscript variable. The variable must have one subscript for each dimension of the array. For example, in a two-dimensional array, the first subscript specifies the row, while the second specifies the column. If the second subscript is missing, it defaults to 1.

Pick/BASIC has two types of arrays:

Dynamic arrays:

A string can be handled as a three-dimensional array based on the three main system delimiters; attribute marks, value marks, and subvalue marks. These are called "dynamic arrays". "Dynamic" for the ability to insert and delete array elements without having initially declared the array size. A dynamic array is nothing more than a string.

Dimensioned arrays:

Dimensioned arrays are a one or two-dimensional array of separate variables. These are called "dimensioned" arrays due to the need to declare the number of array elements to the compiler or runtime with the "dim" statement.

Dimensioned arrays are also defined by the "file" statement. In this case, the Pick/BASIC compiler dimensions the array, using the file name as the array name. It determines the number of elements in the array from the program itself and the file dictionary. The array is dimensioned based on the maximum attribute number addressed in the program, plus 1.

Subscripts in dimensioned arrays are enclosed in parentheses.

Dimensioned arrays are limited to two dimensions (rows and columns). Additional dimensions can be obtained by referencing dynamic arrays from elements in a dimensioned array.

All elements within dynamic arrays are separated by delimiters. Dynamic arrays consist of fields (or sets of values) separated by attribute marks (char(254)). Each attribute or field in a dynamic array may consist of a number of values separated by value marks (char(253)). Each value may contain several subvalues separated by subvalue marks (char(252)).

Dynamic arrays do not have a fixed size, nor are they pre-dimensioned.

Subscripts in dynamic arrays are enclosed in angle brackets (<>). Dynamic arrays are limited to three dimensions (attribute, value, and subvalue). They are called dynamic because the number of elements can increase or decrease automatically.

In most cases, accessing a dimensioned array is significantly faster than accessing the same size dynamic array.

A dynamic array may be an element in a dimensioned array, in which case the dynamic array subscripts are specified following the dimensioned array subscript.

The following is a dynamic array element that has been referenced from the dimensioned array, "m":

m(a,b)<x,y,z>

where:

"a" is the row number of the dimensioned array
"b" is the column number of the dimensioned array
"x" is the attribute number of the dynamic array
"y" is the value number of the attribute
"z" is the subvalue number of the value

The element "m(a,b)" of the dimensioned array points to the beginning of the dynamic array.

In AP, dimensioned arrays may be re-dimensioned as many times as desired. See the example.
Syntax
Options
Example
max = 100
n = 1
dim a(max)
execute "select md"
loop
  readnext id else exit
  a(n) = id
  if (n >= max) then
    max += 100
    dim a(max)
  end
  n += 1
repeat

This loads all the item-ids from the current md into the dimenisoned array, 
"a".
Purpose
Related basic.dim
basic.array.dynamic
basic.lt
basic.read
basic.<
basic.assignment
basic.array.variable
basic.(
basic.)