Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FlexFile Reference Guide - <b>a_scan()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 A_SCAN()
 Scan an array or part of an array for an expression
-------------------------------------------------------------------------------

 Syntax

    A_SCAN(  <aTarget>,
             <expSearch>,
             [<idxPos>],
             [<nCount>] )    ->    nAbsPos

 Arguments

    <aTarget> The array to scan.

    <expSearch> An expression that evaluates to the same type as the
    <aTarget> array.

    <idxPos> is the first position to in the <aTarget> array to be
    scanned.  If not specified, the default value is the first element
    of the array.

    <nCount> is the number of elements to scan starting at <idxPos>.
    If not specified, elements are searched to the end of the array.

 Returns

    A_SCAN() returns an integer which is the absolute index pointer to
    the first element found that matches .  If no match is found
    A_SCAN() returns 0.  The <nAbsPos> can and should be used in any
    further references to that element (see example below).

 Description

    A_SCAN() is used to search a FlexFile array for a value.  A_SCAN()
    will return an error if <expSearch> evaluates to a different type
    than the <aTarget> array.

    Wrapping will occur if <nCount> goes beyond the current row
    pointed to by <idxPos>.  For example, if you have a two
    dimensional array with accounts represented by the first dimension
    and 12 prior period amounts in the second dimension, and you
    wanted to scan the first quarter (i.e.  3 periods) for a value,
    making <nCount> three times the number of accounts will "wrap"
    around three periods.  See the discussion on wrapping in the
    Arrays Chapter.

 Examples

    LOCAL ffArray, ptr, rows, cols

    rows = 5
    cols = 8

    // Declare a FlexFile floating point type array.
    ffArray = A_DECLARE( 'F', 5, 8 )

    // Store a couple of values.
    A_STORE( ffArray, 1234.56, A_( 3, 3 ) )
    A_STORE( ffArray, 789.10, A_(4, 4) )

    // Scan the entire array...
    ptr = A_SCAN( ffArray, 789.10 )
    ? A_RETRIEVE( ffArray, ptr )          // Result: 789.10

    // Scan starting at the first element in the fourth row.
    ? A_SCAN( ffArray, 1234.56, A( 4, 1 ) )   // Result: 0

    // Scan starting at the first element in the third row.
    ptr = A_SCAN( ffArray, 1234.56, A_( 3, 1 ) )
    ? A_RETRIEVE( ffArray, ptr )          // Result: 1234.56

    // Scan starting at the first element in the second row
    // but only count for one row.
    ? A_SCAN( ffArray, 1234.56, A_( 2, 1 ), cols )  // Result: 0


See Also: A_STORE() A_DECLARE() A_RETRIEVE()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson