C Language Development Kit/Snippets/Input/ScanOrKeyboardInputSymbol

From OptiWiki

Jump to: navigation, search
Description Input a string of data by the keyboard, or by a scanned barcode. Returns the scanned barcode type id.
Syntax
int ScanOrKeyboardInputSymbol( char *string, int min_length, int max_length, int typ, int x, int y, int display_length, int *nCodeId );
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 accepted
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 *nCodeId

The scanned barcode id, when succesfully scanned a barcode.

Returns
SCANNED When a barcode is scanned.
KEYBOARD When a string is inputted by the keyboard.
CLR_KEY When the CLR_KEY is pressed.
Remarks None.
Example
#include "lib.h"
#include <stdio.h>
#include "input.h"  //Holds the input functions
 
void main( void )
{
    int key;
    char string[ 40+1 ];
    int codeId;
    for(;;)
    {
        string[0] = '\0';
        printf("\ftype or scan..");
        key = ScanOrKeyboardInputSymbol( string, 1, 40, INPUT_ALL, 0, 1, 14, &codeId );
        switch( key )
        {
            case KEYBOARD:
                printf("\ftyped:\n%s\n", string );
                break;
            case SCANNED:
                printf("\fscanned:\n%s\nCode Id=%d", string, codeId );
                break;
            case CLR_KEY:
                printf("\fCLR key pressed\n");
                break;
            default:
                printf("\f?????\n");
                break;
        }
        printf("press a key\nto continue");
        WaitForKey();
    }
}


Views
Personal tools