Keyboard Support

Contact and Search

Keyman.com Homepage

Header bottom

Keyman.com

Other versions
Version 17.0 (home page)Version 16.0 (home page, current version)Version 15.0 (home page)Version 14.0 (home page)Version 13.0 (home page)Version 12.0 (home page)Version 11.0 (home page)Version 10.0 (home page)Version 9.0 (home page)Version 8.0Version 7.0 (home page)Version 6.0 (home page)Version 5.0 (home page)Version 4.0 (home page)

Index

On this page

index statement

    index(%snStore%,%nOffset%)
  

The index statement gets the offset of the character from the left side of the rule at offset nOffset. The offset refers to the position, including other characters, to the any statement which has saved the offset which it found the character in. The index will output the character at that offset from the store snStore. If used carefully, the index and any combination can be very powerful. In previous versions of Keyman, the index statement was only valid in the output; it can now be used also in the context (but not the key section), as long as the source it refers to is before it.

snStore: The store to output from nOffset: The offset in the input to retrieve the any information from.

Example
any(cons) "W" + any(key) > index(keyout,3) "w" index(cons,1)
  

The following example shows how the index statement can be used in the left hand side of a rule. If a repeating vowel is found, then this rule puts a circumflex on top of both vowels when '^' is pressed.

store(vowel)     'aeiou'
store(vowelcirc) 'âêîôû'
any(vowel) index(vowel,1) + '^' > index(vowelcirc,1) index(vowelcirc,2)
  
Versions

The index statement was introduced in Keyman 3.0. As of version 6.0, it can also be used in the left-hand side of a rule.

Related Topics