* Place template definitions

Post Reply
avatar
JoopvB
Superstar
Posts: 285
Joined: 02 May 2015 14:32
Family Historian: V7

Place template definitions

Post by JoopvB » 14 May 2021 13:44

I use, as many others I expect, a certain buildup of the place parts to create my own 'standard' way of showing a place. I use 4 parts:
1) City/Village/Town etc. (optionally followed by County/State/Province etc. between parenthesis e.g. York (North Yorkshire)
2) Location in the city e.g. Broad Road 36
3) Country e.g. UK
4) Extra text to describe the location e.g. on St. Luke's cemetery

Instead of {place} I now use: {=TextPart(%FACT.PLAC%, 4)} <in {=TextPart(%FACT.PLAC%, 1, 3, TIDY)}>

Using the above examples this gives: [he was buried] on St. Luke's cemetery in York (North Yorkshire), Broad Road 36, UK

This works well, but I have to replace {place} with the long phrase above in a great number of facts (everywhere... witnesses, languages etc.) How nice would it be to be able to redefine {place} as the phrase above? No changes required when I want to change the phrase later on and maximum flexibility.

I can even imagine this approach to be used for other codes like {date} {age} {address} etc.

Another option might be to introduce some kind of macro's where a (macro) name represents a text string. In the above case this might look like: {my_place} = the phrase above and have {place} replaced by {my_place}.

User avatar
tatewise
Megastar
Posts: 21748
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Place template definitions

Post by tatewise » 14 May 2021 14:30

There are two Wish List entries that already support that idea:
  1. Ref 498 User Defined Macros (or Custom Functions)
  2. Ref 547 Run Plugins via Expressions
You have already commented and voted on the 2nd which would solve your requirement.

Please vote on the 1st that could allow a macro such as =MyPlace() defined as:
=TextPart(%FACT.PLAC%, 4)=CombineText(" in ", TextPart(%FACT.PLAC%, 1, 3, TIDY), )

To make it more generally applicable in not just Sentence Templates but also Diagrams, Reports, etc, it might become:
=MyPlace("FACT") or MyPlace("INDI.BURI") defined as:
=TextPart(%$1.PLAC%, 4)=CombineText(" in ", TextPart(%$1.PLAC%, 1, 3, TIDY), )
where $1 it replaced by the 1st parameter FACT or INDI.BURI depending on context.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
JoopvB
Superstar
Posts: 285
Joined: 02 May 2015 14:32
Family Historian: V7

Re: Place template definitions

Post by JoopvB » 14 May 2021 15:44

Thanks Mike for reminding me of 547. I've now voted and commented on 498 also.

I guess that CP consider it a lot of work to introduce a macro builder into FH and consequently are not eager to have it high on their priority list. That's why I've now also suggested to make it possible to redefine some standard codes. That is not a big change (could be part of a preference) and would already solve a lot of what we are asking for.

User avatar
tatewise
Megastar
Posts: 21748
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Place template definitions

Post by tatewise » 14 May 2021 16:27

In my opinion, I don't think there is much difference in implementing macros versus redefining Sentence Template codes.
They are both essentially simple string substitution operations, but the former has MUCH wider application.
They will both need a similar user dialogue to define the macros/codes.
It is just that in one case the function format =Macro() is used and in the other the {code} format is used to invoke the text.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
JoopvB
Superstar
Posts: 285
Joined: 02 May 2015 14:32
Family Historian: V7

Re: Place template definitions

Post by JoopvB » 14 May 2021 21:15

The difference is mainly in 1) how extensive the macro handling will be and 2) the need to update (sometimes) a lot of sentences. In case of the {place} example) it would need a modification of virtually every sentence, whilst a redefined {place} would work without changing anything.

My preference would be to have all options (redefinition, macro and plugin) , but I was also thinking about how to motivate CP in providing something in this direction and from that angle redefinition seemed to be the most easy and quick to implement option.

User avatar
tatewise
Megastar
Posts: 21748
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Place template definitions

Post by tatewise » 16 May 2021 14:29

1) how extensive the macro handling will be
The macro processing is the fairly easy part. It is not much more than string substitution even if parameters are involved.
I suspect it is the user dialogue with custom files that take far more effort and are very similar, whichever variant is adopted.
My work with plugins confirms that.

2) the need to update (sometimes) a lot of sentences
That is not strictly the concern of CP unless they were to provide some global editing feature.
See Search & replace in Role sentence templates (19400) that shows how easy it is to globally edit Fact Sets.
( I have also been contemplating enhancing the Search and Replace plugin to support files such as Fact Sets. )

BTW:
I have felt for a long time that the Sentence Template codes like {place} and {address} are an oddity compared to other Expressions and could easily be FH functions like =Place() and =Address() so that Sentence Templates have the same syntax as other Expressions used all over FH. Then there would be no distinction between 'code substitution' and 'function macros'. If it weren't for the codes I don't think there is any need for { curly brackets } in Sentence Templates at all. They aren't needed in any other Expressions, not even in Diagram Text Scheme Items that need a similar mixture of plain text, functions & data refs.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
JoopvB
Superstar
Posts: 285
Joined: 02 May 2015 14:32
Family Historian: V7

Re: Place template definitions

Post by JoopvB » 17 May 2021 20:17

Ad 1) macro handling
Yes, I meant the user dialog; the macro processing as such shouldn't be too difficult.

Ad 2) sentence updates
I read 19400 but don't agree with "see how easy it is to globally edit Fact Sets". With enough knowledge (and access to this forum) everything (at least almost) is doable but in my view something as elementary as a global change over a lot of customized fact sentence definitions should be possible within the work field of FH and the supported plugins.

I very much support your idea of extending your indispensable and powerful Search an Replace plugin to also support FH files in and outside the project!

