Page 1 of 1

String function to get initials

Posted: 22 Jul 2016 19:14
by Seeker
I would like to write a custom query to be able to find a Miss F H Smith amongst my records. Is there a function which will give me the first letter of the First name and the first letter of the middle name?

If there were more than two initials I would need to find a space in middle name and then take the next character. (And repeat to the end of the name) As my example only has two initials before the surname I can forget about that.

I've tried looking through the functions in Help but cannot see one which might assist.

Re: String function to get initials

Posted: 22 Jul 2016 20:11
by tatewise
You are looking in the wrong area, because there are no Functions that perform that kind of operation.
(Although it is possible by writing a Plugin which does have those functions in Lua.)

You can get a long way in the Query itself by using the Rows filter tab.
Here are some clues and I am sure you can figure out the rest:

Exclude unless %INDI.SEX% matches Female.

Exclude unless %INDI.NAME[1]:SURNAME% matches 'Smith'.

Exclude unless %INDI.NAME[1]:FIRST% begins with 'F'.

Exclude unless %INDI.NAME[1]:MIDDLE% begins with 'H'.

Exclude unless %INDI.NAME[1]:MIDDLE% contains ' X'. Case-sensitive.

However, by the time you have written the Query you could have probably sorted the Records Window into Surname and Sex order, used the search filter for Smith F and just eyeballed the names. Unless you intend to generalise the Query to search for any Surname and Initials and thus make it re-usable.

BTW: You never replied to the explanations and suggestions in Custom queries - ability to select only if complete word (13061) so it got moved from New Wish List Requests to the General Usage Forum. Did you solve the problem?

Some of the suggestions made there are used here to solve similar search criteria.

Re: String function to get initials

Posted: 22 Jul 2016 22:20
by Seeker
Thank you for the prompt reply. I have created a generalised query.

My apologies for not replying sooner to your advice: I wanted to construct a list for a visit to a particular library and managed to get something close enough and then forgot all about my question.

I have this evening compiled a detailed reply and then tried to save it, but was asked for my user name and password and then it didn't save my work!

The essence of my reply was that Methods 2 & 3 require multiple searches and I have 13 job titles, so method 1 looks the most promising. But I do not understand how to use fact type queries: I could not find Occupation as a fact nor could I see how to get the individual's name etc into columns.

I have developed an individual query but as you say it only works for the first occupation of an individual.

Thank you for your assistance.

Re: String function to get initials

Posted: 22 Jul 2016 23:07
by tatewise
OK, some of your questions are partly answered by plagiarising a Standard Query such as All Facts.

Ensure that in the Query on the General tab, the Query Type is Fact.

To display the Name of who owns each Fact use one of the following Column Expressions.
1) =FactOwner(%FACT%,1,MALES_FIRST) as used in All Facts.
2) =GetRecord(%FACT%) is a popular alternative.
They both give the same result, except for Family Facts such as Marriage and Divorce.
Then 1) gives the Individual husband, whereas 2) gives the Family couple.

The Fact Query lists all Facts just like an Individual Query lists all Individuals.
To list a subset of Facts (or a subset of Individuals) you must use the Rows tab filters.
So to just include Occupations use Exclude unless =FactLabel(%FACT%) matches 'Occupation'.
To test the Occupation values use Exclude unless =FactValue(%FACT%) matches 'Rector'.
Both of those can be generalised with Parameter Label prompts.

Those expressions above and ones for Date and Place are in All Facts on the Columns tab.

Regarding long replies; yes the login can timeout, but usually after logging in again, to you can use browser Go backwards arrow to get back to the reply edit box and Submit it again. You could also make use of the Save draft button next to Submit. However, for long replies it may be better to compose in a text editor and Cut & Paste into the reply edit box. Alternatively, just occasionally Copy all the text to the Clipboard so it can be easily Pasted back.