basic.array.references

Definition/BASIC Program, Releases: AP and R83

Referencing arrays.

Syntax

array.variable(ac.expression) array.variable(row.number,col.number) array.variable(adi) dynamic.array.variable<ac.expression> dynamic.array.variable<ac.expression, vc.expression> dynamic.array.variable<ac.expression, vc.expression, sc.expression>

Description

dimensioned and dynamic arrays may be referenced in Pick/BASIC programs.

Dimensioned array references have the form:

array.variable(num.expression)

-or-

array.variable(num.expression, num.expression)

Dimensioned arrays have a maximum of two dimensions and must first be defined with a 'dim' or 'dimension' statement.

When used in conjunction with the 'file' statement, dimensioned array elements may be referenced by the actual item-id of the attribute-defining item (adi) in the associated dictionary:

file entity
.
.
if fv.entity(name) = '' then

Dynamic (or 'string') array references have the forms:

1) dynamic.array.variable<ac.expression>

This form references an entire attribute location of a dynamic array.

2) dynamic.array.variable<ac.expression, vc.expression>
This form references a value within an attribute.

3) dynamic.array.variable<ac.expression, vc.expression, sc.expression>

This form references a subvalue within a value.

Combining dimensioned and dynamic array elements:

A specific value or subvalue of a dimensioned array can be specified using the following forms:

array(ac.expression)<ac.expression, vc.expression>

This references the element of the dimensioned array derived from the current value of 'ac.expression'. Within this array element, the value count derived from 'vc.expression' is referenced.

array(ac.expression)<ac.expression, vc.expression, sc.expression>

As in the previous case, with the additional reference to a subvalue location derived from 'sc.expression'.

Advanced Pick also allows every element within either type of array to be compared using an '*' as a wildcard character. The position of the '*' determines which element is searched.

Example

customer.item(1) = name

This assigns the value of 'name' to the first element of the
dimensioned array 'customer.item'.

customer.item<2,2> = address2

This assigns the value of 'address2' to the second value in the
second attribute of dynamic array 'customer.item'.

if array(*) = 'x' then...

This searches for any element in the dimensioned array 'array' equal
to the letter 'x'.

if customer.item<2,*> = '' then...

This searches for any value of attribute 2 in the dynamic array
'customer.item' equal to null string ('').

if customer.item<*,*,*> = '' then...

This searches for any subvalue in any value in any attribute in the dynamic
array 'customer.item' that is equal to a null string ('').

if array<*,1,*> = 'xxx' then...

This searches for any subvalue in value 1 in any attribute in the dynamic array
'array' that is equal to 'xxx'.

See Also

Command Name Type Description
basic.ac.expression Definition Derives an attribute count.
basic.matwrite Statement Writes dimensioned array to file.
basic.read Statement Reads item into dimensioned or dynamic array.
basic.matread Statement Reads item into dimensioned array.
basic.dim Statement Declares a dimensioned array.
basic.lt Relational Operator 'less than' operator.
basic.replace Function Replaces element in string expression.
basic.vc.expression Definition Derives a value count.
basic.num.expression Definition An expression which evaluates to a number.
basic.assignment Definition Assigns value to variable.
basic.array.dimensioned Definition a table where the contents of the elements can be altered (replaced) but the position of each element is fixed.
basic.write Statement Writes dynamic array to file.
basic.array.dynamic Definition A string variable delimited by reserved metacharacters.
basic.sc.expression Definition Derives a subvalue count.
basic.insert Function Inserts element into array.
basic.locate Statement Locates element in string expression.
basic.array.variable Definition References a dimensioned array.
basic.extract Function Extracts element from array.
basic.( Reserved Character used to surround arguments within functions, or to enclose subscript refererences within dimensioned arrays. It is also used to override the normal order of precedence evaluation.
basic.) Reserved Character surrounds arguments within functions, encloses subscript refererences within dimensioned arrays, and overrides the normal order of precedence evaluation.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.