We use cookies to ensure that we give you the best user experience on our website.If you want to find out more about the cookies we use, you can access to our Privacy Policy here.By continuing your visit to our website, we'll assume you consent to our use of cookies.



Technical Information

Application Development Manual | Entering data using bar codes or keys


Enter data using bar codes or keys.
Pressing a key limits input to keys until the user presses the ENT key.
When any echoed back data is displayed on the BHT screen, pressing the C key erases the whole displayed data; pressing the BS key erases the most recently typed-in character of the data.


Use the WAIT statement to wait for bar code or key input.
Use LOC function to monitor bar code input.
Use INKEY$ function to monitor key input.
Do not use INPUT# statement to monitor key input. This statement suspends the user application program until key input, so can not simultaneously wait for either type of input.

Sample Program

const K.ENTER   = chr$(&h0d)
const K.CLEAR   = chr$(&h18)
const K.BS      = chr$(&h08)
const BarDev    = 1          'File number of barcode device file
const InpMax    = 13         'Max data length
'|                                                                           |
'|  Function:   Wait for reading barcode or key-in                           |
'|                f.no%        file number of barcode device file        |
'|                    bar$         read code                                 |
'|                    max%         max number of digit for bar code          |
'|                    esc$         list of escape keys                       |
'|               bar code data or key-in data                           |
'|                                                                           |
'|  Description:                                                             |
'|    Wait for reading barcode or key-in.                                    |
'|    When a bar code is read, returns the bar code data.                    |
'|    When the ENT key is pressed,  returns the key-in data.                 |
'|    When the key specified to escape key is pressed, returns the escape    |
'|    key data.                                                              |
'|                                                                           |
function inpbarkey$(f.no%, bar$, max%, esc$)[InpMax]
private barlen%
private .rt$[InpMax]
private .kb$
while 1
open "BAR:B" as #f.no% code bar$
wait 0,&h03         'Wait for reading-bar code or key-in
barlen% = loc(#f.no%)
if (barlen% > 0) then
.rt$ = input$(barlen%, #f.no%)
print .rt$;
inpbarkey$ = .rt$
close #f.no%
exit function
close #f.no%
.rt$ = ""
.kb$ = inkey$
while .kb$<>""
if instr(esc$, .kb$) then       'when the escape key is pressed
inpbarkey$ = .kb$           'returns the escape key data
exit function
select .kb$
case K.ENTER                    'When the ENT key is pressed
inpbarkey$ = .rt$           'fix the data
exit function
case K.BS                       'When the BS key is pressed
if len(.rt$) then           'Clear 1 character
print chr$(8);
.rt$ = left$(.rt$, len(.rt$)-1)
case K.CLEAR                    'When the C key is pressed
while len(.rt$)             'Clear all data
print chr$(8);
.rt$ = left$(.rt$, len(.rt$)-1)
case else
if len(.rt$)";
tmp$ = inpbarkey$(BarDev,"A:A",InpMax,"m")    'call function
if tmp$ <> "m" then
print "[";tmp$;"]"

Contact us


If you have not registered

The services on this member site are available only for registered customers.

New member reg.