#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # barcode0.msg barcode1.msg barcode2.msg barcode3.msg # # This shell archive created: Sat Mar 2 18:49:54 EST 1996 # echo "Extracting file barcode0.msg" sed -e 's/^X//' <<\SHAR_EOF > barcode0.msg XSubject: Barcode stuff for archive XTo: uunet!walt@rmy.emory.edu XDate: Thu, 29 Feb 1996 13:25:49 -0500 (EST) XFrom: Michael Kuhn X XWalt, X X I figured out how to use barcodes in 4GL reports. X The reports are used in a laboratory environment, X we are creating worksheets used by lab techs. The work sheets X have barcodes on them so that data entry from the worksheet X is easier. Worksheets are used on the lab bench during DNA testing. X X I got the Bar Code software from the company listed below. We X had to write "C" "wrapper" functions that interfaces 4GL to X this library. X X This is basically how you generate a barcode. X X call BarCode_Create(1000, 5, barstr, "", 4, 0, 3, 0, 1) X returning retLen, retStr X print retStr clipped; X X retStr contains the commands to draw barcode on printer. X X I spent a LOT OF TIME trying to figure out how to do this, it could X save someone else from the same thing. X X I have sent this to 4-5 people who had questions about barcodes X in comp.databases.informix. I only got feedback/questions from one. X I don't know if anyone is using it. X X If you want to put this in archive, I can send. . . X X 1. C wrappers that interface 4GL to the StrandWare package, 700 lines of code X X 2. A couple of sample programs that output barcodes, 400 lines of code X X 3. Bar Code Library X StrandWare X P.O. Box 634 X Eau Claire, WI. 54702 X 1-800-552-2331 X X Cannot send this because you have to buy it. But the X reference is in the code. X X I think it was $500 for C code that you compile on your system. X A great deal. X X-- XMichael J. Kuhn Computer Systems Consultant phone:410-254-7060 XEmail: mkuhn@csd.clark.net, csd@clark.net X mkuhn@rhlab.com X c/o Baltimore Rh Typing Laboratory, Inc. phone:410-225-9595 SHAR_EOF if [ `wc -c < barcode0.msg` -ne 1926 ] then echo "Lengths do not match -- Bad Copy of barcode0.msg" fi echo "Extracting file barcode1.msg" sed -e 's/^X//' <<\SHAR_EOF > barcode1.msg XSubject: File 1, C interface to StrandWare XTo: uunet!rmy.emory.edu!walt@uunet.uu.net (Walt Hultgren) XDate: Thu, 29 Feb 1996 14:29:03 -0500 (EST) XFrom: Michael Kuhn X X/* barCode4gl.c -*- C -*- X** Interface from Informix 4gl to the StrandWare Bar Code Library X** X** X** Program : Bar Code Interface X** File : Bar Code 4gl Interface X** Manual Refs : S:194-198 in the Informix-4gl Supplement for Version 4.10 X** X** Written : Bradley M. Kuhn Computer Systems Development, Inc. X** By 5916 Glenoak Ave. X** Baltimore, MD 21214-2009 X** 410-254-7060 X** X** Contact : Michael J. Kuhn mkuhn@rhlab.com X** csd@clark.net X** X** X** Requires : Bar Code Library Source Code X** StrandWare X** P.O. Box 634 X** Eau Claire, WI. 54702 X** 1-800-552-2331 X** X** RCS : X** $Source: $ X** $Revision: $ X** $Date: 1995/05/08 13:48:45 $ X** X** $Log: barCode4gl.c $ X/* X Informix 4gl Calls X X call BarCode_Size(args) returning lng How Much Space? X X call BarCode_Create(args) returning lng, str create barcode X X call BarCode_BarWidthCount(arg) # barcodes on line X X call BarCode_Dots(arg) size of bar code elements X X call BarCode_Landscape(args) specify mode for LaserJet X X call BarCode_cmLPI(arg) specify LPI setting X X call BarCode_cmCPI(arg) specify CPI setting X X call BarCode_cmRATIO(arg) Code 3of9 & Code I2of5 X X call BarCode_cmCHECKSUM() returning chksum_ONE computed check sum value X X call BarCode_cmCHECKSUM2() returning chksum_TWO computed check sum value X X call BarCode_cm128TYPE(arg) specify Code 128 subset X X call BarCode_cmMODE128() returning c128Mode last Code 128 subset value X X call BarCode_cmUPCEMODE(arg) UPC-E bar code mode X X call BarCode_cmNULLCHAR(arg) set char's to NULL X X define X BarReturnString char(1000), # printer control commands X BarReturnLength integer, # ^ the declared length of this string X X BarType integer, # number that identifies the bar code X BarToMake char(7), # generate bar code for this text X TextToPrint char(10), # printed under bar code (Optional) X PrinterType integer, # number that identifies the printer X LeftMarOffset integer, # #char to indent (0 relative addr. on laser) X BarHeight integer, # bar code heigth in 1/10 inches X CheckSum integer, # 1 - enable 0 - disable where applicable X NbrPasses integer, # overstrike print passes (ignored for laser) X BarLength integer # >0 size of string to send to printer X # <0 errors X # -1 BarType not between 1 and 14 X # -2 length of BarToMake =0 or >30 X # -3 TextToPrint >30 X # -4 PrinterType > then # defined printers X # -5 LeftMarOffset > 250 X # -6 BarHeight >20 (2") or <1 X # -7 CheckSum >2 X # -8 NbrPasses not between 1 and 5 X # -9 Bar code generation error X # X # -100 Buffer Overflow (4gl Error) X X let BarToMake = "0123456" X let TextToPrint = "Num0123456" X let BarType = 8 # Code 128 X let PrinterType = 4 # laser jet 300dpi X let LeftMarOffset = 0 # 0 margin X let BarHeight = 4 # .4 inches X let CheckSum = 0 # no checksum X let NbrPasses = 0 # 0 for laser X X let BarReturnLength = 1000 # tell routine how much space we have X call BarCode_Create(BarReturnLength, X BarType, X BarToMake, X TextToPrint, X PrinterType, X LeftMarOffset, X BarHeight, X CheckSum, X NbrPasses) returning BarLength, BarReturnString X X call BarCode_Size(BarReturnLength, X BarType, X BarToMake, X TextToPrint, X PrinterType, X LeftMarOffset, X BarHeight, X CheckSum, X NbrPasses) returning BarLength X X Return to 4gl how much space is required for barcode. Generally, X you only need to do this when first designing program. X X call BarCode_BarWidthCount(arg) X Defines the number of bar codes to print on each line for X multiple width bar codes. Valid range is 1 to 6. X Default is 1. X X No argument returns the current value. X let foo = BarCode_BarWidthCount() X X call BarCode_Dots(arg) X Defines the dot width for each vertical bar or space (element) X of the bar code. Valid range is 1 to 6. X Default is 2. X Normally 1 = high density X 2 = medium density X 3 = low density X X No argument returns the current value. X let foo = BarCode_Dots() X X call BarCode_Landscape(args) X Raster image must be configured differently in landscape mode. X Boolean. 0 - default X 1 - landscape mode on HP LaserJet X X No argument returns the current value. X let foo = BarCode_Landscape() X X call BarCode_cmLPI(arg) X Defines the number of lines per inch printer is using. Vertical X spacing of bar code is adjusted to match the lpi value. X Valid range is 0 to 20. X Default is 6 lpi. Zero(0) does no adjustment. X X No argument returns the current value. X let foo = BarCode_cmLPI() X X call BarCode_cmCPI(arg) X Defines the characters per inch printer is using. This is used X to center any printed text underneath the bar codes. It is also X used to properly position the bar codes and text in landscape X mode of the HP LaserJet. X Valid range is 2 to 20. X Default is 10 cpi. X X No argument returns the current value. X let foo = BarCode_cmCPI() X X call BarCode_cmRATIO(arg) X Defines the the wide to narrow ratio for Code 39 and Interleave 2of5. X Available ratios are 1 = 2 to 1 X 2 = 2.5 to 1 X 3 = 3 to 1 X Default is 3. X X No argument returns the current value. X let foo = BarCode_cmRATIO() X X call BarCode_cmCHECKSUM() returning checksum_ONE X define X checksum_ONE char(10) X Returns the first checksum value that was calculated for X the bar code just generated with the last call. X If there was no checksum the value is 0. X X call BarCode_cmCHECKSUM2() returning checksum_TWO X define X checksum_TWO char(10) X Returns the second checksum value that was calculated for X the bar code just generated with the last call. X If there was no checksum the value is 0. X X X call BarCode_cm128TYPE(arg) X Used to force the character subset mode that is used when X generating Code 128 bar codes. 0 - Automatic subset switching X 1 - Subset A (upper case/ctrl char) X Default is 0. 2 - Subset B (upper/lower case char) X 3 - Subset C (double density numbers) X X No argument returns the current value. X let foo = BarCode_cm128TYPE() X X call BarCode_cmMODE128() returning c128Mode X define X c128Mode integer X X Returns the value of the starting subset mode for the last X Code 128 that was generated. Set to 1, 2, 3 as described in X BarCode_cm128TYPE. X X call BarCode_cmUPCEMODE(arg) X Determines the method of printing UPC-E bar codes. X 0 - 11 characters entered to print the 6 digit bar code X 1 - 6 digit input string using a System of "0" X 2 - 6 digit input string using a System of "1" X X No argument returns the current value. X let foo = BarCode_cmUPCEMODE() X X call BarCode_cmNULLCHAR(arg) X define X arg char(1) X X When set to a value other than 0, every occurance of that X character in the string to bar code will be replaced with the X NULL character. Printed text is not affected. X X No argument returns the current value. X let foo = BarCode_cmNULLCHAR() X*/ X X/* X PRINTER TYPES BARCODE TYPES X (0) PostScript (1) UPC-A X (1) Epson - 9 pin (2) UPC-E X (2) IBM Proprinter - 9 pin (3) EAN/JAN-13 X (3) HP Laserjet - 150 dpi (4) EAN/JAN-8 X (4) HP Laserjet - 300 dpi (5) 3 of 9 X (5) Epson 24 pin mode (6) Extended 3 of 9 X (6) Toshiba (7) Interleaved 2 of 5 X (7) Okidata Microline (8) Code 128 X (8) IBM Proprinter - 24 pin (9) Codabar X (9) Old HP Laserjet - 150 dpi (10) Zip+4 Postnet X (10) Old HP Laserjet - 300 dpi (11) MSI Plessi X (11) HP Deskjet - 150 dpi (12) Code 93 X (12) HP Deskjet - 300 dpi (13) Extended Code 93 X (13) HP Paintjet 180 dpi (14) UCC-128 X (15) HIBC X*/ X X#include X#include X X#define BARCODE_LEN 30+1 /* add one for 4gl */ X#define BARCODE_OUTPUT_MAX 2048+1 X Xstatic char rcsid[] = "$Id: barCode4gl.c 0.9 1995/05/08 13:48:45 mkuhn Exp $"; X/***************************************************************************** X** CheckMalloc -- this function simply checks to make sure that malloc X** does not return a NULL pointer. X** PRECONDITIONS: None X** POSTCONDTIONS: a memory block of size, mem_size will be returned. X*/ Xstatic void * XCheckMalloc(mem_size) X size_t mem_size; X{ X void *ptr; X X ptr = (void *) malloc(mem_size); X X if (ptr == NULL) { X fprintf(stderr, X "CheckMalloc(): No more memory available...Aborting...\n"); X exit(-1); X } X else { X memset(ptr, 0, mem_size); /* clear the memory to a known value */ X return ptr; X } X} X/***************************************************************************** X** CheckFree -- this function simply checks to make sure that the pointer X** is not NULL before freeing it. X** PRECONDITIONS: None X** POSTCONDTIONS: the memory pointed to by ptr will be freed if not NULL. X*/ Xstatic void XCheckFree(ptr) X void *ptr; X{ X if (ptr != NULL) free(ptr); X return; X} X/***************************************************************************** X** strtrim -- trim blanks from end of string X** X*/ Xstatic void Xstrtrim(ptr) X char *ptr; X{ X int len; X X len = strlen(ptr); X ptr = ptr + len -1; X while (len > 1 && *ptr == ' ') {*ptr = '\0'; len--; ptr--;} X return; X} X/*****************************************************************************/ X/* BarCode_Create -- 4gl interface to the bar_code library function X** This function takes the parameters to be passed to bar_code as X** well as the maximum length that the caller can handle. X** Manual Refs.: p. 20 in Bar Code Library User's manual from StrandWare X*/ Xint Xbarcode_create(numArgs) X int numArgs; X{ X /* popped parameters */ X int barCodeMaxLen; /* maximum length of bar code string */ X int barCodeType; /* number that identifies the bar code type */ X char barCodeString[BARCODE_LEN]; /* the string to turn into a barcode */ X char barCodeText[BARCODE_LEN]; /* text to appear under barcode */ X int barCodePrinterType; /* number that identifies the printer */ X int barCodeLeftOffset; /* left margin offset in characters */ X int barCodeHeight; /* height of bar code in 1/10 inches */ X int barCodeChecksum; /* enable(1)/disable(0) bar code checksum */ X int barCodeNumOfPasses; /* overstrike print passes (non laser) */ X X /* pushed(returned) parameters */ X char * barCodeOutput; /* pointer to the output string */ X int barCodeLen; /* the actual length of the barcode X ** if barCodeLen < 0 it is an error. X ** -1 : barCodeType not in [1-14] X ** -2 : length of barCodeString =0 or > 30 X ** -3 : barCodeText > 30 X ** -4 : barCodePrinterType invalid X ** -5 : barCodeLeftOffset > 250 X ** -6 : barCodeHeight > 20 or < 1 X ** -7 : barCodeChecksum > 2 X ** -8 : barCodeNumOfPasses < 1 or > 5 X ** -100 : barCodeLen wanted to be > barCodeMaxLen X ** -101 : 4gl string is too big. X ** (NOTE: -100's are our own convention) X */ X FILE *fp; X static char barCodeOutputArray[BARCODE_OUTPUT_MAX]; X /* switched to a static variable instead of mallocing because of X ** pushquote() bug (V 4.10.UE2) */ X X /* clear so that previous stuff doesn't interfere w/ barcode routines */ X memset(barCodeOutputArray, 0, BARCODE_OUTPUT_MAX); X X if (numArgs != 9) { X fprintf(stderr, X "invalid number(%d) of args to BarCode4gl...aborting\n", numArgs); X exit(-5); X } X popint(&barCodeNumOfPasses); X popint(&barCodeChecksum); X popint(&barCodeHeight); X popint(&barCodeLeftOffset); X popint(&barCodePrinterType); X X popvchar(barCodeText, BARCODE_LEN - 1); X strtrim(barCodeText); /* get rid of trailing spaces */ X X popvchar(barCodeString, BARCODE_LEN - 1); X strtrim(barCodeString); /* get rid of trailing spaces */ X X popint(&barCodeType); X popint(&barCodeMaxLen); X X barCodeLen = barsize(barCodeType, barCodeString, barCodeText, X barCodePrinterType, barCodeLeftOffset, barCodeHeight, X barCodeChecksum, barCodeNumOfPasses); X X /* check to see if requested is too big */ X if (barCodeMaxLen > BARCODE_OUTPUT_MAX - 1) X barCodeLen = -101; X X /* check to see if we will overflow the 4gl return var. */ X if (barCodeLen > barCodeMaxLen) X barCodeLen = -100; X X if (barCodeLen <= 0) { X barCodeOutput = (char *) CheckMalloc(sizeof(char)); X *barCodeOutput = '\0'; X barCodeMaxLen = 0; X } X else { X/* barCodeOutput = (char *) CheckMalloc((barCodeLen + 2) * sizeof(char)); */ X barCodeOutput = barCodeOutputArray; X X barCodeLen = bar_code(barCodeOutput, barCodeType, barCodeString, X barCodeText, barCodePrinterType, X barCodeLeftOffset, barCodeHeight, X barCodeChecksum, barCodeNumOfPasses); X X barCodeMaxLen = barCodeLen; X X if (barCodeLen <= 0) { X *barCodeOutput = '\0'; X barCodeMaxLen = 0; X } X } X X pushint(barCodeMaxLen); X /* pushvchar() doesn't work -- we think because of NULL bytes in X ** the barCodeOuput */ X /* pushvchar(barCodeOutput, barCodeMaxLen); */ X pushquote(barCodeOutput, barCodeMaxLen); X X/* CheckFree(barCodeOutput); */ X return 2; X} X/*****************************************************************************/ X/* BarCode_Size -- 4gl interface to the bar_code library function X** This function takes the parameters to be passed to bar_code as X** well as the maximum length that the caller can handle. X** Manual Refs.: p. 20 in Bar Code Library User's manual from StrandWare X*/ Xint Xbarcode_size(numArgs) X int numArgs; X{ X /* popped parameters */ X int barCodeType; /* number that identifies the bar code type */ X char barCodeString[BARCODE_LEN]; /* the string to turn into a barcode */ X char barCodeText[BARCODE_LEN]; /* text to appear under barcode */ X int barCodePrinterType; /* number that identifies the printer */ X int barCodeLeftOffset; /* left margin offset in characters */ X int barCodeHeight; /* height of bar code in 1/10 inches */ X int barCodeChecksum; /* enable(1)/disable(0) bar code checksum */ X int barCodeNumOfPasses; /* overstrike print passes (non laser) */ X X /* pushed(returned) parameters */ X char * barCodeOutput; /* pointer to the output string */ X int barCodeLen; /* the actual length of the barcode X ** if barCodeLen < 0 it is an error. X ** -1 : barCodeType not in [1-14] X ** -2 : length of barCodeString =0 or > 30 X ** -3 : barCodeText > 30 X ** -4 : barCodePrinterType invalid X ** -5 : barCodeLeftOffset > 250 X ** -6 : barCodeHeight > 20 or < 1 X ** -7 : barCodeChecksum > 2 X ** -8 : barCodeNumOfPasses < 1 or > 5 X ** -100 : barCodeLen wanted to be > barCodeMaxLen X ** (NOTE: -100 is our own convention) X */ X if (numArgs != 8) { X fprintf(stderr, X "invalid number(%d) of args to BarCode4gl...aborting\n", numArgs); X exit(-5); X } X popint(&barCodeNumOfPasses); X popint(&barCodeChecksum); X popint(&barCodeHeight); X popint(&barCodeLeftOffset); X popint(&barCodePrinterType); X X popvchar(barCodeText, BARCODE_LEN - 1); X strtrim(barCodeText); /* get rid of trailing spaces */ X X popvchar(barCodeString, BARCODE_LEN - 1); X strtrim(barCodeString); /* get rid of trailing spaces */ X X popint(&barCodeType); X X barCodeLen = barsize(barCodeType, barCodeString, barCodeText, X barCodePrinterType, barCodeLeftOffset, barCodeHeight, X barCodeChecksum, barCodeNumOfPasses); X X pushint(barCodeLen); X X return 2; X} X/*****************************************************************************/ X/* The following functions are access/setting functions for some of the X** parameters of the barcode library. X** These are described in The Bar Code Library User's Manual on pp. 21-23. X*/ Xint Xbarcode_barwidthcount(numArgs) X int numArgs; X{ X extern int BAR_WIDTH_COUNT; X int newVal = 0; X X if (numArgs == 1) { X popint(&newVal); X if ( (newVal >= 1) && (newVal <= 6) ) X BAR_WIDTH_COUNT = newVal; X else X BAR_WIDTH_COUNT = 1; X } X retint(BAR_WIDTH_COUNT); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_dots(numArgs) X int numArgs; X{ X extern int DOTS; X int newVal; X X if (numArgs == 1) { X popint(&newVal); X if ( (newVal >= 1) && (newVal <= 6) ) X DOTS = newVal; X else X DOTS = 2; X } X retint(DOTS); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_landscape(numArgs) X int numArgs; X{ X extern int LANDSCAPE; X int newVal; X X if (numArgs == 1) { X popint(&newVal); X LANDSCAPE = newVal; X } X retint(LANDSCAPE); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_cmlpi(numArgs) X int numArgs; X{ X extern int CM_LPI; X int newVal; X X if (numArgs == 1) { X popint(&newVal); X if ( (newVal >= 0) && (newVal <= 20) ) X CM_LPI = newVal; X else X CM_LPI = 6; X } X retint(CM_LPI); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_cmcpi(numArgs) X int numArgs; X{ X extern int CM_CPI; X int newVal; X X if (numArgs == 1) { X popint(&newVal); X if ( (newVal >= 2) && (newVal <= 20) ) X CM_CPI = newVal; X else X CM_CPI = 10; X } X retint(CM_CPI); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_cmratio(numArgs) X int numArgs; X{ X extern int CM_RATIO; X int newVal; X X if (numArgs == 1) { X popint(&newVal); X if ( (newVal <= 3) && (newVal >= 1) ) X CM_RATIO = newVal; X else X CM_RATIO = 3; X } X retint(CM_RATIO); X return 1; X} X/*****************************************************************************/ X/* CM_TXTLINE left out because it was C specific. Could not do in 4gl. X*/ X/*****************************************************************************/ Xint Xbarcode_cmchecksum(numArgs) X int numArgs; X{ X extern char CM_CHECKSUM; X X pushquote(&CM_CHECKSUM, 1); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_cmchecksum2(numArgs) X int numArgs; X{ X extern char CM_CHECKSUM2; X X pushquote(&CM_CHECKSUM2, 1); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_cm128type(numArgs) X int numArgs; X{ X extern int CM_128TYPE; X int newVal; X X if (numArgs == 1) { X popint(&newVal); X if ( (newVal >= 0) && (newVal <= 3) ) X CM_128TYPE = newVal; X else X CM_128TYPE = 0; X } X retint(CM_128TYPE); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_cmmode128(numArgs) X int numArgs; X{ X extern int CM_MODE128; X X retint(CM_MODE128); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_cmupcemode(numArgs) X int numArgs; X{ X extern int CM_UPCE_MODE; X int newVal; X X if (numArgs == 1) { X popint(&newVal); X CM_UPCE_MODE = newVal; X } X retint(CM_UPCE_MODE); X return 1; X} X/*****************************************************************************/ Xint Xbarcode_cmnullchar(numArgs) X int numArgs; X{ X extern unsigned char CM_NULLCHAR; X char newVal[2]; X X if (numArgs == 1) { X popquote(newVal, 1); X CM_NULLCHAR = newVal[0]; X } X pushquote(&CM_NULLCHAR, 1); X return 1; X} SHAR_EOF if [ `wc -c < barcode1.msg` -ne 22931 ] then echo "Lengths do not match -- Bad Copy of barcode1.msg" fi echo "Extracting file barcode2.msg" sed -e 's/^X//' <<\SHAR_EOF > barcode2.msg XSubject: File 2, barcode test program XTo: uunet!rmy.emory.edu!walt@uunet.uu.net (Walt Hultgren) XDate: Thu, 29 Feb 1996 14:29:37 -0500 (EST) XFrom: Michael Kuhn X X{ Informix 4gl Bar Code test program X X This was done using: X X Bar Code Library X StrandWare X P.O. Box 634 X Eau Claire, WI. 54702 X 1-800-552-2331 X X Bar Code Library is a collection of C source code X that is compiled onto your system. X X We also wrote our own wrapper functions that X interface 4GL to the C bar code routines. X X The routines return a string that contains all of X the printer commands necessary to draw a barcode X at the current print position. X X define X BarReturnString char(1000), # printer control commands X BarReturnLength integer, # ^ the declared length of this string X X BarType integer, # number that identifies the bar code X BarToMake char(20), # generate bar code for this text X TextToPrint char(20), # printed under bar code X PrinterType integer, # number that identifies the printer X LeftMarOffset integer, # #char to indent (0 relative addr. on laser) X BarHeight integer, # bar code heigth in 1/10 inches X CheckSum integer, # 1 - enable 0 - disable where applicable X NbrPasses integer, # overstrike print passes (ignored for laser) X BarLength integer # >0 size of string to send to printer X # <0 errors X # -1 BarType not between 1 and 14 X # -2 length of BarToMake =0 or >30 X # -3 TextToPrint >30 X # -4 PrinterType > then # defined printers X # -5 LeftMarOffset > 250 X # -6 BarHeight >20 (2") or <1 X # -7 CheckSum >2 X # -8 NbrPasses not between 1 and 5 X # -9 Bar code generation error X # X # -100 4gl error Buffer overflow X X let BarToMake = "0123456" X let TextToPrint = "Num0123456" X let BarType = 8 # Code 128 X let PrinterType = 4 # laser jet 300dpi X let LeftMarOffset = 0 # 0 margin X let BarHeight = 4 # .4 inches X let CheckSum = 0 # no checksum X let NbrPasses = 0 # 0 for laser X X let BarReturnLength = 1000 # tell routine how much space we have X call BarCode4gl(BarReturnLength, X BarType, X BarToMake, X TextToPrint, X PrinterType, X LeftMarOffset, X BarHeight, X CheckSum, X NbrPasses) returning BarLength, BarReturnString X X PRINTER TYPES BARCODE TYPES X (0) PostScript (1) UPC-A X (1) Epson - 9 pin (2) UPC-E X (2) IBM Proprinter - 9 pin (3) EAN/JAN-13 X (3) HP Laserjet - 150 dpi (4) EAN/JAN-8 X (4) HP Laserjet - 300 dpi (5) 3 of 9 X (5) Epson 24 pin mode (6) Extended 3 of 9 X (6) Toshiba (7) Interleaved 2 of 5 X (7) Okidata Microline (8) Code 128 X (8) IBM Proprinter - 24 pin (9) Codabar X (9) Old HP Laserjet - 150 dpi (10) Zip+4 Postnet X (10) Old HP Laserjet - 300 dpi (11) MSI Plessi X (11) HP Deskjet - 150 dpi (12) Code 93 X (12) HP Deskjet - 300 dpi (13) Extended Code 93 X (13) HP Paintjet 180 dpi (14) UCC-128 X} X Xdatabase patern Xdefine X prtnum integer, X prtcol integer , X barstr char(8), X baradj integer, X retstr char(1000) X Xmain X X start report barrpt to pipe "cat >bar.rpt" X X let prtcol = 1 X for prtnum = 8350 to 8399 X X output to report barrpt(prtnum, prtcol, 2) X X let prtcol = prtcol +1 X if prtcol > 2 then let prtcol = 1 end if X end for X X finish report barrpt Xend main X X Xreport barrpt(bardata, prtcol, numcol) X define X bardata integer, X prtcol integer, X numcol integer, X batstr char(8), X retLen integer, X retStr char(1000), X colval integer X Xoutput X top margin 0 X left margin 3 X right margin 4000 X Xorder by bardata, prtcol X Xformat Xfirst page header X# call BarCode_Dots(3) X# call BarCode_Cm128Type(3) X X let colval =0 X let baradj =0 X X print column 1 , today using "mm-dd-yy", " (", time, ")", X column 25, "Bar Code Test", X column 65, "Page ", pageno using "<<<<<" X skip 1 line X print column 1, " 10 20 30 40", X " 50 60 70 80" X print column 1, "----|----.----|----.----|----.----|----.", X "----|----.----|----.----|----.----|----." X skip 1 line X Xpage header X print column 1 , today using "mm-dd-yy", " (", time, ")", X column 25, "Bar Code Test", X column 65, "Page ", pageno using "<<<<<" X skip 1 line X print column 1, " 10 20 30 40", X " 50 60 70 80" X print column 1, "----|----.----|----.----|----.----|----.", X "----|----.----|----.----|----.----|----." X skip 1 line X Xafter group of prtcol X if prtcol = numcol then X print X skip 3 lines X let colval = 0 X let baradj = 0 X end if X Xon every row X X let barstr = bardata using "&&&&&&&&"; X X #call BarCode_Create(1000, 8, barstr, "", 4, 0, 3, 0, 1) X call BarCode_Create(1000, 5, barstr, "", 4, 0, 3, 0, 1) X returning retLen, retStr X if retLen < 0 then X print "FATAL BARCODE ERROR ", retLen using "-<<<<<" X else X print column 9+colval+baradj, " "; X print retStr clipped; X end if X X let baradj = baradj + retLen X X print column 10+colval+baradj, bardata using "########"; X let colval = colval+30 X Xend report X************************************ XClarify "4gl report function" with barcodes. X XThe 4gl report function needs to be "faked out" when it Xcomes to printing the barcodes. X XThe "print" statement is used to print the barcode string. This Xstring is usually very long (hundreds of characters). X XOne characteristic about the barcode is that after it is printed Xthe "cursor position" on the laser is returned to the beginning Xof the barcode. X X the statements that do: X . X . X print column columnAdjust+40, " " X X let columnAdjust = columnAdjust + BarLength X . X . X are postioning the cursor in the print buffer with enough spaces X to move to the correct column on the paper after the barcode prints. X XFor example barcode would contain a long string of print commands Xthat would like garbage to the naked eye. X X(&^e%5#@#0S4H%S&h(u(w(r41&^%74l246&*&!Q@!5587!8#!5#4 TESTSTRING X ^--15 spaces--^ X^----------------------------------------|---------^ X After the printer eats all the codes the cursor is X returned here | X <----------------------| X X ||||||| TESTSTRING X ^--15 spaces--^ X XThe 15 spaces before "TESTSTRING" are intended to reposition past the Xbarcode and get everything lined up again. SHAR_EOF if [ `wc -c < barcode2.msg` -ne 7520 ] then echo "Lengths do not match -- Bad Copy of barcode2.msg" fi echo "Extracting file barcode3.msg" sed -e 's/^X//' <<\SHAR_EOF > barcode3.msg XSubject: File 3, another test program XTo: uunet!rmy.emory.edu!walt@uunet.uu.net (Walt Hultgren) XDate: Thu, 29 Feb 1996 14:30:11 -0500 (EST) XFrom: Michael Kuhn X X{ Informix 4gl Bar Code test program } Xdatabase patern Xdefine X prtnum integer, X prtcol integer , X barstr char(8), X baradj integer, X retstr char(1000) X Xmain X define X sNbr smallint, X sCode char(10), X counter integer X X start report barrpt to pipe "cat >bar.rpt" X X# This program generates a sample SCANNER TARGET SHEET X# Users can enter common values by "point and shoot" method X# X create temp table dnamap(seqnbr smallint, code char(10)) X insert into dnamap values (10, "0.600") X insert into dnamap values (20, "0.450") X insert into dnamap values (30, "0.300") X insert into dnamap values (40, "0.225") X insert into dnamap values (50, "0.150") X insert into dnamap values (60, "0.113") X insert into dnamap values (70, "0.075") X insert into dnamap values (80, "0.056") X insert into dnamap values (90, "0.038") X insert into dnamap values (11, "VALID") X insert into dnamap values (21, "PENDING") X insert into dnamap values (31, "REISO") X insert into dnamap values (41, "NO DNA") X insert into dnamap values (51, "NULL") X insert into dnamap values (61, "NULL") X insert into dnamap values (71, "NULL") X insert into dnamap values (81, "NULL") X insert into dnamap values (91, "NULL") X X declare tagcur cursor for X select seqnbr, code X from dnamap X order by 1 X X let counter = 0 X let prtcol = 1 X foreach tagcur into sNbr,sCode X X output to report barrpt(sNbr, sCode, prtcol, 2) X X let prtcol = prtcol +1 X if prtcol > 2 then let prtcol = 1 end if X X let counter = counter + 1 X X if counter = 50 then X exit foreach X end if X X end foreach X X finish report barrpt Xend main X X Xreport barrpt(wNbr, wTag, prtcol, numcol) X define X wNbr smallint, X wTag char(10), X prtcol integer, X numcol integer, X baradj integer, X colval integer, X X retLen integer, X retStr char(1000) X Xoutput X top margin 0 X left margin 3 X right margin 4000 X X Xformat Xfirst page header X let colval = 0 X let baradj = 0 X X call BarCode_Dots(3) X call BarCode_Cm128Type(2) X X print column 1 , today using "mm-dd-yy", " (", time, ")", X column 25, "Bar Code Test", X column 65, "Page ", pageno using "<<<<<" X skip 1 line X print column 1, " 10 20 30 40", X " 50 60 70 80" X print column 1, "----|----.----|----.----|----.----|----.", X "----|----.----|----.----|----.----|----." X skip 1 line X Xpage header X print column 1 , today using "mm-dd-yy", " (", time, ")", X column 25, "Bar Code Test", X column 65, "Page ", pageno using "<<<<<" X skip 1 line X print column 1, " 10 20 30 40", X " 50 60 70 80" X print column 1, "----|----.----|----.----|----.----|----.", X "----|----.----|----.----|----.----|----." X skip 1 line X Xafter group of prtcol X if prtcol = numcol then X print X skip 4 lines X let colval = 0 X let baradj = 0 X end if X Xon every row X X if wTag <> "NULL" then X print column 1+colval+baradj, wTag clipped; X X call BarCode_Create(1000, 8, wTag, "", 4, 0, 3, 0, 1) X returning retLen, retStr X else X print column 1+colval+baradj, " "; X let retStr = "" X let retLen = 0 X end if X X if retLen < 0 then X print "FATAL BARCODE ERROR ", retLen using "-<<<<<" X else X print column 10+colval+baradj, " "; X print retStr clipped; X end if X X let baradj = baradj + retlen X X let colval = colval+40 X Xend report SHAR_EOF if [ `wc -c < barcode3.msg` -ne 3765 ] then echo "Lengths do not match -- Bad Copy of barcode3.msg" fi echo "Done." exit 0