C Language Development Kit/Snippets/Input/KeyboardInput SMS

From OptiWiki

< C Language Development Kit | Snippets | Input(Difference between revisions)
Jump to: navigation, search
Jbo (Talk | contribs)
(initial creation of KeboardInput SMS page)

Current revision as of 14:23, 10 July 2009

Description Input a string of data by the keyboard in SMS-style.
Syntax
int KeyboardInput_SMS( char *string, int min_length, int max_length, int x, int y, int display_length, int shift_init, int key_timeout);
Arguments
char *string

Holds the scanned barcode.

int min_length

The minimal length the scanned barcode at least needs to have.

int max_length

The maximum length the scanned barcode may have.

int x

x start position where the input string is placed.

int y

y start position where the input string is placed.

int display_length

If more characters are inputted then display_length then the data is scrolled.

int shift_init

Initial state of the shift key when entering the function. shift_init can have one of the following values:

CAPS_OFF Input text in lower case. Shown in the specified corner as 'abc'.
CAPS_ONCE Input first character as capital, then automatically switch to CAPS_OFF mode. Shown in the specified corner as 'Abc'.
CAPS_LOCK Input text in upper case. Shown in the specified corner as 'ABC'.
NUM_LOCK Numeric input mode. Shown in the specified corner as '123'.
int key_timeout

Key entry time-out in steps of 20ms. When the time-out occurs, the cursor moves to the next position. (0 is no time-out). If the key is still pressed when the time-out occurs, the key is interpreted as a numeric input. The most commonly used value for this variable is 50.

Returns The key that exits the function is returned
CLR_KEY only possible when string is empty
ENT_KEY possible when string length >= min_length
Remarks - The BS_KEY removes 1 character from the string.

- If the CLR-key is double-pressed quickly, the string is cleared.
- Use the SHIFT-key to switch between: Lower case (=abc), Shift (=Abc), Caps lock (=ABC) and Numeric mode (=123)
- This snippet is not compatible with the PHL terminals, because the application can't fully control the operation of the shift-key.
- AUTOWRAP must be disabled before calling this function.

Example
#include "lib.h"
#include <stdio.h>
#include "input.h"  //Holds the input functions
 
void main( void )
{
    char string[ 20+1 ];
 
    cursor(NOWRAP);
 
    for(;;)
    {
        string[0] = '\0';
        printf("\f\tr SMS Input  \tr\n");
 
        if(KeyboardInput_SMS(string, 0, 20, 1, 2, 12, CAPS_ONCE, 50) != CLR_KEY)
            printf("\n \tr%s\tr\n",string);
 
        WaitForKey();
    }
}
}


Views
Personal tools