  !include "MUI.nsh"
ShowInstDetails show
Name "GetText"
OutFile "GetText_Testing.exe"

#  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_INSTFILES
  !insertmacro MUI_LANGUAGE "English"
  

Function VersionCompare
	!define VersionCompare `!insertmacro VersionCompareCall`

	!macro VersionCompareCall _VER1 _VER2 _RESULT
		Push `${_VER1}`
		Push `${_VER2}`
		Call VersionCompare
		Pop ${_RESULT}
	!macroend

	Exch $1
	Exch
	Exch $0
	Exch
	Push $2
	Push $3
	Push $4
	Push $5
	Push $6
	Push $7

	begin:
	StrCpy $2 -1
	IntOp $2 $2 + 1
	StrCpy $3 $0 1 $2
	StrCmp $3 '' +2
	StrCmp $3 '.' 0 -3
	StrCpy $4 $0 $2
	IntOp $2 $2 + 1
	StrCpy $0 $0 '' $2

	StrCpy $2 -1
	IntOp $2 $2 + 1
	StrCpy $3 $1 1 $2
	StrCmp $3 '' +2
	StrCmp $3 '.' 0 -3
	StrCpy $5 $1 $2
	IntOp $2 $2 + 1
	StrCpy $1 $1 '' $2

	StrCmp $4$5 '' equal

	StrCpy $6 -1
	IntOp $6 $6 + 1
	StrCpy $3 $4 1 $6
	StrCmp $3 '0' -2
	StrCmp $3 '' 0 +2
	StrCpy $4 0

	StrCpy $7 -1
	IntOp $7 $7 + 1
	StrCpy $3 $5 1 $7
	StrCmp $3 '0' -2
	StrCmp $3 '' 0 +2
	StrCpy $5 0

	StrCmp $4 0 0 +2
	StrCmp $5 0 begin newer2
	StrCmp $5 0 newer1
	IntCmp $6 $7 0 newer1 newer2

	StrCpy $4 '1$4'
	StrCpy $5 '1$5'
	IntCmp $4 $5 begin newer2 newer1

	equal:
	StrCpy $0 0
	goto end
	newer1:
	StrCpy $0 1
	goto end
	newer2:
	StrCpy $0 2

	end:
	Pop $7
	Pop $6
	Pop $5
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Exch $0
FunctionEnd

  !define GetBetween "!insertmacro GetBetween"

!macro GetBetween <version> </version> In Return
Push "${<version>}"
Push "${</version>}"
Push "${In}"
 Call GetBetween
Pop "${Return}"
!macroend


Section "Check"
${GetBetween} "<version>" "</version>" "$INSTDIR\currentversion.xml" "$R0"
${VersionCompare} "5.405" "5.403" "$R0"
StrCmp $R0 0 0 +2
 MessageBox MB_OK "Versions equal" IDOK Done
StrCmp $R0 1 0 +2
 MessageBox MB_OK "There is an Update. CurrentVersion is Older" IDOK Done
StrCmp $R0 2 0 +2
 MessageBox MB_OK "CurrentVersion is Newer than the Most Recent Version on Site, Which is Odd? You must be the Creator And you Haven't Updated the XML Yet.!!!!"
Done:
SectionEnd


Function GetBetween
 Exch $R0 ; file
 Exch
 Exch $R1 ; before this (marker 2)
 Exch 2
 Exch $R2 ; after this  (marker 1)
 Exch 2
 Push $R3 ; marker 1 len
 Push $R4 ; marker 2 len
 Push $R5 ; marker pos
 Push $R6 ; file handle
 Push $R7 ; current line string
 Push $R8 ; current chop

 FileOpen $R6 $R0 r

 StrLen $R4 $R2
 StrLen $R3 $R1

 StrCpy $R0 ""

 Read1:
  ClearErrors
  FileRead $R6 $R7
  IfErrors Done
  StrCpy $R5 0

 FindMarker1:
  IntOp $R5 $R5 - 1
  StrCpy $R8 $R7 $R4 $R5
  StrCmp $R8 "" Read1
  StrCmp $R8 $R2 0 FindMarker1
   IntOp $R5 $R5 + $R4
   StrCpy $R7 $R7 "" $R5

  StrCpy $R5 -1
  Goto FindMarker2

 Read2:
  ClearErrors
  FileRead $R6 $R7
  IfErrors Done
  StrCpy $R5 -1

 FindMarker2:
  IntOp $R5 $R5 + 1
  StrCpy $R8 $R7 $R3 $R5
  StrCmp $R8 "" 0 +3
   StrCpy $R0 $R0$R7
  Goto Read2
  StrCmp $R8 $R1 0 FindMarker2
   StrCpy $R7 $R7 $R5
   StrCpy $R0 $R0$R7

 Done:
  FileClose $R6

 Pop $R8
 Pop $R7
 Pop $R6
 Pop $R5
 Pop $R4
 Pop $R3
 Pop $R2
 Pop $R1
 Exch $R0
FunctionEnd
