| Reference | 498 |
|---|---|
| Title | User Defined Macros (or Custom Functions) |
| Category | General |
| Description | A recent FH Mailing List
dialogue suggested that User
Defined Macros for Expressions
would make the exchange of complex Data References and Functions more reliable and convenient. This would allow 'experts' to create sophisticated expressions, or partial expressions, that others could use, without the risk of introducing basic syntax errors. Although User Defined Macros look like Functions, they actually use simple text string substitution logic. So for example =SpouseName() could be defined as %INDI.~SPOU[$1]>NAME[1]% where $1 represents the 1st macro parameter. Thus: =SpouseName(1) would become %INDI.~SPOU[1]>NAME[1]% the 1st spouse. =SpouseName(2) would become %INDI.~SPOU[2]>NAME[1]% the 2nd spouse. =SpouseName(3) would become %INDI.~SPOU[3]>NAME[1]% the 3rd spouse. (If an actual $ character were needed then it would be represented by $$.) To allow a list of spouse names with space separators it could be defined as %INDI.~SPOU[$1]>NAME[1]% . " " With the =CombineText() function and custom separators it would be =CombineText( $2, %INDI.~SPOU[$1]>NAME[1]% ) So for example =SpouseName(3," & ") would become =CombineText( " & ", %INDI.~SPOU[3]>NAME[1]% ) Alternatively, a complete spouse name list Macro called =AllSpouseNames(&) could be defined as =CombineText(,%INDI.~SPOU[1]>NAME[1]%,CombineText(" $1 ",%INDI.~SPOU[2]>NAME[1]%,CombineText(" $1 ",%INDI.~SPOU[3]>NAME[1]%,CombineText(" $1 ",%INDI.~SPOU[4]>NAME[1]%)))) |
| Web Link | http://www.fhug.org.uk/forum/viewtopic.php?f=46&t=6221 |
| Votes | 14 |
| Rating | 4.0 |
| Added | Wednesday 25th July 2012 |
| Last Vote | Thursday 13th October 2022 |
Only Signed in FHUG users can vote, please go to the Forum and sign in.