C Language Development Kit/Snippets/Input/KeyboardInput

From OptiWiki

Jump to: navigation, search
Description Input a string of data by the keyboard.
Syntax
int KeyboardInput( char *string, int min_length, int max_length, int typ, int x, int y, int display_length, int num, ... );
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 typ

typ is an orred parameter that specifies what keys can be typed. typ can be one or orred of these keys:

INPUT_FLOAT Numeric input and the . are accepted.
INPUT_NUM Numeric input is.
INPUT_ALPHA Alpha keys and space character are accepted.
INPUT_NEGATIVE The first character of the input string can be a minus sign.
INPUT_PRINT All printable characters are accepted.
INPUT_ALL All the above options orred together.
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 num

The amount exception keys that are specified in the list. ... Holds the list of exception keys.

Returns EOF when no exception keys are used, else returns the exception key.
Remarks BS_KEY cannot be used as an exception key.
Example
#include "lib.h"
#include <stdio.h>
#include "input.h"  //Holds the input functions
 
void main( void )
{
    int key;
    char string[ 46 ];
    for(;;)
    {
        string[0] = '\0';
        printf("\fKeyboardInput\n");
        if(KeyboardInput(string,1,40,INPUT_ALL,0,1,14,2,CLR_KEY,ENT_KEY) == CLR_KEY)
            printf("\fCLR key pressed\n");
        else
            printf("\ftyped:\n%s\n", string);
        printf("press a key\nto continue");
        WaitForKey();
    }
}


Views
Personal tools