;PAGESTREAM 3.2 BETA 7 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.2. 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 5 hard drive installation to 3.2 public beta 7.\n\nYour original PageStream3 disks will not be modified by this update.\n\nYou MUST have 3.1 beta 5 installed to use this patch.\n\nYou MUST have a battery-backed clock in your computer to use this version."))
(if (<> (exists "PageStream3:PageStream3") 1)
	(abort "PageStream3 is not in the PageStream3: directory. You must properly install PageStream3.1 beta 5 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 5 before applying this update patch.")
)
(set PGSsize (getsize "PageStream3:PageStream3"))
(if (<> PGSsize 1411964)
	(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)))
(if (= (exists "PageStream3:PageStream3.rsrc") 1) (delete "PageStream3:PageStream3.rsrc" (safe)))


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

;UPDATE FILTERS AND EFFECTS
(working "Installing Updated Filters...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Filters x Filters.lha")
(delete "Filters.LHA" (safe))
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Effects x Effects.lha")
(delete "Effects.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 13...")
		(run "ram:lhex >NIL: <NIL: -qfw=ram: x BMEpatch.LHA")
		(delete "BMEpatch.LHA" (safe))
		(run "spatch >NIL: <NIL: -oPageStream3:BMEnew -pram:BME.pch PageStream3:BME")
		(if (exists "PageStream3:BMEnew")
			(
				(delete "PageStream3:BME")
				(rename "PageStream3:BMEnew" "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.2 Beta 7...\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:PageStreamNew -pram:PageStream.pch PageStream3:PageStream3")
(if (exists "PageStream3:PageStreamNew")
		(
				(delete "PageStream3:PageStream3")
				(rename "PageStream3:PageStreamNew" "PageStream3:PageStream3")
		)
		(abort "The patch to PageStream3 was not successful. Refer to the Read.1st! file for instructions.")
)
(delete "ram:PageStream.pch" (safe))

;PATCH EXTRAS TO LATEST VERSION IF APPLICABLE

(run "ram:lhex >NIL: <NIL: -qfw=ram: x Patch.LHA")
(delete "Patch.LHA" (safe))

; PATCH TTF.KEY TO LATEST VERSION
(if (= (exists "SoftLogik:Special/Keys/TTF.key") 1)
	(
		(run "spatch -oram:TTF.font -pram:TTF.pch SoftLogik:Special/Keys/TTF.key")
		(if (= 37284 (getsize "ram:TTF.font"))
			(copyfiles (source "ram:TTF.font") (dest "SoftLogik:Engines"))
			(message "\n\nYour TrueType font engine could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem TTKEY2NEW.")
		)
		(delete "ram:TTF.font" (safe))
	)
)
(delete "ram:TTF.pch" (safe))

; PATCH WWDOC.KEY TO LATEST VERSION
(if (= (exists "SoftLogik:Special/Keys/WWdoc.key") 1)
	(
		(run "spatch -oram:Wordworth.dfilter -pram:WW.pch SoftLogik:Special/Keys/WWdoc.key")
		(if (= 35400 (getsize "ram:Wordworth.dfilter"))
			(copyfiles (source "ram:Wordworth.dfilter") (dest "SoftLogik:Filters"))
			(message "\n\nYour Wordworth document filter could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem WWKEY2NEW.")
		)
		(delete "ram:Wordworth.dfilter" (safe))
	)
)
(delete "ram:WW.pch" (safe))

; PATCH TEXTFX1.KEY TO LATEST VERSION
(if (= (exists "SoftLogik:Special/Keys/TextFX1.key") 1)
	(
		(run "spatch -oram:TextFX.extension -pram:TextFX1.pch SoftLogik:Special/Keys/TextFX1.key")
		(if (= 39508 (getsize "ram:TextFX.extension"))
			(copyfiles (source "ram:TextFX.extension") (dest "SoftLogik:Engines"))
			(message "\n\nYour TextFX1 extension could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem FX1KEY2NEW.")
		)
		(delete "ram:TextFX.extension" (safe))
	)
)
(delete "ram:TextFX1.pch" (safe))

; PATCH TEXTFX2.KEY TO LATEST VERSION
(if (= (exists "SoftLogik:Special/Keys/TextFX2.key") 1)
	(
		(run "spatch -oram:TextFX.extension -pram:TextFX2.pch SoftLogik:Special/Keys/TextFX2.key")
		(if (= 46768 (getsize "ram:TextFX.extension"))
			(copyfiles (source "ram:TextFX.extension") (dest "SoftLogik:Engines"))
			(message "\n\nYour TextFX1 extension could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem FX1KEY2NEW.")
		)
		(delete "ram:TextFX.extension" (safe))
	)
)
(delete "ram:TextFX2 .pch" (safe))

; PATCH JPEG.KEY TO LATEST VERSION
(if (= (exists "SoftLogik:Special/Keys/JPEG.key") 1)
	(
		(run "spatch -oram:JPEG.gfilter -pram:JPEG.pch SoftLogik:Special/Keys/JPEG.key")
		(if (= 95332 (getsize "ram:JPEG.gfilter"))
			(copyfiles (source "ram:JPEG.gfilter") (dest "SoftLogik:Filters"))
			(message "\n\nYour JPEG filter could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem JPKEY2NEW.")
		)
		(delete "ram:JPEG.gfilter" (safe))
	)
)
(delete "ram:JPEG.pch" (safe))

; PATCH GARY.KEY TO LATEST VERSION
(if (= (exists "SoftLogik:Special/Keys/Gary.key") 1)
	(
		(run "spatch -oram:Average.effect -pram:avg.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 5740 (getsize "ram:Average.effect"))
			(copyfiles (source "ram:Average.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Average effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWCV.")
		)
		(run "spatch -oram:Median.effect -pram:med.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 6264 (getsize "ram:Median.effect"))
			(copyfiles (source "ram:Median.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Median effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWCV.")
		)
		(run "spatch -oram:Maximum.effect -pram:max.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 6268 (getsize "ram:Maximum.effect"))
			(copyfiles (source "ram:Maximum.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Maximum effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWCV.")
		)
		(run "spatch -oram:Minimum.effect -pram:min.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 6256 (getsize "ram:Minimum.effect"))
			(copyfiles (source "ram:Minimum.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Minimum effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWCV.")
		)
		(run "spatch -oram:Solarize.effect -pram:sol.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 4640 (getsize "ram:Solarize.effect"))
			(copyfiles (source "ram:Solarize.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Solarize effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWCV.")
		)
		(run "spatch -oram:Threshold.effect -pram:thr.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 5044 (getsize "ram:Threshold.effect"))
			(copyfiles (source "ram:Threshold.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Threshold effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWCV.")
		)
		(run "spatch -oram:HSB.effect -pram:HSB.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 6464 (getsize "ram:HSB.effect"))
			(copyfiles (source "ram:HSB.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour HSB effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWHB.")
		)
		(run "spatch -oram:Gamma.effect -pram:gam.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 14372 (getsize "ram:Gamma.effect"))
			(copyfiles (source "ram:Gamma.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Gamma effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWHB.")
		)
		(run "spatch -oram:Convolve.effect -pram:conv.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 11240 (getsize "ram:Convolve.effect"))
			(copyfiles (source "ram:Convolve.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Convolve effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWCV.")
		)
		(run "spatch -oram:Histogram.effect -pram:hist.pch SoftLogik:Special/Keys/Gary.key")
		(if (= 5688 (getsize "ram:Histogram.effect"))
			(copyfiles (source "ram:Histogram.effect") (dest "SoftLogik:Effects"))
			(message "\n\nYour Histogram effect could not be patched to the latest version.\n\nPlease email support@softlogik.com for assistance. Report problem GEKEY2NEWHT.")
		)
	)
)
(delete "ram:Convolve.effect" (safe))
(delete "ram:Histogram.effect" (safe))
(delete "ram:HSB.effect" (safe))
(delete "ram:average.effect" (safe))
(delete "ram:median.effect" (safe))
(delete "ram:maximum.effect" (safe))
(delete "ram:minimum.effect" (safe))
(delete "ram:solarize.effect" (safe))
(delete "ram:threshold.effect" (safe))
(delete "ram:gamma.effect" (safe))
(delete "ram:Conv.pch" (safe))
(delete "ram:Hist.pch" (safe))
(delete "ram:HSB.pch" (safe))
(delete "ram:avg.pch" (safe))
(delete "ram:med.pch" (safe))
(delete "ram:max.pch" (safe))
(delete "ram:min.pch" (safe))
(delete "ram:sol.pch" (safe))
(delete "ram:thr.pch" (safe))
(delete "ram:gam.pch" (safe))


(message "\n\nPlease take the time to read the ReadMe.Now file before using this version. Many of the included scripts will not work in this beta due to a change in script commands. They will be updated for the final version. Sorry for the inconvenience.")

;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-Beta7.info" (safe))

(message "\n\nYou MUST update your font paths after starting this beta for the first time. Choose Fonts from the System Preferences submenu in the Project menu. Select each font path in the requester and click Update. When you are done, click Save.")

;DONE
(exit "Finished Installation")


;VERSION NUMBERS
;3.0h
;ttf.font                   36704 1.0
;wordworth.dfilter          33256 1.0

;3.0h2
;wordworth.dfilter          34760 1.0a
;jpeg.gfilter               81768 1.0
;textfx.extension           27368 1.0
;convolve.effect            10804 1.0
;histogram.effect            5152 1.0

;3.0i
;TTF.font                   37176 1.1
;wordworth.dfilter          34732 1.0b
;jpeg.gfilter               81916 1.0a
;textfx.extension           32456 1.0a American
;textfx_d.extension         32468 1.0a Deutch
;convolve.effect            11108 1.0a
;histogram.effect            5444 1.0a
;hsb.effect                  6020 1.0

;3.1b5 (3.1pr)
;ttf_db.font               121480 1.2 debug
;ttf.font                   37284 1.2
;wordworth.dfilter          35252 1.0c beta 3
;JPEG_d.gfilter             95272 1.0b Deutch
;jpeg_e.gfilter             95272 1.0b American Old
;JPEG.gfilter               95360 1.0b American New
;textfx.extension           32880 1.0b beta 3
;textfx.extension           47144 2.0
;convolve.effect            11268 1.0b
;histogram.effect            5624 1.0b
;hsb.effect                  6432 1.0a

;3.2b6
;wordworth.dfilter          35400 1.0c beta 6
;JPEG.gfilter               95332 1.0c beta 2
;textfx.extension           39508 1.0c
;textfx.extension           39552 2.0a
;average.effect              5740 1.0a beta 2
;median.effect               6264 1.0a beta 2
;maximum.effect              6268 1.0a beta 2
;minimum.effect              6256 1.0a beta 2
;solarize.effect             4640 1.0a beta 2
;threshold.effect            5044 1.0a beta 2
;hsb.effect                  6464 1.0b beta 2
;gamma.effect               14372 1.0a beta 2
;histogram.effect            5688 1.0c beta 2
;convolve.effect            11240 1.0c beta 2

;3.2b7
;textfx.extension           46768 2.0b

