AIdx

From BR Wiki
Revision as of 11:33, 12 January 2012 by Mikhail.zheleznov (talk | contribs) (edit)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

AIDX (array name)

The AIDX internal function returns an array that is an ascending index obtained from sorting the array named. The array to be sorted may be either string or numeric. Permitted only in the MAT statement.

The Mat may not be used in the array name parameter of this function. Rather than (Mat X), (X) will specify the X array.

Comments and Examples

The program below will sort and print an array of names in alphabetical order:

00100 DIM A(100),N$(100)
00110 DATA "Tom", "Colleen", "Bill", "Christi"
00120 DATA "Tim", "Dave", "Sheila", "Jenni"
00130 DATA "Pam", "Laura", "Jean", "Michele"
00140 DATA "Gary", "Gordon", "Mallika"
00150 READ MAT N$ EOF 155
00155 MAT N$(CNT)
00160 MAT A(UDIM(N$))=AIDX(N$)
00170 FOR I=1 TO 15
00180  PRINT N$(A(I))
00190 NEXT I

Related Functions

Other functions that operate on arrays are DIDX (array sort with descending index), SRCH, SUM and UDIM. See also the MAT statement.

Technical Considerations

  1. The RD specification in BRConfig.sys can affect the AIDX function because it determines when two numeric values are considered equal.
  2. The COLLATE option in effect when the program was last saved or in the Option (statement) can alter the sort order from the AIDX function when sorting string values.
  3. To use AIDX, the arrays on both sides of the equal sign must have the same dimensions.