(PRELIMINARY VERSION)

RFIO.RFInputEx

BSTR RFInputEx(BSTR pszDefault, BSTR  sInputPhrase, short nLength, short nCol, short nRow, BSTR pszBarCfg, short nKeyMode, 
long iDisplayFlags, long iInputCharacterFlags, long iDeviceFlags, long iLenghtControlFlags, long iMiscellaneousFlags, long iAsrFlags)

Function RFInputEx( pszDefault As String, sInputPhrase As String, nLength As Integer, nCol As Integer, nRow As Integer, pszBarCfg As String, nKeyMode As Integer,
iDisplayFlags As Long, iInputCharacterFlags As Long, iDeviceFlags As Long, iDeviceFlags As Long, iLenghtControlFlags As Long, iMiscellaneousFlags As Long, iAsrFlags  As Long

Inputs user data from keyboard, scanner or ASR engine.

Return value
A string that contains the user input. Empty if an error occurs.
Sets the variables accessed by RFGetLastError, LastInputType, LastBarcodeType.

The string returned by F1 is "1" (type WLCOMMANDTYPE), the  string returned by [1]+[ENTER] key is "1" (type WLKEYTYPE).
The values returned by the function keys (type WLCOMMANDTYPE) are :
"1"=F1, "9"=F9, "10"=F0.
"21"=Up Arrow, "22"=Left Arrow, "23"=Right Arrow, "24"=Down Arrow

The string returned by [ESC] is 0x1B (27) and WLCOMMANDTYPE is set as LastInputType.
This action is also performed by ASR ResCancel keyword recognition.

The string returned by [ENTER] is 0x0D (13) depending on WLNOCRIFEMPTY and WLKEYTYPE is set as LastInputType.
This action is also performed by ASR ResAccept keyword recognition.

ASR recognition returns ASRTYPE in LastInputType.

Return value, weird
If the CLR key is pressed, the LastInputType is WLCOMMANDYPE. Note that in GetEvent the CLR key returns a WLKEYTYPE.
If the ENTER key is pressed in an empty field, the LastInputType is WLKEYTYPE and the 013 code (0Dh) is returned. 
If the WLNOCRIFEMPTY flag is set, an empty string is returned.

Parameters

pszDefault
    The default data displayed in the input area, and put in the input queue.

sInputPhrase
    The phrase to say to user before input (TTS).

nLength
    The maximum possible length of the input if the WLMAXLENGTH is set in the nInputMode flag. Otherwise, the user input may exceed this value.
    If reached, returns from input automatically if WLNO_RETURN_FILL is not set in the nInputMode flag.

nCol
    The start column (0 based) of the input area.

nRow
    The start row (0 based) of the input area.

pszBarCfg
    Barcode and button configuration : "BarCfg|BntPad". Should be "BarCfg|BntPad", "BarCfg", "|BntPad" or "".
The name of an existing barcode configuration file (see RFBARCODE object, and StoreBarcode method), up to 8 characters.
If empty, uses the previous or default barcode configuration.
It is recommended to use the StoreBarcode and PullBarcode one time to load the configuration and leave empty this field rather than supplying a barcode configuration name here.

The name of an existing Button Pad file preceded by "|" (see RFBUTTON object, and PadStore method), up to 8 characters.
If empty, uses the default Button Pad configuration ("_Input") (WCE only).

The names must contain legal characters for MS-DOS filenames. Do not include dots (.) and other special characters (* , $ \ : etc). The "|" character is a separator between barcode and button file names.

nKeyMode
    The default keyboard state, one (and only one) of the following constants :

Constant Description
WLNORMALKEYS The keyboard is set to lowercase mode (for full keyboards: 45, 46 keys) or in numeric mode (reduced keyboards: 35, 21 keys). 
WLCAPSLOCK The keyboard is set to uppercase mode (for full keyboards: 45, 46 keys) or in alphabetic mode (reduced keyboards: 35, 21 keys). 
WLKEEPKEYSTT Keep the keyboard actual state. The keyboard remains in the state the previous input left.

iDisplayFlags (Controls the display of input)

Constant Description
Default behavior 

iDisplayFlags

WLECHO_ASTERISK Replace the displayed characters with an asterisk (*).
WLSUPRESS_ECHO Do not display the input data.
(If not set) Display by default.

iInputCharacterFlags (Controls the input characters allowed)

Constant Description
Default behavior 

iInputCharacterFlags

WLALPHA_ONLY Allow only alphabetic characters in input.
(If not set) All characters are allowed by default.
WLNUMERIC_ONLY Allow only numeric characters in input.
(If not set) All characters are allowed by default.
WLINCLUDE_DATA When a function key is pressed, returns the data and function key.
(If not set) When a function key is pressed, returns only the function key and data is discarded by default.
WLTOUPPER Uppercase keyed data characters.
(If not set) The input characters are not modified. 

iDeviceFlags (Controls the devices allowed for this input)

Constant Description
Default behavior 

iDeviceFlags

WLDISABLE_SCAN Disable the barcode scanner for input.
(If not set) Scanner enabled by default.
WLDISABLE_ASR Disables the ASR (Automatic Speech Recognition) mode.
(If not set) ASR enabled by default.
WLDISABLE_KEY Disable the keyboard for input (but not the function keys).
(If not set) Keyboard enabled by default.
WLDISABLE_FKEYS Disable the function keys for input.
(If not set) Fuynction keys enabled by default.
WLSOFT_TRIGGER Activate the scanner (timed-out) at input time.
(If not set) Scanner is activated by trigger keys by default
WLVIRTUALKBD Activates the software virtual keyboard on screen.

iLenghtControlFlags (Controls the length of the input)

Constant Description
Default behavior 

iLenghtControlFlags

WLFORCE_ENTRY Do not return from function with an empty input.
(If not set) Returns if ENTER key is pressed with an empty input by default.
WLMAXLENGTH The function doesn't allow more than the maximum length characters defined by nLength.
(If not set) The function allows input for more characters than defined by nLength (system limitations).
WLNOCRIFEMPTY Do not put a CR (013, 0x0Dh) when an empty string is input.
(If not set) Put a CR (013, 0x0Dh) when an empty string is input.
WLNO_RETURN_FILL Do not return from function if the maximum length is reached. Needs the ENTER key to be pressed.
(If not set) Automatic return if the maximum length is reached, without ENTER key by default.
WLNO_RETURN_BKSP Do not return from function if the BKSP key is pressed and the input area is empty.
(If not set) Returns if the BKSP key is pressed, in an empty input area by default.

iMiscellaneousFlags

Constant Description
Default behavior 

iMiscellaneousFlags

WLEDIT_DEFAULT If default data is supplied, the input data is appended.
(If not set) The default data is overwritten, new input replaces default.
WLINPUTTIMEOUT Sets a timeout for user input. Uses KeyTime from RFTERMINAL for timeout timeframe and returns a WLCOMMANDTYPE "TIMEOUT" message if the user goes over the timeout.
(If not set) No Timeout.

iAsrFlags (Controls the ASR engine)

Constant Description
Default behavior 

iAsrFlags

WLASR_VALIDATE Uses the ASR validate mode. After the recognition the input is said to user for validation  (accept / cancel).
(If not set) Uses the ASR in simple mode (no user validation).
WLASR_GRAMMAR_COMMANDS Allows only commands keywords see ResCancel, ResAccept and ResRepeat configuration for language dependent keywords.
ResCancel has the same action as [ESC] key.
ResAccept has the same action as [ENTER] Key.

(If not set) If no grammar is defined, ASR will be disabled.

WLASR_GRAMMAR_DIGIT Allows only digits input words, (0 -9). One or more digits will be input by user.
(If not set) If no grammar is defined, ASR will be disabled.
WLASR_GRAMMAR_CUSTOM Reserved for special custom compiled grammars
(If not set) If no grammar is defined, ASR will be disabled.
WLASR_REPEAT Repeat to the user the last voice input recognized.
WLASR_SAY_ONE_TIME Say the voice announce (sInputPhrase) only one time (do not repeat the phrase if no recognition is done).

Remarks
The RFInputEx function fills the input area (nLength characters starting at nCol and nRow position) with the "fill character" (underscore "_" by default or any other defined by SetFillChar) and sets in the input area the default data.
The function sets the keyboard to the mode indicated by nKeyMode flags.
The barcode configuration file is read and the scanner decoder is set with this values if the entry is not empty.
RFInputEx enables all the input devices (scanner, keys, function keys, ASR) except those indicated in iDeviceFlags flags.
The keys are echoed to the display, under control of iInputCharacterFlags flags. Function keys are not echoed.
Some characters (numeric, alphabetic) from keyboard will be avoided by iInputCharacterFlags flags.
The input ends with ENTER key, by filling the complete input area, by a function key or by a successful barcode scanning.
Empty user input and auto-return are controlled by iLenghtControlFlags flags.
Scanner and ASR will be automatically switched on when entering the function by iDeviceFlags flags.

ASR Remarks
Two voice (TTS + ASR) modes are available, simple mode and validate mode.

The simple mode (without validation)
*
A phrase is said to the user, then the user speaks.
1) The input phrase is said to the user.
2) The ASR engine is started (start BEEP) (with the indicated grammar).
3) The user says some digits (one, two, three).
4) If no user entry is recognized, loops to (1), repeating the input phrase.
5) If user entry is recognized, exits with the recognized data (123).

