SOLVED: Can't display the QRCode generated with qrCreate

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

SOLVED: Can't display the QRCode generated with qrCreate

Post by simon.schvartzman » Fri Feb 07, 2020 10:40 pm

Hi team, I'm running the example given on the dictionary for the qrCreate command and it seems to be working fine except that no image is displayed. Not sure what am I doing wrong and any help will be appreciated.

For now I'm on IDE on macOS Mojave 10.14 & LC 9.5.1

My card has on button with mouseUp script and one image named "img1"

Code: Select all

on mouseUp
   put "M" into tECC
   put 3 into tSize
   put "132" into tData
   -- example how to use qrCreate with LiveCode server
   qrCreate "!", tData, tECC, tSize
   put the result into tData
   answer tData

    if tData begins with "Error" then
      put tData
      answer "Error:" && tData
   else
      # line 1 of the result contains some info
      # the remaining lines contain the png image data
      put line 1 of tData into tInfo
      delete line 1 of tData
      
      put "<b>Qr code info</b><br/>" & LF
      put "Version: " & item 1 of tInfo & "<br/>" & LF
      put "ECC: " & item 2 of tInfo & "<br/>" & LF
      put "Mode: " & item 3 of tInfo & "<br/>" & LF
      put "Mask: " & item 4 of tInfo & "<br/>" & LF
      
      # show the image
      put base64Encode(tData) into tData
      replace LF with empty in tData
      put "<img src='data:image/png;base64," & tData & "'/><br/>" & LF into img "img1"
   end if
end mouseUp
The picture below is the result of answer tData
Screen Shot 2020-02-07 at 18.31.21.png
Last edited by simon.schvartzman on Sat Feb 08, 2020 2:00 am, edited 1 time in total.
Simon
________________________________________
To ";" or not to ";" that is the question

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10341
Joined: Wed May 06, 2009 2:28 pm

Re: Can't display the QRCode generated with qrCreate

Post by dunbarx » Fri Feb 07, 2020 11:36 pm

Hi.

Never used this before, but the parameters may need checking. For example, is a "132" valid for tData? And is it permitted to omit the rest of the parameters? The dictionary does not seem to offer these as optional values, as it usually does with, for example the date:

Code: Select all

the [{ long | abbreviated | short }] [{ english | system }] date
I am not sure about any of this, of course.

Craig

simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

Re: Can't display the QRCode generated with qrCreate

Post by simon.schvartzman » Sat Feb 08, 2020 1:54 am

Hi Craig, many thanks for your answer. I found it! It was not about the parameters, in order to show the generated qrCode in an image field the following lines should not be there

Code: Select all

   put base64Encode(tData) into tData
   replace LF with empty in tData

and

Code: Select all

    put "<img src='data:image/png;base64," & tData & "'/><br/>" & LF into img "img1"
has to be replaced by

Code: Select all

set the text of image "img1" to tData 
So the final (working) code is:

Code: Select all

on mouseUP
   put "M" into tECC
   put 3 into tSize
   put "132" into tData
   qrCreate "!", tData, tECC, tSize
   put the result into tData
  if tData begins with "Error" then
      put tData
   else
      # line 1 of the result contains some info
      # the remaining lines contain the png image data
     delete line 1 of tData
    
      # show the image
       put tData into image "img1"
   end if
end mouseUp
which retrieves the expected QRCode
Screen Shot 2020-02-07 at 21.52.47.png
Screen Shot 2020-02-07 at 21.52.47.png (5.15 KiB) Viewed 4972 times
Simon
________________________________________
To ";" or not to ";" that is the question

ajperks
Posts: 105
Joined: Sat Sep 06, 2014 3:38 pm

Re: SOLVED: Can't display the QRCode generated with qrCreate

Post by ajperks » Fri Jul 17, 2020 1:08 pm

I needed a QR code generator and rather than go on line, I found this for LC
I copied and pasted this as a stack and it worked perfectly in the editor, but does nothing when made into an EXE.
Did anyone else find this issue?
Win 10 Version 2004 OS build 19041.388
Running LC Community 9.6
Thanks

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

Re: SOLVED: Can't display the QRCode generated with qrCreate

Post by SparkOut » Fri Jul 17, 2020 9:24 pm

In the standalone builder settings, check you have the qr library included. If you're letting LiveCode search for inclusions automatically, then try turning that off and manually selecting the qr library (as well as any others needed).

Post Reply