yab | yet another Basic for HAIKU
checking for new versions of your app - Printable Version

+- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum)
+-- Forum: Programming in yab (https://yab.orgfree.com/forum/forumdisplay.php?fid=1)
+--- Forum: Snippets (https://yab.orgfree.com/forum/forumdisplay.php?fid=3)
+--- Thread: checking for new versions of your app (/showthread.php?tid=12)



checking for new versions of your app - clasqm - 07-05-2015

Is this function now obsolete because of packaging? Perhaps, but your user might still enjoy being reminded to update.

On a server under your control, put a one-line text file containing the current available version. Like this:

v0.2

Use Pe to generate this. StyledEdit has this irritating habit of ending the file with a newline even if you didn't put one there. If there are two lines you will confuse the routine. Do not hit Enter after the text! The lowercase v is also important here.It gives us a quick-and-dirty way to check connectivity.

There are two global variables involved. AppVersion$ is the version set in the program itself and used in the About box and such. UpdateFile$ is the full URL to the one-line text file. They don't HAVE to be global, of course, but I happen to use these variables elsewhere

Code:
sub FindUpdates()
    local version$,selector
    version$ = system$("curl --connect-timeout 1 " + UpdateFile$)
    if left$(version$,1)<>"v" then
        alert "Unable to connect to update server!", "OK", "warning"
        return
    endif
    if version$ = AppVersion$ then
        alert "You have the latest version of this program.", "OK", "info"
        return
    else
        selector = alert "A newer version of this program is available. Take  a look?", "Yes", "No", "", "info"
        if selector = 1 launch "http://mysite.mweb.co.za/residents/clasqm/haiku/yab-apps/index.html"
    endif
end sub

Now you just need to remember to update UpdateFile$ whenever you post up a new version.


PS. Jim does this forum have a "Code" function?

A possible tweak to this might be that the app itself notes that its version number is higher than the one in UpdateFile$ and auto-updates the remote file. Must look into that.


RE: checking for new versions of your app - bbjimmy - 07-05-2015

Quote:PS. Jim does this forum have a "Code" function?

This seems to work:

see yab | yet another Basic for HAIKU / Help Documents / MyCode

Code:
local version$,selector
    version$ = system$("curl --connect-timeout 1 " + UpdateFile$)
    if left$(version$,1)<>"v" then
        alert "Unable to connect to update server!", "OK", "warning"
        return
    endif
    if version$ = AppVersion$ then
        alert "You have the latest version of this program.", "OK", "info"
        return
    else
        selector = alert "A newer version of this program is available. Take  a look?", "Yes", "No", "", "info"
        if selector = 1 launch "http://mysite.mweb.co.za/residents/clasqm/haiku/yab-apps/index.html"
    endif
end sub



RE: checking for new versions of your app - clasqm - 07-06-2015

(07-05-2015, 10:49 PM)bbjimmy Wrote:
Quote:PS. Jim does this forum have a "Code" function?

This seems to work:

Much better, thanks. I'll update my posts.


Free Web Hosting