PowerBuilder Requires Chilkat v11.7.0+
PowerBuilder
Validate a QR Code Request
See more QR Code Examples
Demonstrates the validate operation, which examines a request without producing anything. The scope says how far to look: definition checks the options, capacity also checks that the data fits a QR symbol, and layout also checks the rendered size against the limits. The response has a validationStatus of valid or invalid, a list of checks, and findings[] describing what is wrong. A request that cannot be understood at all, such as one with a misspelled option, still makes the call fail in the usual way.Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Fmt
oleobject loo_JsonOut
long i
long n
oleobject loo_Json
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_JsonOut = create oleobject
li_rc = loo_JsonOut.ConnectToNewObject("Chilkat.JsonObject")
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateString("target","symbol")
loo_Json.UpdateString("validation.scope","capacity")
loo_Json.UpdateString("payload.text","https://www.chilkatsoft.com/barcode_overview.asp")
li_Success = loo_Fmt.QrCode("validate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Fmt
destroy loo_JsonOut
destroy loo_Json
return
end if
Write-Debug "status: " + loo_JsonOut.StringOf("validationStatus")
n = loo_JsonOut.SizeOfArray("checks")
for i = 0 to n - 1
loo_JsonOut.I = i
Write-Debug " " + loo_JsonOut.StringOf("checks[i].name") + ": " + loo_JsonOut.StringOf("checks[i].status")
next
// The same text does not fit version 2 at error-correction level H.
loo_Json.UpdateInt("encoding.qr.maxVersion",2)
loo_Json.UpdateString("encoding.qr.errorCorrection","H")
li_Success = loo_Fmt.QrCode("validate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Fmt
destroy loo_JsonOut
destroy loo_Json
return
end if
Write-Debug "status: " + loo_JsonOut.StringOf("validationStatus")
n = loo_JsonOut.SizeOfArray("checks")
for i = 0 to n - 1
loo_JsonOut.I = i
Write-Debug " " + loo_JsonOut.StringOf("checks[i].name") + ": " + loo_JsonOut.StringOf("checks[i].status")
next
n = loo_JsonOut.SizeOfArray("findings")
for i = 0 to n - 1
loo_JsonOut.I = i
Write-Debug "finding: " + loo_JsonOut.StringOf("findings[i].code") + " at " + loo_JsonOut.StringOf("findings[i].path")
Write-Debug " " + loo_JsonOut.StringOf("findings[i].message")
next
// Sample output:
// status: valid
// definition: passed
// capacity: passed
// layout: notApplicable
// status: invalid
// definition: passed
// capacity: failed
// layout: notApplicable
// finding: capacityExceeded at /payload
// the payload does not fit any admitted QR version at the selected error-correction level
destroy loo_Fmt
destroy loo_JsonOut
destroy loo_Json