Jump to content
Sign in to follow this  

UDF to check between two program versions

Recommended Posts

If you run _INetUpdater() or similar functions, you probably find this UDF may help you.

Happy AutoIt to everyone!

; Description:      Check if, in two strings reporting a version number each,
;                   the first one is newer than the second
;                   eg: when comparing downloaded updates
; Syntax:           _IsFirstOneNewer($sSource, $sDest)
; Parameter(s):     $sSource
;                         eg: ''
;                   $sDest
;                         eg: ''
; Requirement(s):   $sSource and $sDest must be in the form number.number.number.number
; Return Value(s):  On Success - True or False
;                   On Failure - False and @error is set to 1
; Author:           MCP, Aristotele.Skotos, aka ...

Func _IsFirstOneNewer($sSource, $sDest) ; FYI: newer means not equal too
    Local $bRC = False, _
            $aSource = StringSplit($sSource, '.'), _
            $aDest = StringSplit($sDest, '.')

    If 4 <> $aSource[0] Or 4 <> $aDest[0] Or @NumParams <> 2 Then
        Return $bRC

    For $i = 1 To 4
        If Number($aSource[$i]) > Number($aDest[$i]) Then
            $bRC = True
    Return $bRC
EndFunc   ;==>_IsFirstOneNeweroÝ÷ Øî²×èºwm+(ëh¡«­¢+Ù}

EDIT: Added check for wrong number of parameters

EDIT: Added official UDF from <Misc.au3>

EDIT: Corrected an error in the elements number check

Edited by MCP

Share this post

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...