Brian Dunning's FileMaker Custom Functions

PropertyManager ( list ; name ; value ; action )

Custom function to manage propertylists

  Average rating: 4.3 (33 votes) Log in to vote

Reinder Wolting   Reinder Wolting
ABECON
http://www.abecon.nl

Share on Facebook Share on Twitter

  Sample input:
PropertyManager ( "¶b=2¶" ; "b" ; "" ; 0 )
PropertyManager ( "¶b=2¶" ; "a" ; "1" ; 1 )
PropertyManager ( "¶a=1¶b=2¶" ; "a" ; "4" ; 2 )
PropertyManager ( "¶a=1¶b=2¶" ; "a" ; "" ; 3 )
  Sample output:
2
"¶a=1¶b=2¶"
"¶a=4¶b=2¶"
"¶b=2¶"

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

Custom function to manage propertylists
You can add, replace or delete properties form the list or get is value.
This functions assumes that a list looks like this: ¶name1=value1¶name2=value2¶name3=value3¶...

Parameters:
list: the propertylist
name: the propertyname
value: the new value of the property
action: what to do; 0 stands for get, 1 for add, 2 for replace and 3 for delete

 

Comments

Serge   Serge
Apr 22, 2022
Thanks Reinder!

I've added a small fix in the version I use as it seems there's a little bug if you do an Add (e.g. name A, value 1) then another Add with same name A and value 2, your proposed code doesn't seem to do a replace (so you end up with 2 values A (A=1¶A=2 instead of A=2).

So I now have replaced:
If ( xPosition ; Replace ( list ; xStart ; xLength ; value ) ; list & name & "=" & value & "¶" ) ; // add

by:
If ( xPosition ; Replace ( list ; xStart ; xLength ; value ) ; list & if ( list = "" ; "¶") & name & "=" & value & "¶" ) ; // add

PS: Also it seems current version of FileMaker doesn't like to use "list" as a parameter anymore (reserved word?) so I have renamed that too.

Hope this helps.
 

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: