if() statement allows a rule to be applied conditionally on the basis of the content of a variable store.
if() statement can also be used to test the value of certain system stores, such as
if(storeName comparison store2) ... > ... if(storeName comparison constant) ... > ... if(&systemStore comparison store2) ... > ... if(&systemStore comparison constant) ... > ...
- The variable store to test.
The system store to test. The supported system stores are listed below; see associated topics for more detail:
!=, for equal and not equal, respectively.
- The name of a store to compare to
- A string value to compare to
if() statement allows any rule to be applied conditionally, depending on
the content of store
storeName, which can be defined either during keyboard
configuration or dynamically by using a
set() statement. The content of
storeName is tested to see whether it matches (or does not match) a string or
the content of another store, and the following rule used or ignored
A variable store (used in an
should not also be used to match context or key, or output in a rule. (Note:
this advice has changed from previous versions of Keyman. The compiler will warn
on this misuse.)
Certain statements must appear in specific positions in the rule. The following order is enforced by the compiler:
- All other statements and characters
if(opt1 = '1') + any(letterGroup1) > index(outputGroup1,2)
The rule to output a character from the
outputGroup1 store according to a
keystroke matching a character in store
letterGroup1 will only be applied if
the content of store
opt1 is exactly equal to the string '1'.
Where two or more separate options are held in stores, the different options can be tested together (logical "AND"):
if(opt1 = '1') if(opt2 = '1') + any(letterGroup1) > index(outputGroup1,3)
or separately (logical "OR"):
if(opt1 = '1') + any(letterGroup1) > index(outputGroup1,2) if(opt2 = '1') + any(letterGroup1) > index(outputGroup1,2)
Applying a rule only on a specific platform (see also compile targets):
if(&platform = 'web') + any(letterGroup1) > index(outputGroup1, 2)
if() statement can be used in keyboards on the following platforms.
Currently, only Windows and Linux support the options.htm form to set variable stores through a configuration user interface.
|Windows||macOS||Linux||Desktop web||Mobile web||iOS||Android|
if() statement was introduced in Keyman 8.0.
Keyman 9.0: Added support for variable system stores.
Keyman for macOS 11.0.221 added support for
reset() for variable stores.