;PAGESTREAM 3.1 BETA 3 ONLINE UPDATE PATCH INSTALLATION SCRIPT
;COPYRIGHT 1996 SOFTLOGIK PUBLISHING CORPORATION

;WARN WEENIES TO GET LOST
(message "\n\nThis is a pre-release BETA version of PageStream 3.1. Stop now if you haven't read the Read.1st! file. Clicking Proceed indicates that you are knowingly installing beta software on your system.")

;QUIT PROGRAMS
(message "\n\nIf PageStream, BME or PageLiner are running now, quit them before continuing.")
(run "avail flush" (safe))

;USE ASSIGNS TO AVOID THE STUPID INSTALLER'S CRASH BUG
(run "CD PageStream3:" (safe))
(run "CD SoftLogik:" (safe))
(run "assign fonts: softlogik:fonts add" (safe))

;CONFIRM CORRECT VERSION IS INSTALLED, SET DESTINATION
(message ("\n\nThis patch will update your PageStream 3.1 beta 2 hard drive installation to the 3.1 Pre-Release beta 3 version.\n\nYour original PageStream3 disks will not be modified by this update.\n\nYou MUST have 3.1 beta 2 installed to use this patch."))
(if (<> (exists "PageStream3:PageStream3") 1)
	(abort "PageStream3 is not in the PageStream3: directory. You must properly install PageStream3.1 beta 2 before applying this update patch.")
)
;get destination
(set PGSdest (getassign "PageStream3" "a"))
(set SLdest (getassign "SoftLogik" "a"))
(if (OR (= PGSdest "") (= SLdest ""))
	(abort "PageStream3: and/or SoftLogik: are not assigned. You must properly install PageStream 3.1 beta 2 before applying this update patch.")
)
(set PGSsize (getsize "PageStream3:PageStream3"))
(if (<> PGSsize 1387292)
	(abort "You have the wrong version of PageStream installed. Please read the Read.1st! file for instructions.")
)
(set @default-dest PGSdest)

;MAKE REQUIRED DIRECTORIES IF THEY DON'T EXIST
(if (<> (exists "SoftLogik:Engines") 2) (makedir "SoftLogik:Engines" (infos)))
(if (<> (exists "SoftLogik:Libs") 2) (makedir "SoftLogik:Libs" (infos)))
(if (<> (exists "SoftLogik:Printers") 2) (makedir "SoftLogik:Printers" (infos)))
(if (<> (exists "SoftLogik:Filters") 2) (makedir "SoftLogik:Filters" (infos)))
(if (<> (exists "SoftLogik:Effects") 2) (makedir "SoftLogik:Effects" (infos)))
(if (<> (exists "PageStream3:Help") 2) (makedir "PageStream3:Help" (infos)))
(if (<> (exists "PageStream3:Scripts") 2) (makedir "PageStream3:Scripts" (infos)))
(if (<> (exists "PageStream3:Scripts/TextClips") 2) (makedir "PageStream3:Scripts/TextClips" (infos)))
(if (<> (exists "PageStream3:Documents") 2) (makedir "PageStream3:Documents" (infos)))

;COPY THE LHEX PROGRAM TO RAM:
(copyfiles (source "PageStream3Disk1:lhex") (dest "ram:") (nogauge))

;UPDATE FILTERS
(working "Installing Updated Filters...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Filters x Filters.lha")
(delete "Filters.LHA" (safe))

;UPDATE LIBS
(working "Installing Updated Libraries...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Libs x Libs.lha")
(delete "Libs.LHA" (safe))

;UPDATE ENGINES
(working "Installing Updated Engines...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Engines x Engines.lha")
(delete "Engines.LHA" (safe))

;UPDATE PRINTERS
(working "Installing Updated Printer Drivers...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Printers x Printers.lha")
(delete "Printers.LHA" (safe))

;UPDATE SCRIPTS
(working "Installing Updated Scripts...")
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3:Scripts x Scripts.lha")
(delete "Scripts.LHA" (safe))

;UPDATE BME
(if (exists "PageStream3:BME")
	(
		(working "Patching BME to 3.1a Beta...")
		(run "ram:lhex >NIL: <NIL: -qfw=ram: x BMEpatch.LHA")
		(delete "BMEpatch.LHA" (safe))
		(run "spatch >NIL: <NIL: -oPageStream3:BME3.1 -pram:BME.pch PageStream3:BME")
		(if (exists "PageStream3:BME3.1")
			(
				(delete "PageStream3:BME")
				(rename "PageStream3:BME3.1" "PageStream3:BME")
			)
			(message "\nThe patch to BME was not successful. Refer to the Read.1st! file for further instructions.")
		)
		(delete "ram:BME.pch" (safe))
	)
)

;UPDATE PAGESTREAM3
(working "Patching PageStream to 3.1 Beta 3...\n\nThis will take a while...")
(run "ram:lhex >NIL: <NIL: -qfw=ram: x PGSpatch.LHA")
(delete "PGSpatch.LHA" (safe))
(run "spatch >NIL: <NIL: -oPageStream3:PageStream3.1 -pram:PageStream.pch PageStream3:PageStream3")
(if (exists "PageStream3:PageStream3.1")
		(
				(delete "PageStream3:PageStream3")
				(rename "PageStream3:PageStream3.1" "PageStream3:PageStream3")
		)
		(abort "The patch to PageStream3 was not successful. Refer to the Read.1st! file for instructions.")
)
(delete "ram:PageStream.pch" (safe))

;DISPLAY README (Try 3 different ways!)
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3: x Read.LHA")
(delete "Read.LHA" (safe))
(IF (> (run "Sys:Utilities/MultiView PageStream3:ReadMe.Now") 0)
		(IF (> (run "Sys:Utilities/AmigaGuide PageStream3:ReadMe.Now") 0)
				(run "More PageStream3:ReadMe.Now")
		)
)

;REMOVE THE LHEX PROGRAM
(delete "ram:lhex" (safe))
(delete "spatch" (safe))
(delete "Install-Beta3.info" (safe))

;DONE
(exit "Finished Installation")
