Creating your own bar code function

The bar code functions in our PowerBuilder library are usually sufficient, but if necessary, it is easy to create additional bar code functions for special applications.

Note: Any bar code functions you create, will rely on our; functions, DLL components and fonts. When you distribute any application you develop, or if you distribute your new bar code function, you must purchase a license for each person who will directly or indirectly print bar codes.

To create a new function, use the existing bar code functions, in the supplied PowerBuilder library, as examples. 

See: Bar code functions for a complete list of the new bar code functions

For example, if you examine function CIA_ITF( ), you can see this bar code function contains one line of actual code;

// Interleaved 2 of 5 (ITF) bar code. Use 'CIA ITF...' fonts. License required for each person.
return cia_bcp32("ITF-0.B", msg)

To get the bar code result, function CIA_ITF( ) calls function CIA_BCP32( ).

CIA_BCP32( )

Function CIA_BCP32( ) can be used to return any bar code type you require. You can use function CIA_BCP( ) in your own function, or you can use function CIA_BCP( ) directly.

See: CIA_BCP32 ( Barcode Type, Message )

Example of a new function

If you want to print human-readable text below ITF (Interleaved 2 of 5) bar codes, and you want the text to include the added check character, you can create a function to do this.

IMPORTANT: If you do not need a check character in the human-readable text, printed underneath the bar code, you could simply print the existing field underneath the bar code, using a separate Column object. Just use any regular text font to print the original field.

To creata a new function, add a function called MY_ITF_HUMAN to a library in your application.

Function: MY_ITF_HUMAN

The new MY_ITF_HUMAN( ) function only needs one argument. The argument can simply be the string that will contains the data used to produce the bar code, or produce the human-readable text (normally printed below the bar code) ;

Name: msg Type: string

the code of this function is simple;

return cia_bcp32("ITF-0.HA", msg)

Function MY_ITF_HUMAN( ) simply uses function CIA_BCP32( ).

Note: Function CIA_BCP32( ) will return human-readable text, when character H is used in the bar code type argument.

Now you can use your new MY_ITF_HUMAN( ) function in your Report or DataWindow.

- Add a Computed Field object to your Report or DataWindow.

- Use function MY_ITF_HUMAN( ) in the Expression property of the new Computed Field object.

The following example expression, prints the client_number field as human-readable text with a check character added.

MY_ITF_HUMAN ( client_number )

To print human-readable text underneath an ITF (Interleaved 2 of 5) bar code, use different expressions in two separate Computed Fields, like so;

Expression Results Font
CIA_ITF_A ( client_number )
CIA ITF Medium, 14 point.
MY_ITF_HUMAN ( client_number )
01234565 Arial Bold, 10 point.

Human-readable characters are usually printed underneath bar codes, but you could print the human-readable text anywhere (because you are printing it using a separate Computed Field).

When printing human-readable characters you can use any regular text font; Arial, Courier, Times, etc.

 


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