Page 1 of 2

QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 2:40 am
by bsnipes
I am new to LiveCode and using the sQuiRt library to generate a QR code image. When I run the code in the development environment, it runs correctly (Windows and Linux both) and updates the image on screen. When I run the executable created (Windows or Linux) it doesn't appear that qrCreate works properly. No errors show up on screen. I would appreciate any suggestions :-)

The code takes the text from txtField and uses qrCreate to create the image data which it puts into tImagedata. I copy tImagedata to a text box to view it. I then delete the first line from tImagedata and set fldImage to it.

Code: Select all

   put the text of field txtField into tQRData
   qrCreate "!", tQRData, "M", 3 
   # qrCreate "!", field txtField, "M", 3
   put the result into tImagedata
   put tImagedata into field fldImageData
   delete line 1 of tImagedata
   set the text of image "fldImage" to tImagedata
   

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 2:54 pm
by Mikey
What's up snipes? Welcome to LC.
In case you are interested in the source for SQuiRt, it's at https://github.com/macMikey/sQuiRt
Any reason why you are not targeting the image directly? The code below should give us some feedback on what's going on in your project. It will put the result into the clipboard, so after running this code, please reply to this thread and hit paste to paste the message from sQuiRt.

Code: Select all

qrCreate "fldImage",field txtField,"M","3"
#<debug>
	put the result into goop  #will either be "Error:" and an error message, or information about the qr code created
	set the clipboardData to goop
	answer goop
#</debug>

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 4:03 pm
by bsnipes
Thanks for the welcome! I am looking forward to the process and am working a bit every day on it.
I wasn't going directly to the image for one main reason - I didn't realize I could... I was basing the "!" from example code :-)

I tried your debug code and it works fine in the IDE but doesn't popup any dialogs in the executable. I did the following which pops up data in the IDE and shows the contents of "txtField" (the VCard data) and shows "8,M,8 bitbyte,5,57" for "goop". However when run as an executable the "goop" answer dialog never triggers.

Code: Select all

   answer field txtField
   qrCreate "fldImage",field txtField,"M","3"
   #<debug>
   put the result into goop  #will either be "Error:" and an error message, or information about the qr code created
   set the clipboardData to goop
   answer goop
   #</debug>

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 4:29 pm
by Mikey
That helps. Unfortunately, LC scripts tend to terminate without throwing an error when they run into a problem in your code, like a syntax error.
First question: is "txtfield" the name of the field, or is the name of the field in a container called txtfield?

If and only if the name of the field is "txtfield", then let's put it in quotes in your code, too and try again, like this:

Code: Select all

qrCreate "fldImage",field "txtField","M","3"
#<debug>
	put the result into goop  #will either be "Error:" and an error message, or information about the qr code created
	set the clipboardData to goop
	answer goop
#</debug>

If and only if the name of the field is inside the container called txtfield, let's start by putting an answer dialog both above and below the block of code. I am also going to add a couple of lines to the code so that we put a default value in the clipboard. After you run your code, no matter what happens, paste the clipboard and let's see what it shows.

Code: Select all

#<debug>
	answer "About to create the image"
	set the clipboardData to "About to create the image from:"&CR&field txtField
#</debug>
qrCreate "fldImage",field txtField,"M","3"
#<debug>
	put the result into goop
	set the clipboardData to goop
	answer goop
#</debug>

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 6:07 pm
by bsnipes
The field is indeed named "txtField". I added an extra 'answer' to your code below the debug so that it looks like below:

Code: Select all

   #<debug>
   answer "About to create the image"
   set the clipboardData to "About to create the image from:"&CR&field "txtField"
   #</debug>
   qrCreate "fldImage",field "txtField","M","3"
   #<debug>
   put the result into goop
   set the clipboardData to goop
   answer goop
   #</debug>
   answer clipboardData
 
When run in the IDE, I get 3 answer popups. When run as an executable, I get only the first "About to create the image" popup. It appears to hit the qrCreate and then just aborts the rest of the code in the MouseUp event.

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 6:35 pm
by Mikey
You didn't paste the clipboard into your last message so we can see what ends up there.
At this point I would
1) Download the repo from the link I posted earlier
2) copy/paste the contents of the squirt.livecodescript file below your script (in other words, you're adding the entire library file right into your script, so that when you're debugging it you control the source).
3) Go into the qrCreate handler and start adding answer dialogs until you find the line where things stop.
4) Report back.

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 6:40 pm
by Mikey
and at some point we might also need to see the data you're trying to encode, and the version of LC you're using.

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 6:41 pm
by bsnipes
Will do. Thanks for the guidance.

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 6:51 pm
by ClipArtGuy
[removed, see below]

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 7:55 pm
by jacque
Did you include the script-only file in the Copy Files pane in Standalone Settings?

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 7:57 pm
by Mikey
@clipartguy are you using the version from the repo or are you using some other version - just so we're all testing the same thing

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 8:03 pm
by bsnipes
I was using the version from splash21 website.

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 8:05 pm
by ClipArtGuy
:oops: So.... I realized that my test example didn't 'start using stack "sQuirt"' anywhere..... :oops:

Once that was added to an openstack handler, everything is working as expected in the standalone...

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 8:08 pm
by ClipArtGuy
bsnipes wrote:
Fri Aug 24, 2018 8:03 pm
I was using the version from splash21 website.
This is also the version I am using. Try this, and see if it works for you:

1- Create new stack
2- Make sQuiRt library a substack of it
3- Drag out a fld, an img, and a btn
4-Put this into the button script

Code: Select all

on mouseup
   put field 1 into tQRData
   qrCreate "!", tQRData, "M", 3 
   put the result into tImagedata
   delete line 1 of tImagedata
   put tImagedata into img 1
end mouseup
5- put this code into the stack script :

Code: Select all

on openstack
   start using stack "sQuiRt"
end openstack
This seems to be working as expected here on ubuntu 18.04 in the IDE as well as the standalone

Re: QRCode and updating image on compiled application

Posted: Fri Aug 24, 2018 8:26 pm
by bsnipes
And.... that was my problem. I didn't realize that the openstack code was needed. :roll:

Thanks all!