No data returned using 2D FontEncode Functions in PowerBuilder

No data returned using 2D FontEncode Functions in PowerBuilder

You are here:
< Back

When using PDF417 and Data Matrix FontEncode Functions in PowerBuilder, there is no data returned. This issue applies to all IDAutomation Barcode Font and Encoder products.

Solution(s):

The following is an example of using the PDF417 FontEncode function from IDAutomation ActiveX Barcode Controls in PowerBuilder. The FontEncode function should return the data formatted for the PDF417 barcode font in the variable Is_barcode_pdf. In this example, the variable Is_barcode_pdf is not updated.

string
ls_location_plain = “123456789”
string
ls_barcode_pdf
OLEObject        ole_pdf417
ole_pdf417 = Create OLEObject
li_retval = ole_pdf417.ConnectToNewObject( "IDAuto.PDF417" )
ole_pdf417.FontEncode( ls_barcode_plain, 0, 0, 0, 0, 0, 0, ls_barcode_pdf 
)

To fix this problem change the above line of code to:

ole_pdf417.FontEncode( ls_barcode_plain, 0, 0, 0, 0, 0, 0, REF ls_barcode_pdf 
)

The first line of code did not work because the last parameter of FontEncode is passed into the function “By Value”. Passing the parameter “By Value” causes a copy of the variable to be sent into the function, thus, when it returns, the actual variable is not updated. The work-around for this is to use the REF keyword before the variable name. The REF keyword tells PowerBuilder to pass the address of the variable to the FontEncode function allowing the variable to be populated and returned by the FontEncode function.