Using the bar code functions in our plug-in, you can print any database field as an automatic bar code.
See: Advice for printing UCC-EAN-128 bar codes
But often your fields are not already in a format that can be used directly.
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.
Here is some helpful advice about how to format different 4D field and variable types, before you use the result as the argument to a bar code function.
Alpha 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;
|CIAXCOM_CODE128 ( [Table 1]ORDER_NUMBER )|
To print bar codes containing more than one field you can use simple string concatenation. For example, if ORDER_NUMBER and BATCH_NUMBER are both alpha fields, you can use;
|CIAXCOM_CODE128 ( [Table 1]ORDER_NUMBER + [Table 1]BATCH_NUMBER )|
to print a Code 128 bar code containing two fields, separated by a comma.
Use the Substring function to print bar codes containing only part of a field or string. For example, if a field called SAMPLE_CODE contained JK239, then the following expression;
|Substring ( [Table 1]SAMPLE_CODE;3 )|
would print only the characters after the second character (i.e. the third character and all characters that follow);
The bar code is automatically printed using this formula;
|CIAXCOM_CODE128 ( Substring ( [Table 1]SAMPLE_CODE;3 ) )|
Use the 4D function String( ) to format numbers in many different ways. For example, to print a numeric value with up to 5 leading zeros and no decimal places;
|String ( [Table 1]AnInteger;"00000" )|
When you use a bar code function, the fixed length values will produce numeric bar codes of equal length;
|CIAXCOM_CODE128 ( String ( [Table 1]AnInteger;"00000" ) )|
Often bar codes that contain dates use the date format DDMMYY or YYMMDD (e.g. the global UCC/EAN-128 standard uses YYMMDD). There is no function in the 4D language to format dates like this, so we can write a simple function (or Method) to do this.
Here is a function called DATE_YYMMDD() that takes a date argument and returns a string in the form DDMMYY.
$D := $1
$YY := Substring ( String ( Year of ( $D ) ); 3 )
$MM := String ( Month of ( $D ); "00" )
$DD := String ( Day of ( $D ); "00" )
$0 := $YY + $MM + $DD
this will reduce the size of date bar codes and also allows you to use bar code types that only allow numeric characters;
|DATE_YYMMDD ( [Table 1]SellByDate )|
If field SellByDate contains the date 07/06/2003 then the result is;
030706 (if your usual date format is MM/DD/YYYY as in the USA)
070306 (if your usual date format is DD/MM/YYYY as in the UK)
The UCC/EAN-128 standard tells you to prefix a date with the fixed application identifier (15), to identify the date as a Sell By Date. The following prints a UCC/EAN-128 bar code containing (15) 030706
|CIAXCOM_EAN128 ( "15" + DATE_YYMMDD ( [Table 1]SellByDate ) )|
And to print the human readable text below the bar code;
|"(15) " + DATE_YYMMDD ( [Table 1]SellByDate )|
To print a boolean field as a number 1 or 0 use the standard 4D function Num(). Here is an example, printing a field called YesOrNo as 1 or 0.
|Num ( [Table 1]YesOrNo )|
If you want to print a bar code containing Y or N (i.e. for Yes or No) then first use the following expression to print a boolean field as Y or N.
|String ( Num ( Num ( [Table 1]YesOrNo ) = 1);"Y;;N" )|
Then use this expression with a bar code function;
|CIAX_CODE128 ( String ( Num ( Num ( [Table 1]YesOrNo ) = 1);"Y;;N" ) )|
If you need other examples, see Technical Support. Consult your 4th Dimension documentation first.
Copyright © 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.