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 - Show more from this author
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)

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

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.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: