Barcode reading
Posted in 1996
The following are some snippets of code that show an example of how we read from barcode readers. The readers that we use are capable of being programmed. You can set a code sequence that is automatically sent at the beginning and the end if required of each barcode. The code we use is CONTROL-B. You can then use the ON KEY to detect a barcode. In many cases the barcodes are muti-part meaning that they are comprised of several data entry fields on the 4GL screen. We have a separate general purpose data entry field that we INPUT barcodes into. Based on the field you were in when the barcode is decoded it is inserted into appropriate places and displayed. If anyone has any further questions feel free to ask. Also I put some barcode stuff in the archive that used the StrandWare barcode generation software. Look there for info on how to print barcodes from 4GL reports. ON KEY(CONTROL-B) # This is the NOTE from above...Is this a problem here? Untested..... # NOTE: NEXT FIELD's were commented out here....the AFTER FIELD # is not done on the field if you next field from here. # See the Informix 4GL Reference Manual Volume 2 V4.00 pg. 7-139 #9 CASE WHEN infield(center_cd) LET fieldNbr = SamplePackageInputFieldNbr( "draw_center.center_cd") CALL SamplePackageInputBarcode(fieldNbr) NEXT FIELD sample_package.date_drawn WHEN infield(client_cd) LET fieldNbr = SamplePackageInputFieldNbr("client.client_cd") CALL SamplePackageInputBarcode(fieldNbr) NEXT FIELD draw_center.center_cd WHEN infield(receipt_nbr) LET fieldNbr = SamplePackageInputFieldNbr( "sample_package.receipt_nbr") CALL SamplePackageInputBarcode(fieldNbr) NEXT FIELD sample_package.shipping_nbr WHEN infield(shipping_nbr) LET fieldNbr = SamplePackageInputFieldNbr( "sample_package.shipping_nbr") CALL SamplePackageInputBarcode(fieldNbr) NEXT FIELD FORMONLY.goto_sample END CASE FUNCTION SamplePackageInputBarcode(fieldNbr) DEFINE fieldNbr INTEGER # DEFINE barcode CHAR(80), len INTEGER # # ----- get the barcode ----- # LET barcode = NULL INPUT barcode WITHOUT DEFAULTS FROM FORMONLY.barcode AFTER FIELD FORMONLY.barcode EXIT INPUT END INPUT # # ----- clear the barcode field ----- # DISPLAY "" TO FORMONLY.barcode # # ----- save the barcode ----- # LET len = length(barcode) -1 CASE WHEN fieldNbr == SamplePackageInputFieldNbr("draw_center.center_cd") LET GsamplePackageDrawCenter.center_cd = barcode[2,len] DISPLAY GsamplePackageDrawCenter.center_cd TO draw_center.center_cd WHEN fieldNbr == SamplePackageInputFieldNbr("client.client_cd") LET GsamplePackageClient.client_cd = barcode[2,len] DISPLAY GsamplePackageClient.client_cd TO client.client_cd WHEN fieldNbr == SamplePackageInputFieldNbr("sample_package.receipt_nbr") LET GsamplePackage.receipt_nbr = barcode[2,len] DISPLAY GsamplePackage.receipt_nbr TO sample_package.receipt_nbr WHEN fieldNbr == SamplePackageInputFieldNbr("sample_package.shipping_nbr") LET GsamplePackage.shipping_nbr = barcode[2,len] DISPLAY GsamplePackage.shipping_nbr TO sample_package.shipping_nbr END CASE END FUNCTION -- Michael J. Kuhn Computer Systems Consultant phone:410-254-7060 Email: mkuhn@csd.clark.net, csd@clark.net mkuhn@rhlab.com c/o Baltimore Rh Typing Laboratory, Inc. phone:410-225-9595