Using the Barcode Fonts with PowerBuilder

PowerBuilder is an integrated development environment (IDE) tool owned by SAP. It supports the use of Powerscript, an object oriented programming language for creating powerful software applications. ConnectCode Barcode Fonts package is bundled with a COM (Component Object Model) barcode library that can be accessed through Powerscript to generate barcodes in PowerBuilder applications.

This tutorial illustrates the setup of the Barcode Fonts COM library in Windows and accessing the functions in the library through Powerscript. The functions in general convert input data into characters that can be applied with a barcode font to generate high quality barcodes that meet the strictest industry requirements.

Prerequisites

  • PowerBuilder v12, PowerBuilder 2017, or PowerBuilder 2019 is installed
  • .Net 4.x is installed on your machine
  • ConnectCode Barcode Fonts is installed
    BarcodeFontsCOMLibrary.dll in the Resource\BarcodeFontsCOMLibrary subdirectory.

Using the Barcode Fonts with PowerBuilder Tutorial


1. Launch the Command Prompt (as Administrator) from the Windows Search bar (or Cortana Ask Me Anything).

2. In the Command Prompt, go to the following folder.

C:\Program Files (x86)\ConnectCode\Resource\BarcodeFontsCOMLibrary

If you are using the msix style installer for Windows 11, "BarcodeFontsCOMLibrary" is available in the Resource.zip file.

3. The above folder contains the COM library “BarcodeFontsCOMLibrary.dll”

4. Enter the following command:

Regasm BarcodeFontsCOMLibrary.dll /tlb:BarcodeFontsCOMLibrary.tlb /codebase



Ensure that the command is executed successfully. If you see an error, make sure you have started the Command Prompt as an Administrator. If Regasm is not available in your PATH, you can enter the full path name such as “C:\Windows\Microsoft.NET\Framework\v4.0.30319\Regasm”.

5. We are now ready to call the COM library through Powerscript. Launch PowerBuilder.

6. Create a new Template Application in PowerBuilder.



7. You can simply select “SDI appiication” as the Application Types and “None” in Connectivity Options”.

8. Click on w_genapp_main when the application is created. Go to the Menu and select Insert->Control->CommandButton.



9. Double click on the button and add the following script:


   

OLEObject barcode
int return_code
barcode = CREATE OLEObject
return_code=barcode.ConnectToNewObject("ConnectCode.BarcodeFontsCOMLibrary")
if return_code<>0 then
	destroy barcode
	messagebox ("Error","BarcodeFontsCOMLibrary not available")
else
	string result
	string input="12345678"
	result=barcode.Encode_Code128Auto(input)
	messagebox ("Result",result)
	destroy barcode
end if


10. Go to the menu and select the “Run->Select and Run” option.



11. Click on the button and a message box will display the barcode characters generated by the COM library for a Code 128 symbology with “12345678” as the input data.



12. You can place the output characters into a textbox and then apply the Code 128 Barcode Fonts as shown in the following:

barcoderesource.com/code128_barcodefont.html

Other barcodes such as Code 39, EAN13, I2of5, GS1-128, GS1 Databar 14 are also supported.