Custom GetValue () Function

In FileMaker , we have GetValue(list;valueNumber) to identify a value within a list.

For example:-

GetValue ( “john¶chris¶matt¶dave” ; 2 )  = chris

GetValue ( “john¶chris¶matt¶dave” ; 3 )  = matt

This “¶” is the default delimiter set by FileMaker.
Suppose ,we have a condition in which the list data is having 2 or more carriage returns (“¶”) for each data ,

then how can we distinguish the individual data.

For example:-

record 1 , fieldData = john¶chris

record 2 , fieldData = matt

record3 , fieldData = dane¶steve

By taking the list of all these records , we cannot identify the individual record’s data from GetValue() function.

We can come across this List situation in a number of odd environments.

*There is a solution for this.

Lets get the List of all required values in the way of ExecuteSQL ,separated by a delimiter (let’s say “|”).

For Exampe:-

listData = ExecuteSQL(“SELECT name FROM Contact WHERE country = ?” ; “”;”|”;”india”)

= john¶snow|matt|deman¶white|robin
There is a custom function ,i have developed for this purpose.

GetValueCustom(listData;delimiter;posn)
——————————————–

// GetValueCustom ( “abcd|dadsad|fsdadfds|”; “|” ; 2 ) = dadsad

// GetValueCustom ( “abcd|dadsad|fsdadfds|”; “|” ; 3 ) = fsdadfds

// GetValueCustom ( “abcd|dadsad|fsdadfds|”; “|” ; 1 ) = abcd

// GetValueCustom ( “abcd|dadsad|fsdadfds|”; “|” ; 4 ) = “”
// GetValueCustom ( “abcd|dadsad|fsdadfds|”; “|” ; 5 ) = “”

Let (

[ l = listData ;
d = delimiter ;
p = posn ;

noDem = PatternCount ( l; d );

dataInitialPos = Position ( l ; d ;1 ;posn -1 ) ;

dataFinalPos = Position ( l; d ; 1 ; posn )

];
If ( (noDem < 1) or not(posn < noDem + 1) ; “” ; Middle (l ; dataInitialPos+1 ; dataFinalPos – dataInitialPos -1) )

)

Leave a Reply