;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       KixVer() 
;; 
;;ACTION         Exits if not running minimum Kix or Beta version  
;; 
;;AUTHOR         Glenn Barnas  
;; 
;;VERSION        1.0  - 2003/05/19 
;; 
;;HISTORY        1.0  - 2003/05/19 - Initial Release 
;; 
;;SYNTAX         KixVer(ver [,SoftErr [,BRC]]) 
;; 
;;PARAMETERS     Minimum - Required - String 
;;               - Value of minimum allowable Kix version 
;; 
;;               SoftErr - Optional - Integer 
;;               - Return error if non-zero, default is End Program 
;; 
;;               BRC - Optional - Integer 
;;               - Allows use of Beta or Release Candidate if non-zero 
;; 
;;REMARKS        This function is used to insure use of proper Kix versions 
;; 
;;RETURNS        Kixtart version string if Return is set, otherwise it terminates  
;;               the script if minimum version requirement is not met. 
;; 
;;DEPENDENCIES   none 
;; 
;;TESTED WITH    NT4, W2K, WXP, W2K3 
;; 
;;EXAMPLES       KixVer(4.21,0,1)  ; requires ver 4.21, allows Beta version 
;; 
;;UPDATES        01/31/04 - fixed quotes in message 
; 
Function KixVer($_Minimum, OPTIONAL $_SoftErr, OPTIONAL $_BRC)
 
  Dim $_CVer, $_VerOK, $_MSG, $_fPtr, $_fX
  $_fPtr = 0
 
  $_CVer = Split(@KIX,' ')
  For $_fX = 0 to UBound($_CVer)
    If InStr('Kix200', Left($_CVer[$_fX],3))
      $_fPtr = $_fPtr + 1
    EndIf
  Next
 
  $_VerOK = 1              ; assume good version 
 
  If $_CVer[$_fPtr] < $_Minimum
    ; Version running is less than minimum allowed 
    $_VerOK = 0
    $_MSG = "Can't run with Outdated Kix Version!"
  Else
    ; If any commentary exists, it isn't a production version. $BRC true allows it, though. 
    If UBound($_CVer) > 0 And $_BRC = 0
      $_VerOK = 0        ; current, but not production 
      $_MSG = "Can't run with Beta or Release Candidate!"
    EndIf
  EndIf
 
  ; Prepare to return the current kixtart version 
  $KixVer = @KIX
 
  ; Minimum version was not found 
  If $_VerOK = 0
    If $_SoftErr = 0
      ; complain and terminate script if version is not acceptable 
      ; use hard print and not MSG function when terminating! 
      ? 'Version Check! Need ' + $_Minimum + ', running @KIX' ?
      $_MSG ?
      Quit 120
    Else
      Exit 120
    EndIf
  EndIf
 
  Exit 0
 
EndFunction