-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist.position.fmfn
56 lines (50 loc) · 1.53 KB
/
list.position.fmfn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* =====================================================
* @function list.position ( values; search )
*
* @parameter values (list)
* @parameter search (string)
*
* @return number The list line number that matches the supplied search string.
*
* @category list
* @copyright 2013, Jason P. Scharf
*
* @version 1.0.0
*
* @dependencies NONE
*
* @purpose Get the position of the first whole value that matches the supplied
* search string.
*
* @notes Based upon list.position by Matt Petrowsky
* (https://github.com/petrowsky/fmpfunctions/blob/master/list.position.fmfn)
* @/notes
*
* @todo Currently case sensitive: add case sensitive flag or make it disregard
* case
*
* @changes
* 2014-03-28, JPS, Recreated to use tags and using a better placeholder.
* @/changes
* =====================================================
*/
Let (
[
/************************/
/* Start Configuration **/
/************************/
values = List ( "apple"; "pear"; "grape"; "orange" );
search = "pear";
/* CONSTANTS ************/
TAG = Char ( 26 ); /* (0026, 001A) SUB */
/************************/
/* End Configuration ****/
/************************/
~substituteValue = Substitute ( ¶& values &¶ ; ¶& search &¶ ; ¶ & TAG & ¶ );
~valuesCleared = Filter ( ~substituteValue; ¶ & TAG & ¶ );
~extractPosition = Position ( ~valuesCleared; TAG; 1; 1 ) - 1;
~cleanupPosition = Max ( 0; ~extractPosition )
];
~cleanupPosition
)