Brian Dunning's FileMaker Custom Functions

PutValue ( ValueList ; ValueNumber ; ReplaceString )

Replaces a designated value in a value list with another value

  Average rating: 5.0 (24 votes) Log in to vote

Bill Thurmes   Bill Thurmes
MDCA
http://www.miyotadca.com

Share on Facebook Share on Twitter

  Sample input:
PutValue ( "1¶3¶5" ; 2 ; "yellow" )
PutValue ( "1¶3¶5" ; 5 ; "yellow" )
PutValue ( "1¶9¶3¶577¶6" ; 3 ; GetValue ( "1¶9¶3¶577¶6" ; 3 ) & ¶ & "yellow" )
  Sample output:
"1¶yellow¶5"
"1¶3¶5¶¶yellow"
"1¶9¶3¶yellow¶577¶6"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This function is a complement to GetValue, replacing a given value number with ReplaceString
ValueList is a ¶-delimited value list
If ValueNumber > the number of values in ValueList then the function adds extra ¶s to allow the new value
(recursive only if new ¶s need to be added - this is a new feature in 2016)
If successful the function returns the new value list complete with ReplaceString
ReplaceString can include ¶, so Result may contain more values than ValueList, but never fewer
If Replacestring = "" then value ValueNumber will be empty
Example of use:
Sorting multi-attribute lists (like element symbols and # of atoms of that element)
(Loop through $count1)
(Loop through $count2)
If LeftWords ( GetValue ($ValList ; $count2 ) ; 1 ) < LeftWords ( GetValue ($ValList ; $count1) ; 1 )
Set Variable $Temp to GetValue ( $ValList ; $count1 )
Set Variable $valList to PutValue ( $ValList ; $count1 ; GetValue ($ValList ; $count2 ))
Set Variable $ValList to PutValue ($ValList ; $count2 ; $Temp )
(End loops)

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.