LiveCode for FM Manual Custom ComponentsHow do I create a QR code?

How do I create a QR code?

In this lesson we will use the LCQRCode function to create QR code and display it in a container field.

The LCQRCode function

The LCQRCode function takes 4 parameters

  • Content - the content to be encoded in the QR code
  • Error Correction Level - QR codes have the capacity to restore data if it is dirty or damaged. The value is one of
    • L - Approx 7% (default if unspecified)
    • M - Approx 15%
    • Q - Approx 25%
    • H - Approx 30%
  • Size - an integer specifying the size of the QR code. The default in 3 if the value is not specified.
  • Mask - a mask changes the bits according to their coordinates in the matirx. The purpose is to make the QR code easier for a scanner to read. The mask number is an integer between 0 and 7.

For more information on these values see

http://www.qrcode.com/en/about/error_correction.html

http://www.thonky.com/qr-code-tutorial/mask-patterns

Solution Layout

In your solution create

  1. a field to specify the content to be encoded in the QR code
  2. a drop-down list to select the error correction level
  3. a field to specify the size of the QR code
  4. a drop-down list to select the mask value
  5. a container field to hold the QR code that is returned by LCQRCode
  6. a button to generate the QR code. In button setup name it and choose `Single Step` as its action.

Create QR Code button script

The `Create QR Code` button script is just a single script step. It passes the values of 'content', 'errorCorrectionLevel', 'size' and 'mask' to the "LCQRCode" function and sets the QR code container to the result.

Testing

Exit layout mode and set the values of 'content', 'errorCorrectionLevel', 'size' and 'mask'. Click the "Create QR Code" button and you will see a QR Code in the image container field.

Change some of the values and generate another QR Code, the image will change.

0 Comments

Add your comment

E-Mail me when someone replies to this comment