Printing different field types as bar codes

This section is not about bar codes - it is concerned with formatting your data before the data is put in to bar codes.

Typically you will use standard Paradox functions to create a single expression that formats your data and results in a string. In more complex applications you may need to create a function to return a string.

TIP: You should get the format of the data right first, before you use the data to produce bar codes.

Once you have an expression or function that evaluates to the correctly formatted data string, you can then use a bar code function to print that formatted string as any type of bar code.

You can print all of the following Paradox database fields as any industry bar code type;

Alpha A
Number N
Currency $
Small S
Long Integer I
BCD #
Date D
Time T
Time Stamp @
Logical L
Autoincrement +

Formatting database fields

Our product provides the bar code functions you need to print bar codes, but you must format your data, as you require, before it is printed as bar codes.

Below is some helpful advice about how to format different Paradox field types, before you use the result as the argument to a bar code function.

If you need other examples, see Technical Support.

Text fields

Text fields usually do not require any special formatting. To print field ORDER_NUMBER as a Code 128 bar code we use function CIA_CODE128, like so;

barcode = CIA_CODE128( ORDER_NUMBER )

Text field concatenation

One typical application requirement is to print bar codes containing more than one field. If ORDER_NUMBER and BATCH_NUMBER are both text fields, you can use simple string concatenation, like so;

barcode = CIA_CODE128( ORDER_NUMBER + "," + BATCH_NUMBER )

to print a Code 128 bar code containing two fields, separated by a comma.

Number fields

Use the format( ) function to print numbers in different number formats.

For example, to print a numeric value with up to 5 leading zeros;

format( "W5,EZ"", field )

When you use a bar code function, this will produce numeric bar codes of equal length;

barcode = CIA_CODE128( format( "W5,EZ"", field ) )

Padding numbers in text field

If you are storing numbers in text fields, use this function if you want to pad the string with up to 5 zeros.

fill( "0", 5 - size(field) )

and to automatically produce a Code 128 bar code;

barcode = CIA_CODE128( fill( "0", 5 - size(field) ) )

and to automatically handle blank fields;

barcode = iif(isblank(field) = False, CIA_CODE128 ( fill ( "0", 5 - size( field ) ) ), "")

Date fields

Use the format( ) function to print dates in different date formats. For example, to print dates without a separator;

format( "DO(%Y%M%D)", field )

When you use a bar code function, this will reduce the size of date bar codes and also allows you to use bar code types that only allow numeric characters;

barcode = CIA_CODE128 ( format( "DO(%Y%M%D)", field ) )

if some fields could be blank (i.e. NULL or unknown value) then use the following;

barcode = iif(isblank(field) = False, CIA_CODE128 ( format( "DO(%Y%M%D)", field ) ), "")

this will give an empty string if the field is blank, or a bar code if the field is not blank.

Yes/No fields

In Paradox, the standard iif( ) function is very useful for printing Paradox logical fields as any two values. For example, you can use iif( ) to print Y or N instead of True and False, using the following expression;

iif( field = True, "Y", "N" )

Now, when you use a bar code function, this will produce a smaller bar code (because string "Y" is shorter than string "True"). The bar codes will be of equal length (because "Y" and "N" are both one character in length).

barcode = CIA_CODE128 ( iif( field = True, "Y", "N" ) )

If you need other examples, see Technical Support.

 


Copyright 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.