* Writing new queries

Homeless Posts from the old forum system
Locked
User avatar
jsphillips
Megastar
Posts: 579
Joined: 13 Aug 2006 16:00
Family Historian: V6.2
Location: Near Sevenoaks Kent

Writing new queries

Post by jsphillips » 30 Sep 2011 08:32

It would be nice to start a specific forum just dealing with writing new queries and help in writing. Then to add to download query list.

ID:5488

avatar
arshawbrown
Diamond
Posts: 55
Joined: 11 May 2005 09:00
Family Historian: None

Writing new queries

Post by arshawbrown » 30 Sep 2011 16:03

Too right! I don't use queries as I don't understand them or how to write them.

User avatar
Jane
Site Admin
Posts: 8441
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Writing new queries

Post by Jane » 30 Sep 2011 16:28

Tree Searcher have you tried looking at:

[wiki]how_to:creating_a_query[/wiki]?

User avatar
jsphillips
Megastar
Posts: 579
Joined: 13 Aug 2006 16:00
Family Historian: V6.2
Location: Near Sevenoaks Kent

Writing new queries

Post by jsphillips » 01 Oct 2011 22:14

Yes I have read this but it appears to be a little beyond me and several I have tried writing fail and then I have asked for help.
Regards

User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Writing new queries

Post by gerrynuk » 01 Oct 2011 23:11

I do sympathise - I can't get my head around all these brackets/braces, percent signs and full stops and when you use them and when you don't and why sometimes you need an equals sign! etc etc etc.

I can use the Data Reference Assistant for simple queries but feel I could be much more creative if I understood more about how expressions were built up and where you find and how you use the different components of expressions.

So yes please, if someone could write the A to Z Guide to Queries that explains all these things I would be very grateful.

Gerry

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

Writing new queries

Post by tatewise » 02 Oct 2011 10:25

Have you actually looked at the Knowledge Base on Creating a Query recently? It has been updated.
See http://www.fhug.org.uk/wiki/doku.php?id ... ng_a_query
There is an Animated Tutorial, references to worked examples in the Getting the Most From Family Historian guide, references to FH Help on Understanding Data References and Understanding Functions, and some tips and advice.
If there are particular areas that need more details then post your ideas here, and we will see what we can do.

User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Writing new queries

Post by gerrynuk » 02 Oct 2011 12:01

Hi Tatewise,

Er, yes, actually! But I still don't understand the structure of, for example, from your recent posting:

%INDI.NAME:ADORNED% =CombineText('aka ',%INDI.NAME[2]%,' ','') (=LifeDates2())

