Random Thoughtfulness
« FlowLayoutPanel BugContactFX :: Field Linking »

ContactFX :: Functions

  13/10/10 15:24, by scribbly, Categories: Development, Software, VB.Net, ContactFX

We've all grown up with spreadsheets and the ability to reference other cells and perform functions on other values, and probably rarely think how much that has changed our calculation experience... we just do it now.

So it seemed natural to include those abilities into ContactFX as our relationships are often much more complex than our spreadsheets.

I discussed in this post about field linking: that's the ability to include values from other fields and other contacts (even contacts from other file locations) into the contact data.

Functions add the ability to manipulate the linked data.

Current Functions

Initialise
Return the upper case initial letter plus a period (".")

{ INITIALISE name.additional }

If the text in the Additional Name field is "perry" the above function will return "P."

{ INITIALISE "some string" }

Will return "S."

UCase
Return the upper case of the string.

{ UCASE 1#name.family }

If the text in the Family Name field of Contact #1 is "mowbray" the above function will return "MOWBRAY"

{ UCASE "thiS Is a MiXeD sTrInG" }

This will return "THIS IS A MIXED STRING"

Join
This is a conditional join: if the object being joined is non-blank then it is joined to the previous joined result with the constant.

{ JOIN ', ' [ "me" , name.additional , { UCASE name.additional(2) } ] }

If the text in the first Additional Name is "myself" and the text in the second Additional Name field is "i" then the above function will return "me, myself, I"

{ JOIN ' :: ' [ "me" , "" , "you" ] }

Will return "me :: you".

Ternary
Well, like a ternary... if the Object is blank then the constant is returned otherwise the Object is returned.

{ name.additional ?? 'Additional Name is empty' }

If the Additional Name field is empty then the above function will return the constant "Additional Name is empty".

{ "" ?? 'Empty String' }

Will return "Empty String".

Conditional Pad
Pad the string with a constant if the string is not blank.

{ 'Mr. ' && name.family}

If the text in the Family Name field is empty the above function will return an empty string "".

If the Family Name field has the text "Mowbray" the above function will return "Mr. Mowbray"

{ name.family && ' esq.'}

If the text in the Family Name field is empty the above function will return an empty string "".

If the Family Name field has the text "Mowbray" the above function will return "Mowbray esq."

A real life example

{ { JOIN ' ' [ name.given , { INITIALISE name.additional } , { UCASE name.family } ] } ?? 'New Entry' }" />

When entered into the displayName field:
When

  • Given Name = "Perry"
  • Additional Name = ""
  • Family Name = "Mowbray"

Then
Display Name will display: "Perry MOWBRAY"

When

  • Given Name = "Sandra"
  • Additional Name = "Jane"
  • Family Name = "Mowbray"

Then
Display Name = "Sandra J. MOWBRAY"

Some other files that you can play with have been posted over on DonationCoder.

1 comment

Comment from: scribbly  
scribbly

I’ve just realised that identifying “constants” specifically limited functions unnecessarily, so I’ve re-written them so that the constants that were previously defined using single quotes (the functions PAD, TERNARY & JOIN are defined above with ‘’) are now defined using double quotes ("").

This also means that “constants” can also be functions or fields.

Now that is far more flexible!!

For example:
{ nickname ?? name.given } is legal
also:
{ nickname ?? { name.additional ?? name.given } }

19/10/10 @ 02:00
December 2014
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Scribbly is derived from the common name of one of the 10 Eucalypts that have insect trails (scribbles) in the bark. Eucalyptus haemastoma is a dominant species where I live and is commonly known as "Scribbly Gum".

The scribbles on the bark of these magnificent trees often reminded me of the journey of many of my projects: somewhat random, but beautiful in the end.

Search

  XML Feeds

powered by b2evolution
 

©2014 by Perry MOWBRAY

Contact | Help | b2evo skins by Asevo | multiblog | hosting companies