;$VER: Twist_Patcher 2.21 (14.7.95)
;Twist update script

(set patchver (getversion "UpdateTwist2"))
(set patchver$ (cat (/ PATCHVER 65536) "." (- PATCHVER (* (/ PATCHVER 65536) 65536))) )

(user 2)

(Message "\n\nThis is the freely distributable patch for Twist 2 Amiga (English language),"
" this patch utility requires the correct patch for your version of Twist (See the About Box in Twist 2) and"
" the original Twist 2 distribution disk.\n\nNOTE: This patch will not work on\ninstalled versions of Twist."
)

(Message "\nInsert a backup copy of your Twist\nmaster disk in drive DF0:\n\n"
"**********************************\n"
"\nWarning: This disk will be\naltered by the update utility\n\n"
"**********************************"
)
 
(PROCEDURE CHOOSEPATCH

(Working "\nChecking current version\n\nPlease Wait...")
(set currentver (getversion "DF0:Twist/Twist2"))

(if (AND (>= (- CURRENTVER (* (/ CURRENTVER 65536) 65536)) 1) (<= (- CURRENTVER (* (/ CURRENTVER 65536) 65536)) 9))
(set currentver$ (cat (/ CURRENTVER 65536) ".0" (- CURRENTVER (* (/ CURRENTVER 65536) 65536))))
(set currentver$ (cat (/ CURRENTVER 65536) "." (- CURRENTVER (* (/ CURRENTVER 65536) 65536))))
)

(set patchfile (cat "Patch" currentver$))


(debug currentver currentver$ patchfile)


                                                                                                                                                                                               )
(PROCEDURE CHECKVER

	(If (<> (exists patchfile) 1)

		(

		(If (= patchver$ currentver$)
			(
			(Message ("\nThe latest version(%s) is already installed" currentver$))
			(EXIT (QUIET))
			)
		)

		(Message ("\nIncorrect patch file you require\nthe %s to %s patch" currentver$ patchver$))
		(EXIT (QUIET))

		)
	)

)
(PROCEDURE RUNPATCH

(if (< currentver patchver)

	(
	(Working ("You have version %s of Twist\n\nPatching Twist to version %s Please wait"  currentver$ patchver$))
	(run ("spatch -oram:TwistNew -p%s DF0:Twist/Twist2" patchfile))

	(If (= (exists "RAM:TwistNew") 1)

		(

		(copyfiles
		(source "RAM:TwistNew")
		(dest "DF0:Twist")
		(newname "Twist2")
		(optional "force" "nofail")
		)
		(delete "RAM:TwistNew")
		(Message "Patch has been successful. \n\nRe-install the new version of\nTwist from the updated disk")
		)

		(Message "Patch has failed, contact tech support for an update disk")

	)

	)

	(Message "Incompatible patch file, contact tech support for an update disk")

)

)

(CHOOSEPATCH)
(CHECKVER)
(RUNPATCH)