Downloading an extension to the app

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

Post Reply
Voyd
Posts: 13
Joined: Thu Mar 10, 2016 8:11 pm

Downloading an extension to the app

Post by Voyd » Sat Mar 12, 2016 2:45 pm

Hello all,
I'm creating an App both for desktop and mobile devices. I would like a feature to download an extension for the app, like an in app purchase. I had a look on how to add in app purchase for various devices but that's not what I'm looking for. I was wondering if it is possible to have the app download a card or a stack, preferable a card.

So I would like the app to have a button, and for that button if the card is available go to the card/stack if not then download the card/stack.

I tried searching for it but came up with nothing.

Help would be most appreciated.


Thank you


Sheldon

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Downloading an extension to the app

Post by jmburnod » Sat Mar 12, 2016 3:07 pm

Hi Sheldon,
I think adding a stack is easier way than adding a card and you can use "start using" to use script of your app.
Anyway i think you have to download a stack to add a cd to your app ... and delete it after cd is copied
Best regards
Jean-Marc
https://alternatic.ch

Voyd
Posts: 13
Joined: Thu Mar 10, 2016 8:11 pm

Re: Downloading an extension to the app

Post by Voyd » Sat Mar 12, 2016 3:42 pm

thank you Jean-Marc,
I've looked at start using in the dictionary but I don't understand it quite well.
Can you use all objects in that stack or just scripts.

I also looked at copy in dictionary and I understand that but what i don't understand is how to implement download from a standalone app, both desktop and mobile, and do I save the stacks for download as standalone apps. for example exe file for windows.

once I copy a card to use do still need to use "Start using".

Is there an example code or tutorial for this?


Thank you


Sheldon

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Downloading an extension to the app

Post by jmburnod » Sat Mar 12, 2016 5:42 pm

Sorry, my english is not the best in this forum. There is some guys whom think I can progress :D
Can you use all objects in that stack or just scripts.
I my context I use scripts and custom properties but I think you can place a group from the mainstack onto downloaded stack or copy objets.
how to implement download from a standalone app
this thread should be useful for that
http://forums.livecode.com/viewtopic.ph ... =+download
do I save the stacks for download as standalone apps. for example exe file for windows.
No. The stacks stay a .livecode file but you can open it from your standalone app
https://alternatic.ch

Voyd
Posts: 13
Joined: Thu Mar 10, 2016 8:11 pm

Re: Downloading an extension to the app

Post by Voyd » Mon Mar 14, 2016 1:22 pm

Hi Jean-Marc,
Sorry for the late reply. This helped a lot thank you.

I'm able to copy a card over into my standalone but when I close then execute the standalone again the card is not there. Is there a way to allow the standalone to retain the card after copying and close without having to copy again?

I hope I'm clear in what I want to achieve.


Thank you


Sheldon

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Downloading an extension to the app

Post by jmburnod » Mon Mar 14, 2016 2:09 pm

Hi Sheldon,
Is there a way to allow the standalone to retain the card after copying
NO.Your standalone remains like you compiled it when you close it
If you want add cds I think use stacks is a better way
Jean-Marc
https://alternatic.ch

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Downloading an extension to the app

Post by Klaus » Mon Mar 14, 2016 2:42 pm

Hi Sheldon,

please keep in mind that Apple stirctly forbids downloading "code"
and stacks are considered code by Apple unfortunately.

Can't you provide a "complete" stack and only let the user go to until then
forbidden cards/substacks after entering the "in-app-purchase" code?
Know what I mean?

No idea if this is feasable for with your app.


Best

Klaus

Voyd
Posts: 13
Joined: Thu Mar 10, 2016 8:11 pm

Re: Downloading an extension to the app

Post by Voyd » Mon Mar 14, 2016 5:38 pm

Hi Jean-Marc,
Ok thank you.
All works for me except the progress bar. I followed the lesson located at livecode website how-to-show-the-progress-of-a-download because i did not understand it from your application.

When I use :

Code: Select all

put pStatus
it only shows connected which leads to

Code: Select all

if the number of items in pStatus = 3 then
being false and showProgress ending.


Any solution?


Thank you


