AIdx: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
(edit)
 
No edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
AIDX (array name)
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 '''AIDX''' [[internal function]] returns an [[array]] that is an ascending index obtained from sorting the array within parenthesis. The array to be sorted may be either string or numeric. '''The use of AIDX is 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.
'''Note''' that you cannot use the '''[[Mat]]''' keyword in the ''array name'' parameter of this function.
 
Correct:
 
  00010 MAT AscendingIndexArray(UDIM(ArrayToBeIndexed$))=AIDX(ArrayToBeIndexed$)
 
Incorrect:
 
00010 MAT AscendingIndexArray(UDIM(ArrayToBeIndexed$))=AIDX(MAT ArrayToBeIndexed$)


===Comments and Examples===
===Comments and Examples===
Line 16: Line 24:
  00150 READ MAT N$ EOF 155
  00150 READ MAT N$ EOF 155
  00155 MAT N$(CNT)
  00155 MAT N$(CNT)
  00160 MAT A(UDIM(N$))=AIDX(N$)
  00160 MAT A(UDIM(N$))=AIDX(N$) !
  00170 FOR I=1 TO 15
  00170 FOR I=1 TO 15
  00180 PRINT N$(A(I))
  00180   PRINT N$(A(I))
  00190 NEXT I
  00190 NEXT I


===Related Functions===
===Related Functions===


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


===Technical Considerations===
===Technical Considerations===
Line 29: Line 37:
# The [[RD]] specification in [[BRConfig.sys]] can affect the AIDX function because it determines when two numeric values are considered equal.
# The [[RD]] specification in [[BRConfig.sys]] can affect the AIDX function because it determines when two numeric values are considered equal.
# 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.
# 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.
# To use AIDX, the arrays on both sides of the equal sign must have the same dimensions.
# To use AIDX, the arrays on both sides of the equal sign must have only one dimension and they must be the same number of elements.


<noinclude>
<noinclude>
[[Category:Internal Functions]]
[[Category:Internal Functions]]
</noinclude>
</noinclude>

Latest revision as of 03:34, 23 May 2017

AIDX (<array name>)

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

Note that you cannot use the Mat keyword in the array name parameter of this function.

Correct:

00010 MAT AscendingIndexArray(UDIM(ArrayToBeIndexed$))=AIDX(ArrayToBeIndexed$)

Incorrect:

00010 MAT AscendingIndexArray(UDIM(ArrayToBeIndexed$))=AIDX(MAT ArrayToBeIndexed$)

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 MAT.

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 only one dimension and they must be the same number of elements.