checking for new versions of your app
#1
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.
Reply
#2
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
Reply
#3
(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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)
Free Web Hosting