Topic The If statement changes the output indices.

We have two new locations for Keyman technical support:

The Tavultesoft Forums are now read only.


# The If statement changes the output indices.   2016-02-25 10:07:04.140
br Julian Griffin OSL
The line below works. (I have shortened Store names to make it easier to read.)
:
Any(LL) $SK + ['A'] > Context(1) Index(SO,1) Index(S_a,1)

   I wanted to make it conditional, so I added an IF, to get:
:
If(MF = 'No') Any(LL) $SK + ['A'] > Context(1) Index(SO,1) Index(S_a,1)

   But this would not compile. So, assuming the IF was being counted as an element of the Rule, I changed all the (1)s to (2). This compiled, but no longer functioned as required. After trying all eight possible configurations of the three (1)s, I found the following code compiled and function correctly.
:
If(MF = 'No') Any(LL) $SK + ['A'] > Context(1) Index(SO,2) Index(S_a,2)

   So to my question, why is Context (1), when the two Indexes are (2)?

Regards
Julian Griffin
# RE: The If statement changes the output indices.   2016-02-26 07:38:54.177
Marc Durdin
Tavultesoft Staff
Yes, you are correct. I looked into my notes and found a reference to this from ages ago but it never made it into the documentation. It's a silly distinction that I should have resolved but won't for now because there are too many keyboards and versions of Keyman dependent on it.

I could update the compiler to handle this case but even then it would require existing keyboards to be updated and I think documenting the difference will be more productive at this stage.
# RE: The If statement changes the output indices.   2016-02-26 07:57:48.027
Marc Durdin
Tavultesoft Staff
And I've just pushed a documentation change to http://help.keyman.com/developer/language/reference/index and http://help.keyman.com/developer/language/reference/context to reflect this inconsistency :)