Why and when are the %s needed and where are they placed? I assume they are some sort of delimiters.
Why ...NAME:ADORNED and not NAME.ADORNED?
Why and when is '>' or '>>' used? (I'm sure I have seen both used. As in: %IND.FAMC>HUSB>NAME%)
Can you use [*] e.g. INDI.NAME[*] to select all the recorded names and does this work with other references?
The use of the function =CombineText() in the middle of the expression is odd - I would expect the expression to be within the function so that the whole expression began =CombineText(%INDI.NAME...
Why are there brackets around (=LifeDates2()) but not around =CombineText()?

That's probably enough to be getting on with?

Gerry

User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Writing new queries

Post by gerrynuk » 02 Oct 2011 12:08

Something went wrong with part of the text of my message, which should have read:

Can you use (square bracket)*(square bracket) e.g. %INDI.NAME(square bracket)*(square bracket)% to select all the recorded names and does this work with other references?

(For some reason square bracket followed by an asterisk followed by another square bracket isn't printed correctly.)

Gery

User avatar
Jane
Site Admin
Posts: 8441
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Writing new queries

Post by Jane » 02 Oct 2011 12:17

Square brackets are use in the forum for items such as bold.

If you wrap your output in a code section the # on the icon panel you can

Code: Select all

NAME[*]

User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Writing new queries

Post by gerrynuk » 02 Oct 2011 12:56

Jane,

Thanks for the explanation.

What I had meant to write was:

Can you use

Code: Select all

[*] e.g. %INDI.NAME[*]% 
to select all the recorded names and does this work with other references?

(But without 'code:' appearing!)

Gerry

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

Writing new queries

Post by tatewise » 02 Oct 2011 13:07

The guide Getting the Most From Family Historian explains the answers to many of your questions quite well.
It is well worth working through Chapter 14 – Writing Custom Queries in particular, as recommended in the Knowledge Base advice.

To answer your specific points, Expressions are composed from two fundamental features, namely Data References and Functions.
Enter either of these phrases into the FH Help > Family Historian Help > Index tab search box and there is a full explanation.

Data References are enclosed in % and represent the GEDCOM database field tags.
Tags nested in the same record are separated with a dot . and a link to another record is signalled by a greater than > sign.
The colon : introduces a Qualifier such as ADORNED which specifies how data is displayed.
This is all explained on the Understanding Data References Help page.
However, the relevant Data Reference Assistant associated with each Expression only allows valid Data References to be composed.
You CANNOT use wildcard asterisk * indices in square brackets.
Indices are also explained on the Understanding Data References Help page.

Functions have the format =FunctionName(Parameters) as explained on the Understanding Functions Help page.
The %INDI.NAME:ADORNED% is not inside the =CombineText() function because we want this NAME displayed unconditionally.
The =CombineText() function either displays 'aka %INDI.NAME[2]% ' or it displays nothing.
The parentheses around (=LifeDates2()) are redundant and I only retained them to maintain consistency with the installation default.
I cannot explain why they are there at all.

Does that help?

User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Writing new queries

Post by gerrynuk » 02 Oct 2011 14:29

Thanks, Tatewise. I think your brief and lucid explanation will give me the encouragement to dip further into subject - I did find the explanations in the Help files etc rather heavy going and the points you have now clarified were not 'jumping out of the page' at me! (Part of the explanation for this is that I find reading large amounts of text on a screen is difficult - give me the old fashioned printed book that I can have beside me as I work through the examples.)

I do have one further query in relation to the following:

'Tags nested in the same record are separated with a dot . and a link to another record is signalled by a greater than > sign.'

Perhaps reading the Help pages might make it clearer but presumably you can only access certain types of record with the '>'?

Regards,

Gerry

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

Writing new queries

Post by tatewise » 02 Oct 2011 15:03

There is nothing to stop you printing Getting the Most From Family Historian which is in paginated book form, or from printing the FH Help pages.

I presume that you understand the different Record types are Individuals, Families, Notes, Sources, etc, as per the Record Window tabs.
Their linkable relationships are defined by the GEDCOM V5.5 Specification supported by FH.
So in a Property Box when you click Up to a Parent, or across to a Spouse or Child, or Go To Source Record, or on a Multimedia tab Go To Record then you are following such a link.

In the Query Window on the Columns tab examine the Fields pane on the left.
Click on the + signs to expand the nested fields.
When you click on the > sign Add Field as Column button, the associated tags appear in the Columns Expression.
As it says in Getting the Most From Family Historian in Making Sense of the Field List on page 146:
'Any field in the field list which stores a link to another record always ends in ‘>>‘'
That is where a > is used instead of a dot to separate tags.

avatar
Dagwood
Superstar
Posts: 302
Joined: 30 Nov 2009 17:37
Family Historian: V6.2

Writing new queries

Post by Dagwood » 02 Oct 2011 17:53

Re 'There is nothing to stop you printing Getting the Most From Family Historian which is in paginated book form, or from printing the FH Help pages. '
I started to do this and gave up quickly! At about £16 I found the printed book more convenient and excellent value compared with printer costs.......a lot thinner too.
Dagwood

User avatar
gerrynuk
Megastar
Posts: 565
Joined: 25 Apr 2007 09:21
Family Historian: V6
Location: Welwyn Garden City
Contact:

Writing new queries

Post by gerrynuk » 02 Oct 2011 18:33

Thanks, Tatewise.

Things are certainly clearer now.

Regards,

Gerry

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

Writing new queries

Post by tatewise » 03 Oct 2011 11:37

Certainly, buying the Getting the Most From Family Historian book is a worthwhile investment.
However, this expense will need to be repeated for each major update to FH.

It is not necessary to print the entire Getting the Most From Family Historian, just the pages of interest.
Also most printers will print double sided to save paper.

I have tried to capture the essence of this discussion thread in two new Knowledge Base entries:
Understanding Data References at http://www.fhug.org.uk/wiki/doku.php?id ... references
Understanding Functions at http://www.fhug.org.uk/wiki/doku.php?id ... _functions

Comments please.

User avatar
PeterR
Megastar
Posts: 1129
Joined: 10 Jul 2006 16:55
Family Historian: V7
Location: Northumberland, UK

Writing new queries

Post by PeterR » 03 Oct 2011 18:02

Mike, well done, these should be helpful.
there is nothing equivalent to the Data Reference Assistant for constructing Functions, so they must always be composed manually
You could refer to Use PSPad to Format Functions at http://www.fhug.org.uk/wiki/doku.php?id ... _functions which does provide some assistance when building functions in the PSPad text editor.

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

Writing new queries

Post by tatewise » 03 Oct 2011 20:24

Thank you Peter, forgot about that one, and it is now mentioned.
BTW - After looking at it again I noticed that the Functions =Diff(), =FactName(), and =TextIf() are missing and need to be added to complete the set.

Locked