Ad BTW) I agree and can even see that CP might agree with the more easy and powerful function approach. Maybe up- and downward compatibly issues are holding them back? On the other hand these might easily be overcome by introducing the function approach next to the current codes and start promoting this as the way forward?

User avatar
tatewise
Megastar
Posts: 21748
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Place template definitions

Post by tatewise » 17 May 2021 21:59

Yes, I assumed access to this forum and that this whole topic involves advanced features.

I'll put Search and Replace within any text files on my to-do list.

If CP switched to functions in place of codes they could continue to provide backward support for codes, or auto-convert each code to its equivalent function as part of the update process. The snag would be interoperability between FH earlier versions that support codes and FH later versions that support functions. So, yes, codes and functions supported in parallel may be best.

That then poses the question of what are the most desirable features to request in the Wish List?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
JoopvB
Superstar
Posts: 285
Joined: 02 May 2015 14:32
Family Historian: V7

Re: Place template definitions

Post by JoopvB » 18 May 2021 10:34

Most desirable for the wish list... is, I guess user dependent, but from a "general" CP point of view my list would be:
1. =Individual(), =Principal(), =Spouse(), =Couple()
with parameters for all the sub options such as his/her etc. Benefit is easy future extensions.
2. =Date()
with parameters for format (and maybe language).
3. =Age()
with parameters for what and how to use to calculate e.g. use baptized and burial dates if birth and/or death date is missing.
4. =Place()
with parameters for placing the different parts and non-standard prefixes
5. =Address()
same as Place; maybe combined into one =Place() with parameters describing what to use and/or combine.
6. =FactData()
with parameters to select what fact data and how to use (e.g. for {value}, {cause}, {label} etc.)
7. =Role()
with parameters to specify the name(s) of the witnesses and/or principals and how to use them (e.g. 1 or multiple and
what part of the name to use etc.).

Altogether a short list, that pretty well covers all current codes, is easily extendable and leaves a lot of room for macro's user defined functions (plugin's) etc.

User avatar
tatewise
Megastar
Posts: 21748
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Place template definitions

Post by tatewise » 18 May 2021 15:03

That wasn't quite what I was asking but it seems you want to go with Ref 498 User Defined Macros (or Custom Functions) and add a new request for Sentence Template Functions to Replace Codes.

We could just summarise the requirement and leave the details to CP, or provide a list of examples similar to your list.
However, the list should dovetail with the current functions noting that =Date() and =Individual() already exist.
A comprehensive list could be as below where the context allows one function to replace several codes.
e.g. =Principal() refers to the principal individual or family couple whether in a principal or witness sentence.
  1. {individual} {individual/him/her} {individual's} {principal} {couple} {principals}
    =Principal() name of principal individual or names of family couple with parameters for variant options.
  2. {spouse/her/him}
    =Spouse() name of principal's spouse with parameters for variant options.
  3. {him/her} {his/her}
    =Sex(%CUR_PRIN%,"him","her","them") =Sex(%CUR~WITN>%,"his","her","their") use existing function.
  4. {date}
    =FactDate() with parameters for format and prefixes.
  5. {age} {age range} {their ages} {their age ranges}
    =FactAge() with parameters for what and how to calculate, e.g. use actual or estimated birth date.
  6. {place} {_place} {_place2}
    =FactPlace() with parameters for arranging parts and prefixes.
  7. {address}
    =FactAddr() similar to =Place() or combined with =Place() in a composite =Location() function.
  8. {cause} {note}
    %FACT.CAUS% %FACT.NOTE2% %FACT.TYPE% %FACT.PHON% use existing data references.
  9. {label} {abbr}
    =FactLabel() =FactAbbr() use existing functions.
  10. {value} {a/an value}
    =FactValue() existing function but with parameters for options and prefixes, or simply use %FACT%.
  11. {children} {spouses}
    =TextIf(FactValue()="1","child","children") =TextIf(%FACT%="1","spouse","spouses") use existing function.
  12. {role name} {role=___} {role(single)=___} {role(plural)=___} {other=___} {other(single)=___} {other(plural)=___}
    =Role() with parameters for options and role names.
  13. {blank} <br> <para>
    =Format() with parameters for layout options such as "\n\n" or "\t" or maybe fonts.
  14. < ... >
    =CombineText() existing function with parameters for prefix, variable text, suffix, and empty text.
    This avoids the confusion users experience when more than one variable text is inside < angle > brackets.
With the above functions, previously impossible structures become feasible.
e.g. {=TextIf( x=y, {date:YEAR}, "else" )} is invalid but =TextIf( x=y, FactDate(":YEAR"), "else" ) is allowed.
Also the \ escape character is no longer needed.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
JoopvB
Superstar
Posts: 285
Joined: 02 May 2015 14:32
Family Historian: V7

Re: Place template definitions

Post by JoopvB » 18 May 2021 17:23

If your comprehensive list gets implemented by CP (fingers crossed) sentence creation will certainly be more flexible and powerful, but also IMHO easier for the user and easier to maintain when changes to codes that are used in many definitions are needed. And as an extra benefit for CP: more concise, open to future extensions and better fitting in with the built-in functions.

Mike, I support it 100%; please add it to the Wish List and hope that CP reads it.

User avatar
tatewise
Megastar
Posts: 21748
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Place template definitions

Post by tatewise » 19 May 2021 13:00

I've created Wish List Ref 577 Sentence Template Functions to Replace Codes. Are you happy with what it requests?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
JoopvB
Superstar
Posts: 285
Joined: 02 May 2015 14:32
Family Historian: V7

Re: Place template definitions

Post by JoopvB » 19 May 2021 19:26

Quite! Thanks Mike.

Now let's hope CP are willing to also think along these lines!

Post Reply