The validate mode (with user validation)
* A phrase is said to the user, then the user speaks.
* The input is repeated to the user, then the user validates the recognition.

1) The input phrase is say to the user.
2) The ASR engine is started (start BEEP) (with the indicated grammar).
3) The user says some digits (one, two, three), the cancel or repeat keyword.
4) If no user entry is recognized or the repeat keyword is recognized, loops to (1), repeating the input phrase.
5) If the user entry is recognized, goes to (6) with the recognized data (123 or cancel).
6) Repeats to user the recognized input (hundred twenty three) or if the cancel keyword was recognized, asks the user if he wishes to cancel (See CancelConfirmation in the configuration)
7) The ASR engine is started (start BEEP) (with the COMMANDS grammar).
8) The user says validation keyword (accept, cancel).
9) If no user entry is recognized, loops to (6).
10) If the cancel keyword is recognized, loops to (1), repeating the input phrase.
11) If the validation keyword is recognized, exits with the recognized data (123, 0x1b if the cancel keyword was recognized).

Available ASR grammars

The available grammars are DIGITS and COMMANDS.

Digits Grammar
Numeric digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
This grammar is suitable to allow numeric user input, by spelling digits.

Commands
Validation / annulations grammar, suitable for a yes/no response (same action as ESC or ENTER key by keyboard).

