Visual FoxPro Requires Chilkat v11.7.0+
Visual FoxPro
Generate a QR Code with the Barcode Method
See more QR Code Examples
Demonstrates the Barcode method, which is the general form of QrCode: the request names the symbology, and everything else is the same. QrCode is Barcode with the symbology already set to qr, and identical requests to the two methods give identical results. A program that will produce more than one kind of barcode can use Barcode for all of them.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loJson
LOCAL loFmt
LOCAL loJsonOut
LOCAL loJson2
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("symbology","qr")
loJson.UpdateString("payload.text","https://www.chilkatsoft.com/")
loJson.UpdateString("output.path","qa_output/qr_from_barcode.png")
loJson.UpdateBool("output.overwrite",1)
loJson.UpdateString("output.return","none")
loFmt = CreateObject('Chilkat.Formats')
loJsonOut = CreateObject('Chilkat.JsonObject')
lnSuccess = loFmt.Barcode("generate",loJson,loJsonOut)
IF (lnSuccess = 0) THEN
? loFmt.LastErrorText
RELEASE loJson
RELEASE loFmt
RELEASE loJsonOut
CANCEL
ENDIF
? "symbology: " + loJsonOut.StringOf("symbols[0].symbology")
? "QR version: " + STR(loJsonOut.IntOf("symbols[0].selectedEncoding.version"))
? "image: " + STR(loJsonOut.IntOf("outputs[0].width")) + " x " + STR(loJsonOut.IntOf("outputs[0].height")) + " pixels"
* The image written to qa_output/qr_from_barcode.png:
*
* Barcode requires the symbology. QrCode does not.
loJson2 = CreateObject('Chilkat.JsonObject')
loJson2.UpdateString("payload.text","https://www.chilkatsoft.com/")
lnSuccess = loFmt.Barcode("generate",loJson2,loJsonOut)
IF (lnSuccess = 0) THEN
? "without a symbology: " + loJsonOut.StringOf("errors[0].code") + " at " + loJsonOut.StringOf("errors[0].path")
ENDIF
* Sample output:
* symbology: qr
* QR version: 3
* image: 148 x 148 pixels
* without a symbology: missingOption at /symbology
RELEASE loJson
RELEASE loFmt
RELEASE loJsonOut
RELEASE loJson2