Jump to content
Sign in to follow this  
Apocalypse

Best way to update?

Recommended Posts

Apocalypse

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?

Share this post


Link to post
Share on other sites
BrettF

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.