This may not be the cleanest code but it works :-)

gPlat is a global denoting the platform:  P, X, or W
goUrl is whatever handler you use to take people to a webpage from your app
tUrl is the url sent to goUrl
pageText is the entire text of the web page where your version info is
In my case, it's a very long web page with the download links and version numbers at the bottom The only caveat is that you must remember not to change whatever string of text you use for this on the web page itself, or add the same string of text higher up with the version numbers. productVersionNumber is the latest version number, stored somewhere in your app for retrieval statusBar is a handler that updates a little status bar in the Info window in case they have a slow connection and it takes a minute, so they can see something is happening


if HostNameToAddress(www.yourDomain.com) is empty then
      answer "You are not connected to the internet.  Please" && \
          "connect to the internet and try again."
      exit to top
    else
put "Checking for updates. . . please wait. . ." into cd fld 2 of cd 1 of stack "Info"
      lock messages
      go invisible cd 1 of stack "Info" as modal
      set the loc of stack "Info" to the loc of stack "yourStack"
      set the decorations of stack "Info" to empty
      show stack "Info"
      unlock messages
      if "Info" is in openStacks() then
        send statusBar to someScript in 5 ticks
      end if
      put url "http://www.yourDomain.com/productPage.html"; into pageText
# Note that Product Name XXX needs to be a unique string of text
# Or be located at the top of the web page
      if gPlat is "P" then
put line (lineoffset("Product Name Classic", pageText)) of pageText into onlineVs
        set the wholeMatches to true
        get wordOffset("Classic",onlineVs)
        put word (it + 1) of onlineVs into onlineVs
      else if gPlat is "X" then
put line (lineoffset("Product Name OSX", pageText)) of pageText into onlineVs
        set the wholeMatches to true
        get wordOffset("OSX",onlineVs)
        put word (it + 1) of onlineVs into onlineVs
      else
put line (lineoffset("Product Name WIN", pageText)) of pageText into onlineVs
        set the wholeMatches to true
        get wordOffset("WIN",onlineVs)
        put word (it + 1) of onlineVs into onlineVs
      end if
      put productVersionNumber into currVs


      replace "." with "" in onlineVs
      replace "." with "" in currVs
      repeat with v = the number of chars of onlineVs down to 1
        if char v of onlineVs is not a number then
          delete char v of onlineVs
        end if
      end repeat
      if (onlineVs is not a number) or (currVs is not a number) then
        put "We were unable to get info on the newest available" && \
            "version.  Click anywhere in this window to close it." \
            into cd fld 2 of cd 1 of stack "Info"
        exit to top
      end if
      if onlineVs > currVs then
        if "Info" is in openStacks() then
          close stack "Info"
        end if
answer "There is a newer version available on our website. Go there now?" with "Yes" or "No"
        if it is "Yes" then
          put "http://www.yourDomain.com/productPage.html"; into tUrl
          goUrl tUrl
        end if
      else
put "You have the most current version." into cd fld 2 of cd 1 of stack "Info"
        wait until the mouseClick
        if "Info" is in openStacks() then
          close stack "Info"
        end if
      end if
    end if

--
Windows and Macintosh shareware games
BIackjack Gold
http://www.gypsyware.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to