Topic Two letter context question.

We have two new locations for Keyman technical support:

The Tavultesoft Forums are now read only.

# Two letter context question.   2016-02-05 23:17:37.197
br Julian Griffin OSL

   The code below was created to meet two requirements:
    1. To allow for two characters and a symbol key to fire a rule that outputs two character with a Unicode symbol between the two characters.
    2. To match the case of the Left-Hand-Side in the Right-Hand-Side of the rule.
"oo" + $TieKey > "o" $Tie1 "o"
"Oo" + $TieKey > "O" $Tie1 "o"
"OO" + $TieKey > "O" $Tie1 "O"
"oO" + $TieKey > "o" $Tie1 "O"
"sh" + $TieKey > "s" $Tie2 "h"
"Sh" + $TieKey > "S" $Tie2 "h"
"SH" + $TieKey > "S" $Tie2 "H"
"sH" + $TieKey > "s" $Tie2 "H"

"th" + $TieKey > "t" $Tie2 "h"
"Th" + $TieKey > "T" $Tie2 "h"
"TH" + $TieKey > "T" $Tie2 "H"
"tH" + $TieKey > "t" $Tie2 "H"

   Although this works, I have 23 blocks like these. So to my question, is there a way to simplify this code? Can this code be placed in an external file which is then included in the project? [Hopefully, making the main code easier to understand read and understand.]

Julian Griffin
# RE: Two letter context question.   2016-02-06 08:02:34.953
Marc Durdin
Tavultesoft Staff
It is possible to reduce the number of rules with use of stores and the context() statement, for example:

store(oo) 'oO'
store(ss) 'sS'
store(tt) 'tT'
store(hh) 'hH'

any(oo) any(oo) + $TieKey > context(1) $Tie1 context(2)
any(ss) any(hh) + $TieKey > context(1) $Tie2 context(2)
any(tt) any(hh) + $TieKey > context(1) $Tie2 context(2)

However, this would probably be the cleanest you could get. Keyman Developer does not currently have a way to import rules from an external file.
# RE: Two letter context question.   2016-02-06 10:32:25.940
br Julian Griffin OSL
Thank you, that's great, it works well. It will shorten the code. But, I fear, at the expence of readability.

   I did explore
context(1) $Tie context(2)

   But I could not get it to work, it did not occur to me to split the context and to store Caps and Lowercase in the same Store().

   It seems to me that I am only just scratching the surface of what Keyman can do. I'm looking at Deadkeys and Groups next.

Thank you.
Julian Griffin