QRCode and updating image on compiled application

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

bsnipes
Posts: 14
Joined: Mon Jul 23, 2018 10:12 pm

QRCode and updating image on compiled application

Post by bsnipes » Fri Aug 24, 2018 2:40 am

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
   

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: QRCode and updating image on compiled application

Post by Mikey » Fri Aug 24, 2018 2:54 pm

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>

bsnipes
Posts: 14
Joined: Mon Jul 23, 2018 10:12 pm

Re: QRCode and updating image on compiled application

Post by bsnipes » Fri Aug 24, 2018 4:03 pm

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>

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: QRCode and updating image on compiled application

Post by Mikey » Fri Aug 24, 2018 4:29 pm

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>

bsnipes
Posts: 14
Joined: Mon Jul 23, 2018 10:12 pm

Re: QRCode and updating image on compiled application

Post by bsnipes » Fri Aug 24, 2018 6:07 pm

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.

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: QRCode and updating image on compiled application

Post by Mikey » Fri Aug 24, 2018 6:35 pm

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.

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: QRCode and updating image on compiled application

Post by Mikey » Fri Aug 24, 2018 6:40 pm

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.

bsnipes
Posts: 14
Joined: Mon Jul 23, 2018 10:12 pm

Re: QRCode and updating image on compiled application

Post by bsnipes » Fri Aug 24, 2018 6:41 pm

Will do. Thanks for the guidance.

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: QRCode and updating image on compiled application

Post by ClipArtGuy » Fri Aug 24, 2018 6:51 pm

[removed, see below]
Last edited by ClipArtGuy on Fri Aug 24, 2018 8:17 pm, edited 1 time in total.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: QRCode and updating image on compiled application

Post by jacque » Fri Aug 24, 2018 7:55 pm

Did you include the script-only file in the Copy Files pane in Standalone Settings?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: QRCode and updating image on compiled application

Post by Mikey » Fri Aug 24, 2018 7:57 pm

@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

bsnipes
Posts: 14
Joined: Mon Jul 23, 2018 10:12 pm

Re: QRCode and updating image on compiled application

Post by bsnipes » Fri Aug 24, 2018 8:03 pm

I was using the version from splash21 website.

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: QRCode and updating image on compiled application

Post by ClipArtGuy » Fri Aug 24, 2018 8:05 pm

: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...

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: QRCode and updating image on compiled application

Post by ClipArtGuy » Fri Aug 24, 2018 8:08 pm

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

bsnipes
Posts: 14
Joined: Mon Jul 23, 2018 10:12 pm

Re: QRCode and updating image on compiled application

Post by bsnipes » Fri Aug 24, 2018 8:26 pm

And.... that was my problem. I didn't realize that the openstack code was needed. :roll:

Thanks all!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”