Technical Information

Application Development Manual | Reading bar codes

Function

Read and display bar codes.

Sample Program

'+===========================================================================+
'|  Declaration variables                                                    |
'+===========================================================================+
    const FileBar = 1

 
'+===========================================================================+
'|  Initial Settings                                                         |
'+===========================================================================+
    out &h6080,1                                      ' Set to small-size font

 
'+===========================================================================+
'|  User defined function                                                    |
'+===========================================================================+
'+---------------------------------------------------------------------------+
'|                                                                           |
'|  Function:   Wait for reading bar code                                    |
'|     None                                                               |
'|     bar code data                                                   |
'|                                                                           |
'|  Description:                                                             |
'|    Wait for reading barcode.                               |
'|    When a bar code is read, returns the bar code data.                    |
'|                                                                           |
'+---------------------------------------------------------------------------+
function readbar$[255]
private barlen%
open "BAR:B" as #FileBar code "A"   'Open bar code device
' for reading EAN/UPC
'      -open "BAR:B" as #FileBar code "K"   ' for CODE128
'      -open "BAR:B" as #FileBar code "Q"   ' for QR code
wait 0,&h02                         'Wait for bar code input
barlen% = loc(#FileBar)
if barlen% > 0 then                 'Check buffer for data
readbar$ = input$(barlen%, #FileBar)
'read bar code data
endif
close #FileBar
end function

 
'+===========================================================================+
'|  Main menu                                                                |
'+===========================================================================+
main:
private bardata$[255]       'Declare variable string for bar code data
private tempkey$
print "Read bar code!"
bardata$ = readbar$         'Call user-defined function
print bardata$
wait 0,&h01
tempkey$ = inkey$
power off

Contact us

QBdirect