Page 1 of 1

Re-Using Expressions

Posted: 16 Jun 2015 06:19
by shoshk
Hi All,

I've started to play with queries and I'm really liking the possibilities.

One thing that I'm discovering is that I often find myself defining a rather hairy expression for a column, which I would like to re-use in another queries.

Currently, I'm using copy-paste, but that's less than ideal, because if I want to change the expression, I have to edit it everywhere it is used.

It would be nice if FH provided for user-defined functions. ;)

Any suggestions for a strategy to manage this would be welcome.

Shosh

Re: Re-Using Expressions

Posted: 16 Jun 2015 09:52
by tatewise
I sympathise with your problem Shosh, for which there is no simple solution.

There already is Wish List Ref 498 User Defined Macros (or Custom Functions) which is derived from posting User Defined Macros (6221) but has attracted few votes.

BTW: I guess you have discovered how_to:understanding_expressions|> Understanding Expressions and its links to Data References and Functions.

The only idea I can suggest is based on the fact that Queries, etc, are mostly saved in plain text files.
So a batch text editor, or FH Plugin, could perform global Find & Replace operations on those text files for the expression to be changed.

Re: Re-Using Expressions

Posted: 16 Jun 2015 10:25
by shoshk
Mike,

I wondered about doing this with a plugin. Since it doesn't look like macros will be available in the near future, I guess I'll add it to my list of things to do.

Is the query file structure documented?

Shosh

Re: Re-Using Expressions

Posted: 16 Jun 2015 11:21
by tatewise
Shosh,
None of the FH custom file types are documented, but they are not difficult to understand, especially when you know their details as shown in FH.
For Queries just check the folder below.
C:\ProgramData\Calico Pie\Family Historian\Queries\Custom
(or use File > Import/Export > Export > Query to the Project Public folder.)

Then open your saved Query (.fhq) file with a plain text editor such as Windows Notepad.

You will see each Column has the following format:
TAG="Record Id","=RecordId()",HIDDEN,DESC,38
where the comma separated parameters are:
1 "Heading"
2 "Expression" (note that simple Data Refs have no enclosing %)
3 Type: HIDDEN or BUDDY or blank
4 Sort: ASC or DESC or blank
5 Column width in quarter characters as adjusted in Result Set

Re: Re-Using Expressions

Posted: 16 Jun 2015 11:47
by shoshk
Thanks Mike.