DataFlex Requires Chilkat v11.7.0+
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFmt
Variant vJsonOut
Handle hoJsonOut
Integer i
Integer n
Variant vJson
Handle hoJson
String sTemp1
String sTemp2
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatFormats)) To hoFmt
If (Not(IsComObjectCreated(hoFmt))) Begin
Send CreateComObject of hoFmt
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonOut
If (Not(IsComObjectCreated(hoJsonOut))) Begin
Send CreateComObject of hoJsonOut
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "target" "symbol" To iSuccess
Get ComUpdateString Of hoJson "validation.scope" "capacity" To iSuccess
Get ComUpdateString Of hoJson "payload.text" "https://www.chilkatsoft.com/barcode_overview.asp" To iSuccess
Get pvComObject of hoJson to vJson
Get pvComObject of hoJsonOut to vJsonOut
Get ComQrCode Of hoFmt "validate" vJson vJsonOut To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFmt To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStringOf Of hoJsonOut "validationStatus" To sTemp1
Showln "status: " sTemp1
Get ComSizeOfArray Of hoJsonOut "checks" To n
For i From 0 To (n - 1)
Set ComI Of hoJsonOut To i
Get ComStringOf Of hoJsonOut "checks[i].name" To sTemp1
Get ComStringOf Of hoJsonOut "checks[i].status" To sTemp2
Showln " " sTemp1 ": " sTemp2
Loop
// The same text does not fit version 2 at error-correction level H.
Get ComUpdateInt Of hoJson "encoding.qr.maxVersion" 2 To iSuccess
Get ComUpdateString Of hoJson "encoding.qr.errorCorrection" "H" To iSuccess
Get pvComObject of hoJson to vJson
Get pvComObject of hoJsonOut to vJsonOut
Get ComQrCode Of hoFmt "validate" vJson vJsonOut To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFmt To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComStringOf Of hoJsonOut "validationStatus" To sTemp1
Showln "status: " sTemp1
Get ComSizeOfArray Of hoJsonOut "checks" To n
For i From 0 To (n - 1)
Set ComI Of hoJsonOut To i
Get ComStringOf Of hoJsonOut "checks[i].name" To sTemp1
Get ComStringOf Of hoJsonOut "checks[i].status" To sTemp2
Showln " " sTemp1 ": " sTemp2
Loop
Get ComSizeOfArray Of hoJsonOut "findings" To n
For i From 0 To (n - 1)
Set ComI Of hoJsonOut To i
Get ComStringOf Of hoJsonOut "findings[i].code" To sTemp1
Get ComStringOf Of hoJsonOut "findings[i].path" To sTemp2
Showln "finding: " sTemp1 " at " sTemp2
Get ComStringOf Of hoJsonOut "findings[i].message" To sTemp1
Showln " " sTemp1
Loop
// 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
End_Procedure