; $VER: InstallAnimGIF_Update 1.1
; Cloanto AnimGIF Update Installer Script
; Copyright © 1996, 1997 Cloanto Italia srl
; Cloanto is a registered trademark of Cloanto Italia srl
; "Installer and Installer project icon Copyright © 1991-1993 Commodore-Amiga, Inc. All Rights Reserved
;  Reproduced and distributed under license from Commodore"
; New installer icon design Copyright © 1994 Cloanto Italia srl

(set #which-dir
	"Please indicate the directory where Personal Paint 7 is installed:")

(set #which-dir-help
	(cat "\nThis program updates the Rexx scripts and the I/O "
	"library which are used by Personal Paint 7 to create and "
	"load GIF animations."
	"\n\nPlease specify the full path of the installed Personal "
	"Paint software, including the final \"PPaint\" directory name "
	"(or other, if a different drawer name was used).\n\n"
	@askdir-help))

(set #message-loadanimgifok
	"\nThis update is not required for the LoadAnimGif Rexx script which is already installed. This step will be skipped.")

(set #message-saveanimgifok
	"\nThis update is not required for the SaveAnimGif Rexx script which is already installed. This step will be skipped.")

(set #message-pgifioliboklcl
	"\nThis update is not required for the Personal GIF I/O library which is already installed in PPaint:libs. This step will be skipped.")

(set #message-pgifioliboksys
	"\nThis update is not required for the Personal GIF I/O library which is already installed in LIBS:. This step will be skipped.")

(set #message-pgifiolibnotoklcl
	"\nThis update was not designed for the version of the Personal GIF I/O library which was found in PPaint:libs. This step will be skipped.")

(set #message-pgifiolibnotoksys
	"\nThis update was not designed for the version of the Personal GIF I/O library which was found in LIBS:. This step will be skipped.")

(set #error-loadanimgif
	"\nLoadAnimGif Rexx script could not be found in PPaint:Rexx. It will not be updated.")

(set #error-saveanimgif
	"\nSaveAnimGif Rexx script could not be found in PPaint:Rexx. It will not be updated.")

(set #error-pgifiolib
	"\nPersonal GIF I/O library could not be found in PPaint:libs. It will not be updated.")

(set #busy-loadanimgif
	"Updating LoadAnimGif Rexx script.")

(set #busy-saveanimgif
	"Updating SaveAnimGif Rexx script.")

(set #busy-pgifioliblcl
	"Updating Personal GIF I/O library in PPaint:libs.")

(set #busy-pgifiolibsys
	"Updating Personal GIF I/O library in LIBS:.")

(if (AND (<> (getassign "PSUITEROOT" "a") "") (<> (getassign "KARACDROOT" "a") "")) (set ppaint_dest "") (set ppaint_dest (getassign "PPaint" "a")))
(if (<> (getassign "PCDPPAINT" "a") "") (set ppaint_dest (getassign "PCDPPAINT" "a")))
(if (AND (<> (getdevice ppaint_dest)(getdevice "RAM:"))(< (getdiskspace ppaint_dest) 10240)) (set ppaint_dest ""))
(if (= ppaint_dest "") (set ppaint_dest @default-dest))

(set ppaint_dest (askdir
	(prompt #which-dir)
	(help #which-dir-help)
	(default ppaint_dest)
	(newpath)
))

(set target1 (tackon ppaint_dest "PPaint"))
(if (<> (exists target1) 1) (if (= (exists target1) 2) (set ppaint_dest target1)))
(set @default-dest ppaint_dest)

(working #busy-loadanimgif)
(set source1 "Rexx/LoadAnimGif.pprx")
(set target1 (tackon ppaint_dest source1))
(if (<> (exists target1) 1) (message #error-loadanimgif) (
	(if (AND (NOT (earlier target1 source1)) (>= (getsize target1) (getsize source1))) (message #message-loadanimgifok) (
		copyfiles
			(prompt #busy-loadanimgif)
			(help @copyfiles-help)
			(source source1)
			(dest (pathonly target1))
			(optional "nofail" "force")
			(confirm)
	))
))

(working #busy-saveanimgif)
(set source1 "Rexx/SaveAnimGif.pprx")
(set target1 (tackon ppaint_dest source1))
(if (<> (exists target1) 1) (message #error-saveanimgif) (
	(if (AND (NOT (earlier target1 source1)) (>= (getsize target1) (getsize source1))) (message #message-saveanimgifok) (
		copyfiles
			(prompt #busy-saveanimgif)
			(help @copyfiles-help)
			(source source1)
			(dest (pathonly target1))
			(optional "nofail" "force")
			(confirm)
	))
))

(set target1 (tackon ppaint_dest "libs/personal_gif_io.library"))
(if (<> (exists target1) 1) (message #error-pgifiolib) (
	(if (>= (getversion target1) 327683) (message #message-pgifioliboklcl) (
		(if (= (getsize target1) 12112) (
			(working #busy-pgifioliblcl)
			(set runstring (cat "spatch >NIL: <NIL: \"-o" target1 "\" -ppersonal_gif_io_51.pch \"" target1 "\""))
			(run runstring)
		))
		(if (<> (getsize target1) 12596) (message #message-pgifiolibnotoklcl) (
			(working #busy-pgifioliblcl)
			(set runstring (cat "spatch >NIL: <NIL: \"-o" target1 "\" -ppersonal_gif_io_52.pch \"" target1 "\""))
			(run runstring)
			(run "Avail >NIL: <NIL: FLUSH")
		))
	))
))

(set target1 "LIBS:personal_gif_io.library")
(if (= (exists target1) 1) (
	(if (>= (getversion target1) 327683) (message #message-pgifioliboksys) (
		(if (= (getsize target1) 12112) (
			(working #busy-pgifiolibsys)
			(set runstring (cat "spatch >NIL: <NIL: \"-o" target1 "\" -ppersonal_gif_io_51.pch \"" target1 "\""))
			(run runstring)
		))
		(if (<> (getsize target1) 12596) (message #message-pgifiolibnotoksys) (
			(working #busy-pgifiolibsys)
			(set runstring (cat "spatch >NIL: <NIL: \"-o" target1 "\" -ppersonal_gif_io_52.pch \"" target1 "\""))
			(run runstring)
			(run "Avail >NIL: <NIL: FLUSH")
		))
	))
))

(exit)
