FindIndex ( )

Function stats

Average user rating
4.0000
57
354
9999
Support
FileMaker 7.0 +
Date posted
29 March 2013
Last updated
04 April 2013
Version
Recursive function
No

Author Info
 Andries Heylen

11 functions

Average Rating 4.9

author_avatar



 

Function overview

Prototype

FindIndex  ( _array;   _value;   _startIndex;   _occurrence )


Parameters

_array  The list of values


_value  The value you want to find


_startIndex  The index from where you want to start your find


_occurrence  The occurrence of your value you want to find


Description

Tags:  value   list   index   array  

Finds the index of the value in the array

Examples

Sample input

GetIndex ( List ( 1 ; 10 ; 3 ; 10 ; 5 ) ; 10 ; 2 ; 1 )


Sample output

4

 

Function code

Let ( [
_le = ¶ & _list & ¶;
_start = Position ( _list ; ¶ ; 1 ; _startIndex - 1 )
_pos = Position ( _le ; ¶ & _value & ¶ ; _start ; _occurrence );
_lr = Left ( _le ; _pos );
_index = ValueCount ( _lr )
];
_index
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/354

    Prototype: FindIndex( _array; _value; _startIndex; _occurrence )
    Function Author: Andries Heylen (http://www.fmfunctions.com/mid/57)
    Last updated: 04 April 2013
    Version: 2.0

*/
// ===================================

 

Comments

Fabrice
30 March 2013



Hi Andries, I use this (additional _start and _occurrence parameters to mimic the Position fucntion and less calls to the calculation engine):

valuecount ( left ( ¶ & _list & ¶ ; position ( ¶ & _list & ¶ ; ¶ & _value & ¶ ; _start ; _occurrence )))
  General comment
Andries Heylen
04 April 2013



I would just adapt the start, so you actually calculate the real start index.

valuecount ( left ( ¶ & _list & ¶ ; position ( ¶ & _list & ¶ ; ¶ & _value & ¶ ; Position ( _list ; ¶ ; 1 ; _start - 1 ) ; _occurrence )))
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Layout  (15)
Interface  (15)
Text  (14)
Variables  (12)
Filter  (11)
Layout Objects  (11)
Design  (10)
Array  (7)