Barcode()

Declaration:

int barcode(const char * datain, char * dataout, int itype, int autocheck, int flag);

where

datain is a pointer to a null-terminated C string containing the data that will be converted into a barcode; the maximum length permitted is 80 charaters, any larger number will produce an Invalid Data Length error

dataout is a pointer to a C character buffer that will receive the barcode characters. This buffer must exist and be at least 512 characters in length before that barcode() call. Its existence and length are not checked within the library.

Itype is an integer containing a value that determines the type of barcode to be generated. The list of barcode types is shown below (under unifont.h Header). It is recommended that the header file is included in projects using the library and that defined name are used for barcode types. This will ensure that updated version of the library do not cause problems with type values.

Autocheck is an integer value that indicates whether any checkdigit is calculated by the library. A non-zero value causes the checkdigit to be calculated by the library. A zero value results in no checkdigit calculation – and consequently assumes that any required checkdigit is included in the datain string.

Flag is a parameter that contains several one-bit flags in its lowest order byte that effect barcode symbol creation for specific barcode types. For most barcode types the Flag parameter should be passed as 0.

At the present time there are three one-bit flags of significance:

B0 = dExtra1 flag
B1 = dExtra2 flag.

The function of these flags are described in the generic Barcode Help system.

B3 = Wide/Narrow ratio flag.
For some barcode types (eg. Code 39 and Interleaved 2 of 5) the width ratio of wide to narrow bars may be varied. If this bit is 0 the ratio defaults to 2 : 1 (ie. The wide bars are twice the width of the narrow bars). If this bit is 1 the ratio of 3 : 1 is used. For barcode types that do not permit width variation this flag is ignored.

Return value

The barcode() function returns an integer error code that has one of the following meanings:

0        OK (ie.No error)
1        Invalid data length
2        Invalid code type
3        Invalid parameters
4        Illegal character in data
5        Invalid embedded code
>6      Error creating barcode

 

More:

getHR()