Filling bar code fields for all records in a table

A bar code field is a term we use to describe a text field that is used to temporarily store the result of a bar code function. A bar code field prints a bar code symbol, when the text in the bar code field is printed in a report - using a bar code font.

Note: We use the term bar code field to describe a text field that contains the text result of a bar code function - and because a barcode field will print a correct bar code symbol simply by using a bar code font in a report.

A bar code function is used to create bar codes from your data values (e.g. from existing data stored in your other fields). The temporary result of a bar code function is a text string - that can be automatically stored in any text field.

EXAMPLE: If your table contains 6 digit client numbers. If, for example, the first client number is;

900347

you can calculate the Code 128 bar code field using the following script code;

BARCODE = CIA_CODE128 ( "900347" )

 
Note: The ObjectPAL code for function CIA_CODE128() is in the CIAXCOM.TXT file. File CIAXCOM.TXT contains a complete set of ObjectPAL bar code functions for Paradox for Windows.

Now barcode contains the 11 character result;

>lAY4i:Y0t#

This strange text can be automatically stored in another text field (i.e. a bar code field).

These strange characters will print a bar code symbol - when the text is printed using a bar code font (you should use font CIA Code 128 Normal - because we created a Code 128 bar code).

A better example - if you want to store your bar codes in a field called BARCODE and your data is stored in a field called CLIENT_NUMBER

BARCODE = CIA_CODE128 ( CLIENT_NUMBER )

 

IMPORTANT: In the above example, the example data was 6 characters, but the bar code result was 11 characters. This is because more characters are always needed to print the bar code symbol. Therefore, it is vital to make bar code fields the correct size. Use this rule to calculate how big to make a bar code field;

Barcode = ( 2 x Data ) + 10

Add a bar code field to your table

Add an Alpha type field (A) to store each bar code in your database table.

The size of the bar code field is always bigger than the number of data characters that the bar code field represents.

For example, if your ClientNo field is 10 digits (or characters), make the bar code field 30 characters.

Use this rule to calculate how big to make a bar code field.

Barcode = ( 2 x Data ) + 10

If your Data field is 10 characters the Barcode field must be 30, to store the characters which will be used to print the bar code.

Filling bar code fields

The code below fills field "BARCODE" with a bar code based on field "FIELD" for all records in table "TABLE.DB".

Add code to pushButton event

- Right-Click the button object, select Object Explorer

- From Object Explorer select View | Tabbed Pane

- Choose the Events pane and double-click pushButton

In the button pushButton event, insert a blank line before the method, like so;

|

method pushButton(var eventInfo Event)

endMethod

then choose menu Edit | Paste From File... (or Past From...) and select one of the these files;

CIAXCOM.TXT ObjectPAL code for Paradox for Windows

to fill a bar code field based on another database field, place both fields on the form and note the object names for each field.

EXAMPLE: To produce Code 128 bar codes we now use the function CIA_CODE128( ) like so;

method pushButton(var eventInfo Event)

var aTC TCursor endvar

; Open table
aTC.open("TABLE.DB")

; Use edit, so we can fill the field
aTC.edit()

; Scan all records in table
scan aTC:

; Fill bar code field based on field
aTC."BARCODE" = CIA_CODE128(aTC."FIELD")

endscan

; End edit
aTC.endEdit()

endmethod

Bar code functions - click for a complete list of bar code functions.

Alternatively (instead of an event) you can use the same code in a script.

method run(var eventInfo Event)

var aTC TCursor endvar

; Open table
aTC.open("TABLE.DB")

; Use edit, so we can fill the field
aTC.edit()

; Scan all records in table
scan aTC:

; Fill bar code field based on field
aTC."BARCODE" = CIA_CODE128(aTC."FIELD")

endscan

; End edit
aTC.endEdit()

endmethod

Bar code functions - click for a complete list of bar code functions.

 


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