AIdx: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Gordon.dye (talk | contribs) No edit summary |
||
(4 intermediate revisions by 2 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 | 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. | '''Note''' that you cannot use the '''[[Mat]]''' keyword in the ''array name'' parameter of this function. | ||
Line 31: | Line 31: | ||
===Related Functions=== | ===Related Functions=== | ||
Other functions that operate on [[arrays]] are [[DIDX]] (array sort with descending index), [[SRCH]], [[SUM]] and [[UDIM]]. See also | 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 37: | 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 | # 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
- 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.
- 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.