Jump to content

Best way to update?


Recommended Posts

I wrote a funtion that checks online for available updates to the program and if so, downloads and installs those updates. I forgot to add a check to make sure the internet is reachable and when I used the program on a computer without internet, the program took forever to get past the update function. Looking around the forums I found two ways to check if there is a reason to continue updating.

Method One:

Update()
DoOtherStuff()

Func Update()   
    $dl = InetGet("http://www.website.com/version.ini", @DesktopDir & "/version.ini", 0, 1)
    If $dl == 0 Then
        FileDelete(@DesktopDir & "/version.ini")
        Return
    EndIf
    $chk = IniRead(@DesktopDir & "/version.ini", "version", "ver", 0)
    If $chk > FileGetVersion(@ScriptFullPath) Then
        ...
        ...
        ...
    Else
        FileDelete(@DesktopDir & "/version.ini")
    EndIf
EndFunc

Method Two:

Update()
DoOtherStuff()

Func Update()   
    InetGet("http://www.website.com/version.ini", @DesktopDir & "/version.ini", 0, 1)
    If @error Then
        FileDelete(@DesktopDir & "/version.ini")
        Return
    EndIf
    $chk = IniRead(@DesktopDir & "/version.ini", "version", "ver", 0)
    If $chk > FileGetVersion(@ScriptFullPath) Then
        ...
        ...
        ...
    Else
        FileDelete(@DesktopDir & "/version.ini")
    EndIf
EndFunc

Which is the prefered method?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...