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 - Show more from this author
MDCA http://www.miyotadca.com |
PutValue ( "1¶3¶5" ; 5 ; "yellow" )
PutValue ( "1¶9¶3¶577¶6" ; 3 ; GetValue ( "1¶9¶3¶577¶6" ; 3 ) & ¶ & "yellow" )
"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)
10/16/2019 - Found that it was adding extra empty values to the end of a list, traced the problem to not using GetAsNumber when using a comparator, and fixed the problem
Comments
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.