Introduction


There are times when a fixed keyboard definition is not the best choice. You can 'work around' this by using multiple key assignments, but this can become clumsy. An intelligent key can help.


SPFLite supports a conditional key assignment, where some test can be made and alternate definitions created.


How is it done?


Making an assignment conditional is done by surrounding a normal assignment with a Prefix and a Suffix, as follows


Prefix the assignment with <IF.xxxx> to mark its beginning, and follow it with <> to indicate then end. 

   For example: <IF.FM>RC Recent<>

Which effectively says - If the current tab is File Manager, Issue a RC Recent command, else do nothing.


What if I want to do something else other than 'nothing'?


Providing an else definition is done as follows:

   <IF.xxxx>true-definition||else-definition<>

The true-string and else-string are separated by a pair of | characters.  e.g  ||


How do I enter an 'IF NOT' condition?


To create an 'IF NOT' condition, simply use the else structure and do not provide a true-string. For example, to perform something if NOT on the File Manager tab:

  <IF.FM>||not-definition<>


Can I enter Multiple Conditions?


Yes, conditional entries are processed left to right, and each entry is processed independently.

   <IF.test1>test1-definition<><IF.test2>test2-definition<><IF.test3>test3-definition<>

The 3 conditional tests here are performed independently, so the result could be perhaps any one of the 3 definitions, or some or all of the definitions, or none of them.


If none of the 3 above, can I provide a Default?


Yes, one of the <IF.xxxx> tests is specifically designed to support this. Simply add the following test after the previous tests.

   <IF.test1>test1-definition<><IF.test2>test2-definition<><IF.test3>test3-definition<><IF.NONE>default-definition<>


Just what ARE all these tests?


Detailed below are the available tests. If, while using these you have another test idea which could be handy, please let us know.


The entries below are the xxxx portion of the <IF.XXXX> structure

FM

True if the current tab is the File Manager tab.

!ppppp

True if the current active Profile for the tab is ppppp.

CMND

True if the cursor is currently on the Command Line.

LNUM

True if the cursor is in the Line Number/Command area.

DATA

True if the cursor is in the text data area.

PATH

True if the cursor is in the File Manager FilePath area.

MASK

True if the cursor is in the File Manager Mask area.

LOCKED

True if the cursor is in a non-typeable area.

KBn

True if the same named SET variable is defined and is not null.

NONE

True if all conditional tests to the left have been FALSE

CAPS

True if CAPS Lock is ON.

SCROLL

True if SCROLL Lock is ON

NUM

True if NumLock is on.


A practical example


Here's a simple example of how useful conditionals can be:


If you program in PL1, the NOT sign is not available directly on the keyboard, making it difficult to type.  Here's a definition, which would be entered for the ^ key, making it 'sensitive' to whether you're working on a PL1 source.


<IF.!PLI>[¬]||[^]<>


Yes it looks cryptic, but is simply says - If the current Profile in use is PLI, then enter a ¬ else enter a ^