Sheldon

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Downloading an extension to the app

Post by jmburnod » Mon Mar 14, 2016 6:41 pm

Hi Sheldon,
All works for me except the progress bar
I just tested it and it works for me
I followed the lesson located at livecode website
I used a custom progressbar. I'm not sure that was a good idea :D
Have a look to "--•• progress bar" in cd script
Jean-Marc
https://alternatic.ch

Voyd
Posts: 13
Joined: Thu Mar 10, 2016 8:11 pm

Re: Downloading an extension to the app

Post by Voyd » Tue Mar 15, 2016 1:33 pm

Hi Jean-Marc,

I really don't understand your custom progress bar, I know it should but I'm unable get my head around it.

This is the entire code I'm trying to use, and all work except the progress bar. I don't know what I'm doing wrong.
I'm on windows platform if that makes a different and I will be using the app on multiple platforms.

Code: Select all

on mouseUp

   put "urlToFile" into tDownloadLink 
   
   libURLSetStatusCallback "showPro", the long name of me
   
   hide scrollbar "proBar"
   
    load URL tDownloadLink with message "downloadComplete"
end mouseUp

command showPro pURL, pStatus

    if the number of items in pStatus = 3 then
        if the visible of scrollbar "proBar" = false then
            put the last item of pStatus into tTotalBytes
            set the startValue of scrollbar "proBar" to 0
            set the endValue of scrollbar "proBar" to tTotalBytes
            show scrollbar "proBar"
        end if
        
        set the thumbPosition of scrollbar "proBar" to item 2 of pStatus
     end if
   put pStatus
end showPro

command downloadComplete pURL, pStatus
   
   hide scrollbar "proBar"
   
   if pStatus = "error" or pStatus = "timeout" then
      answer error "The file could not be downloaded."
   else
      put the effective filename of this stack into fPath
      set the itemDelimiter to slash
      delete last item of fPath
      put last item of pURL into tFilename
      put fPath & slash before tFileName
      put URL pURL into URL ("binfile:" & tFileName)
      
      unload pURL
   end if
end downloadComplete
only minor changes from the livecode lesson

Thank you


Sheldon

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Downloading an extension to the app

Post by jmburnod » Tue Mar 15, 2016 7:57 pm

Hi Sheldon,

For download I use libURLDownloadToFile, I never used "load URL"
I believe understand libURLDownloadToFile is better for callbacks (and also for mobile.

What do you get at

Code: Select all

...
   put pStatus
end showPro
Best regards
Jean-Marc
https://alternatic.ch

Voyd
Posts: 13
Joined: Thu Mar 10, 2016 8:11 pm

Re: Downloading an extension to the app

Post by Voyd » Wed Mar 16, 2016 3:51 pm

Hi Jean-Marc,

I get "contacted"

and i know i need it to had loading ***

I have no clue how to use libURLDownload
I will try and search for a tutorial on it.

EDIT: when I try a new button with just the libURL and callback it comes up as downloaded

Thank you


Sheldon

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Downloading an extension to the app

Post by jmburnod » Wed Mar 16, 2016 7:30 pm

Hi Sheldon,
I have no clue how to use libURLDownload
I will try and search for a tutorial on it.
I thought that stack "DownloadZipExtract001" was one. :D
You can match the process
Best regards
Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Downloading an extension to the app

Post by jmburnod » Thu Mar 31, 2016 9:19 am

I write back about the first subject of this thread.
As Klaus said, we can not download stack.

I’m working now for a « iTunes way » to add one folder with one stack, one .txt file and one subfolder with .txt files in the documents folder of my app. For OS X, Windows and iOS.
It works like that

First install
1. check folders with specific prefix like « onePackageModule_ » & nameModule exist in documents folder
2. check there is a file nameModule & « .txt « 
This file contains one line to verify identity and one line about the folder content
3. move folder to new destination by rename folder

Update
1. check there is a same folder
2. check version in file nameModule & « .txt « 
3. move stack by rename file
4. write version infos to file nameModule & « .txt « 

Subfolder with .txt files (exemples and files created by user) is conserved

Best regards
Jean-Marc
https://alternatic.ch

Post Reply