image ResEx Logo
ResExcellence www : Powered by Google
Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Articles
   3D
   Audio
   Custom Controls
   General RB
   Graphics
   Hacks
   Mac OS X
   Menus
   Novelty
   Printing
   REALbasic 2005
   REALbasic 2006
   Registration
   Resources
   Reviews
   Serial
   Speech
   Sockets
   XML
   Video
Resource Links
News
   Current News
   February 2006
   January 2006
   December 2005
   November 2005
   October 2005
   September 2005
   August 2005
   July 2005
   June 2005
   May 2005
   April 2005
   March 2005









REALbasic for Dummies
by Erick Tejkowski


Learning REALbasic through Applications
by Clayton E., Crooks II


REALbasic for Macintosh
by Michael Swaine


REALbasic Cross-Platform Application Development
by Mark S. Choate





Older files are in Stuffit 5 or greater format. Newer files are ".Zip". Download StuffIt Expander
Tell us about a bad link. Thank You!

Version Tracking
05-30-02

Printer Version




Ever wonder how REALbasic programmers implement the "Check for Updates" feature found in so many apps today? This week we'll look at a simple example of how to do this.


Build the Interface

Launch REALbasic and open Window1. To this window, add a PushButton, an EditField, a StaticText control, a ChasingArrows control, and a Socket. Change the properties of each to match the following table:

Control Type Name Other Info
EditField EditField1  
PushButton PushButton1 Caption = "Check Version"
Socket httpSocket1 super = "httpSocket"

Notice that you don't have an httpSocket in your project yet. If you want to follow along, download the httpSocket from Dan Vanderkam and drag the httpSocket class into your project. Then go back and change the Super property of the httpSocket1 to httpSocket. If you don't feel like finding the parts, you can download the completed project at the end of this tutorial.

Arrange the interface to your liking. For example, it might look like this:

05-30-02_interface.jpg (6k)

Source Code

Double click PushButton1 to open the Code Editor and add the following code to its Action event:

  
  dim theURL as string
  
  // a sample version-number-file on the resex server
  theURL = "/realbasic/articles/old_articles/downloads_02/05-30-02_version.txt"
  
  // Display the ChasingArrows
  // to show we are at work
  ChasingArrows1.visible = TRUE
  
  // Prep the Socket and get the file (as a variable)
  // The resulting variable will be available in the
  // DLFinished event of httpSocket1
  httpSocket1.httpSocket
  httpSocket1.storeInFile=true
  
  httpSocket1.Method = 1
  theURL = httpSocket1.FormatURL(theURL)
  httpSocket1.GetFile(theURL)
  
  

Finally, navigate to the DLFinished event of httpSocket1 and add this code:

  dim myversion as integer
  
  statictext1.text=txt 
  myversion=val(editfield1.text)
  
  // Hide the ChasingArrows
  // to show we are at finished
  ChasingArrows1.visible = FALSE
  
  if val(txt)>myversion then
    MsgBox "You need to update!"
  elseif val(txt)<myversion then
    MsgBox "Your version is newer than the currently available version!"
  else
    MsgBox "Your software is current."
  end if
  

Conclusion

That's it...short and sweet. The code downloads a file I've placed on the Resex server which holds a version number. Once downloaded, we simply compare the version number that is in that text file with the version number we've designated for this application. Then, we display an appropriate message. You can download the finished project here. See you next week!




Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement. [an error occurred while processing this directive]