Français
ResCancel=Annuler
ResAccept=Accepter
ResRepeat=Répéter

English
ResCancel=Cancel
ResAccept=OK
ResRepeat=Repeat

Español
ResCancel=Anular
ResAccept=Aceptar
ResRepeat=Repetir

Example

Public wsRfIo As New RFIO
Public wsRfTerm As New RFTERMINAL
Dim sBuff As String
Dim iRes As Integer
Dim iBc As Integer

Public Sub Main()

   sInputPhrase = "Say the product id"
     iDisplayFlags = 0
   iInputCharacterFlags = 0
   iDeviceFlags = 0
   iLenghtControlFlags = WLMAXLENGTH + WLFORCE_ENTRY
   iMiscellanuousFlags = 0
   iAsrFlags = WLASR_GRAMMAR_DIGITS + WLASR_VALIDATE
   
   While sBuff <> Chr(27) And wsRfIo.RFGetLastError() = WLNOERROR
      sBuff = wsRfIo.RFInputEx("10", sInputPhrase, 15, 0, 3, "", _
         WLNORMALKEYS, _
         iDisplayFlags, _
         iInputCharacterFlags, _
         iDeviceFlags, _
         iLenghtControlFlags, _
         iMiscellanuousFlags, _
         iAsrFlags)

         If wsRfIo.LastInputType <> WLCOMMANDTYPE Then
            wsRfIo.RFPrint 0, 6, "[ Product ID:" & sBuff & "]", WLNORMAL + WLCLREOLN
         End If
   Wend

End Sub

See also    RFIO, RFBARCODE, RFGetLastError, LastInputType, LastBarcodeType, SetFillChar, StoreBarcode, PullBarcode, RFBUTTON, SetDefaultInputMode, RFTERMINAL.