Classic ASP Requires Chilkat v11.7.0+
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set fmt = Server.CreateObject("Chilkat.Formats")
set jsonOut = Server.CreateObject("Chilkat.JsonObject")
set json = Server.CreateObject("Chilkat.JsonObject")
success = json.UpdateString("target","symbol")
success = json.UpdateString("validation.scope","capacity")
success = json.UpdateString("payload.text","https://www.chilkatsoft.com/barcode_overview.asp")
success = fmt.QrCode("validate",json,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( fmt.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "status: " & jsonOut.StringOf("validationStatus")) & "</pre>"
n = jsonOut.SizeOfArray("checks")
For i = 0 To n - 1
jsonOut.I = i
Response.Write "<pre>" & Server.HTMLEncode( " " & jsonOut.StringOf("checks[i].name") & ": " & jsonOut.StringOf("checks[i].status")) & "</pre>"
Next
' The same text does not fit version 2 at error-correction level H.
success = json.UpdateInt("encoding.qr.maxVersion",2)
success = json.UpdateString("encoding.qr.errorCorrection","H")
success = fmt.QrCode("validate",json,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( fmt.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "status: " & jsonOut.StringOf("validationStatus")) & "</pre>"
n = jsonOut.SizeOfArray("checks")
For i = 0 To n - 1
jsonOut.I = i
Response.Write "<pre>" & Server.HTMLEncode( " " & jsonOut.StringOf("checks[i].name") & ": " & jsonOut.StringOf("checks[i].status")) & "</pre>"
Next
n = jsonOut.SizeOfArray("findings")
For i = 0 To n - 1
jsonOut.I = i
Response.Write "<pre>" & Server.HTMLEncode( "finding: " & jsonOut.StringOf("findings[i].code") & " at " & jsonOut.StringOf("findings[i].path")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( " " & jsonOut.StringOf("findings[i].message")) & "</pre>"
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
%>
</body>
</html>