Page 1 of 1
Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 08:17
by shoshk
It looks like Style Codes are not available in the Record Title format. Why?
My current titles include the person's name in the format SURNAME, Given. My husband wants to keep it that way but I don't see an easy way to do it with templated sources. I can program it, but would prefer not to.
Should I add it to the wish list?
Re: Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 10:10
by Jane
The record title is not a Rich Text note field, it's a standard text field, which is populated by the template when the templated source is entered or changed, by default.
If you want to edit it manually untick the Auto Generated option next to the title field in the Citation Window.
Re: Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 11:40
by tatewise
Sorry, but I don't understand the problem
The name format SURNAME, Given is nothing to do with Style Codes.
In the Source Templates I've looked at, that have a Name field, they simply repeat whatever is entered as the Name in the Title.
So if you enter the Name as SURNAME, Given then that is what you get in the Title.
Re: Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 12:12
by shoshk
I need 2 versions of the name. In addition to using SURNAME, Given in the title, I use Given Surname in the formatted footnote.
I guess I'll take care of this programmatically. It's not difficult because our sources are all created via plugin (currently being rewritten to take advantage of new features in FH7). I simply prefer to let FH do the heavy lifting whenever possible.
Re: Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 12:45
by tatewise
OK, that is possible.
Enter the Name using the SURNAME, Given format and construct the Footnote Template to extract the two name parts, reverse them and adjust the SURNAME to Surname:
{=Section(%SOUR.~TX-NAME%,2,",")} extracts the 2nd Section of Given name(s) after the comma.
{=Text(LeftText(Section(%SOUR.~TX-NAME%,1,","),1).ToLower(MidText(Section(%SOUR.~TX-NAME%,1,","),2)))}
This extracts the 1st Section before comma, leaves left-hand character in capitals and makes the remainder lower case.
The Text concatenation is needed because otherwise a space gets inserted between the functions.
Re: Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 13:34
by shoshk
Pretty much (if not all) the fields in the source template are filled in automatically by the plugin.
One of the features of my plugin is that is copies (can copy) much of its data from the source (using copy and paste) from the webpage. Often, the name is in the format Given Surname.
I think I'll just add two fields to the source template for the uppercase version of the surname -- TX-SURNAME_1 and TX-SURNAME_2. It's trivial to add a few lines to the plugin to fill in these fields.
I was just hoping that this business could be handled by FH, but I understand why style codes don't apply in the title format
Re: Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 14:35
by tatewise
I'm not sure why you keep mentioning Style Codes.
They have nothing to do with manipulating plain text and changing case.
The code I posted are NOT Style Codes, which are to do with bold, italics, underline, and suchlike.
However, I could not devise codes to convert Given Surname to SURNAME, Given so you will have to use two fields.
Re: Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 14:39
by shoshk
I know I can't use Style Codes in the Record format. I wish I could. That would allow me to format the surname as uppercase without writing more code.
Re: Source Templates, Style Codes and Record Title formats
Posted: 28 Jan 2021 14:46
by tatewise
Shosh, I will say it once again and then shut up.
Style Codes DO NOT CHANGE CASE or SWAP WORDS they ONLY affect font style like bold, italic, underscore.
The codes I posted earlier would work in the Record Title Template just as well as in the Footnote Template.
They are ONLY manipulating plain text and not font styles.
They just convert from SURNAME, Given to Given Surname and no Style Codes are involved.
I simply can't work out the codes need to convert from Given Surname to SURNAME, Given because there is no convenient delimiter (,).
The code that converts to uppercase is {=ToUpper(...)} and that is a Function code not a Style Code.
Re: Source Templates, Style Codes and Record Title formats
Posted: 29 Jan 2021 05:42
by shoshk
As always, morning wake-up gave me a simple solution which is taken from the idea proposed by you.
I had not considered using FH functions within the title format.
I won't be adding (and maintaining an extra field). The following expression gives me exactly what I need:
Code: Select all
{=ToUpper(%SOUR.~NM-Name_Recorded_1:SURNAME%)}, {Name_Recorded_1:GIVEN}
Thank you for your persistence which clearly triggered the little guy in my brain who keeps pondering while I sleep.

Re: Source Templates, Style Codes and Record Title formats
Posted: 29 Jan 2021 11:11
by tatewise
Yes, excellent. I had not realised you were using a Name (NM) meta-field rather than a Text (TX) meta-field.