PowerBuilder Requires Chilkat v11.7.0+
PowerBuilder
QR Code Numeric, Alphanumeric and Byte Modes
See more QR Code Examples
Demonstrates the QR encoding modes. Digits alone are stored in numeric mode, and text made only of digits, upper-case letters, space and $ % * + - . / : in alphanumeric mode. Both pack more characters into a symbol than byte mode, which is used for everything else. QrCode chooses the most compact mode the text allows, and the response reports it. A product code written in upper case therefore gives a smaller symbol than the same code in lower case.Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Fmt
oleobject loo_Json
oleobject loo_JsonOut
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Fmt = create oleobject
li_rc = loo_Fmt.ConnectToNewObject("Chilkat.Formats")
if li_rc < 0 then
destroy loo_Fmt
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_JsonOut = create oleobject
li_rc = loo_JsonOut.ConnectToNewObject("Chilkat.JsonObject")
// Digits only.
loo_Json.UpdateString("payload.text","00123456789012345678")
li_Success = loo_Fmt.QrCode("generate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Fmt
destroy loo_Json
destroy loo_JsonOut
return
end if
Write-Debug "digits: mode " + loo_JsonOut.StringOf("symbols[0].selectedEncoding.mode") + ", version " + string(loo_JsonOut.IntOf("symbols[0].selectedEncoding.version"))
// Upper-case letters, digits, space and - are all in the alphanumeric set.
loo_Json.UpdateString("payload.text","ORDER-12345 LOT A7 SHELF 12-C")
li_Success = loo_Fmt.QrCode("generate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Fmt
destroy loo_Json
destroy loo_JsonOut
return
end if
Write-Debug "upper case: mode " + loo_JsonOut.StringOf("symbols[0].selectedEncoding.mode") + ", version " + string(loo_JsonOut.IntOf("symbols[0].selectedEncoding.version"))
// Lower-case letters are not, so the same text in lower case needs byte mode.
loo_Json.UpdateString("payload.text","order-12345 lot a7 shelf 12-c")
li_Success = loo_Fmt.QrCode("generate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Fmt
destroy loo_Json
destroy loo_JsonOut
return
end if
Write-Debug "lower case: mode " + loo_JsonOut.StringOf("symbols[0].selectedEncoding.mode") + ", version " + string(loo_JsonOut.IntOf("symbols[0].selectedEncoding.version"))
// The mode can be named. Byte mode can hold any text. Naming a mode the text cannot use
// (numeric for text with letters, for example) fails with conflictingOptions.
loo_Json.UpdateString("payload.text","00123456789012345678")
loo_Json.UpdateString("encoding.qr.mode","byte")
li_Success = loo_Fmt.QrCode("generate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Fmt
destroy loo_Json
destroy loo_JsonOut
return
end if
Write-Debug "digits as bytes: mode " + loo_JsonOut.StringOf("symbols[0].selectedEncoding.mode") + ", version " + string(loo_JsonOut.IntOf("symbols[0].selectedEncoding.version"))
// The four symbols, in the order they were made:
//
// Sample output:
// digits: mode numeric, version 1
// upper case: mode alphanumeric, version 2
// lower case: mode byte, version 3
// digits as bytes: mode byte, version 2
destroy loo_Fmt
destroy loo_Json
destroy loo_JsonOut