Keyboard Support

Contact and Search

Keyman.com Homepage

Header bottom

Keyman.com

Other versions
Version 8.0

Index

On this page

Programmer's Guide - Stores

Stores are a method of grouping multiple characters together, in order to deal with them all in a similar way. The most common use of stores is to reduce the number of rules required in a keyboard by allowing a single rule to match multiple characters through the use of stores and the any statement. An example of this is given in the tutorial.

System stores are stores with a name beginning with &, which have a special purpose, usually defining properties or behaviour of the keyboard.

Stores with only a single character are usually used to define named constants.

Creating Stores

Stores are created with the store statement:

store( %storename% ) %storecontents%
   

Where storename is an identifier you give to the store, and storecontents is the store's contents, expressed as a string or a sequence of Unicode or ANSI character constants. Virtual keys and deadkeys can also be used in stores.

All stores must be given unique identifiers, and are visible throughout the keyboard file. A store statement can be placed anywhere in a keyboard source file, and its visibility is unaffected.

Using Stores

Stores are most often used with the any and index keywords. The any keyword is used in the context or key section of the rule, and will match any character in the specified store, remembering its index.

any( %store% )
      

The index statement is used to look up a character in a store at the index where a specified any statement matched a character. The any statement used to obtain the index is referenced by its position in the context and key, a 1-based number.

index( %store%, %position% )
  

Note that an index statement may reference an any statement which uses a different store: the only requirement is that the stores used by each have the same length.

Example:

any(vowel) + '^' > index(vowel_circum, 1)
      

Outputting Stores

The outs statement can be used to output the contents of a store. This can be used in another store, or in the context or output of a rule.

outs( %storename% )
      

The IPAMenu.kmn sample keyboard gives an example of the use of stores and outs to create a menu-based keyboard for entry of characters from the International Phonetic Alphabet.