;PAGESTREAM 3.3 TO 3.3a PATCH INSTALLATION SCRIPT
;COPYRIGHT ©1997 SOFTLOGIK PUBLISHING CORPORATION

;QUIT PROGRAMS
(message "\n\nStop now if you haven't read the Read.1st! file for important instructions.\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 mini-update will patch your PageStream 3.3 hard drive installation to 3.3a.\n\nYour original PageStream3 disks will not be modified by this update.\n\nYou MUST have 3.3 installed to use this miniupdater."))
(if (<> (exists "PageStream3:PageStream3") 1)
	(abort "PageStream3 is not in the PageStream3: directory. You must properly install PageStream3.3 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.3 before applying this update patch.")
)
(set PGSsize (getsize "PageStream3:PageStream3"))
(if (<> PGSsize 1569600)
	(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 LIBS
(working "Installing Updated Libraries...")
(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Libs x Libs.lha")
(delete "Libs.LHA" (safe))

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

;UPDATE FILTERS AND EFFECTS AND SPECIAL
(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))
(if (= (exists "SoftLogik:Filters/PICT.gfilter") 1) (delete "SoftLogik:Filters/PICT.gfilter" (safe)))
(if (= (exists "SoftLogik:Effects/Tiles.effect") 1) (delete "SoftLogik:Effects/Tiles.effect" (safe)))
;(run "ram:lhex >NIL: <NIL: -qfw=SoftLogik:Special x Special.lha")
;(delete "Special.LHA" (safe))

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

;UPDATE HELP
(working "Installing Updated HTML Help Files...")
;(run "delete PageStream3:Help/#? all")
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3:Help x Help.lha")
(delete "Help.LHA" (safe))

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

;PATCH EXTRAS TO LATEST VERSION IF APPLICABLE

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

;TRUETYPE FONT ENGINE
;(if (= (exists "SoftLogik:Engines/TTF.font") 1)
;	(
;		; 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))

;WORDWORTH DOC FILTER
(if (= (exists "SoftLogik:Filters/Wordworth.dfilter") 1)
	(
		; 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 (= 35388 (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))
;			)
;		)
		(if (<> (exists "SoftLogik:Special/Keys/WWdoc.key") 1)
			(
				(delete "SoftLogik:Filters/Wordworth.dfilter" (safe))
			)
		)
	)
)
;(delete "ram:WW.pch" (safe))

;TEXT FX EXTENSION

;GET RID OF TEXTFX1 KEY IF V2 EXISTS
;(if (AND (= (exists "SoftLogik:Special/Keys/TextFX1.key") 1) (= (exists "SoftLogik:Special/Keys/TextFX2.key") 1))
;	(delete "SoftLogik:Special/Keys/TextFX1.key" (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 TextFX2 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))

;JPEG FILTER
;(if (= (exists "SoftLogik:Filters/JPEG.gfilter") 1)
;	(
;		; 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 (= 95320 (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))

;GARY'S EFFECTS
;(if (= (exists "SoftLogik:Effects/HSB.effect") 1)
;	(
;		; PATCH GARY.KEY TO LATEST VERSION
;		(if (= (exists "SoftLogik:Special/Keys/Gary.key") 1)
;			(
;				(run "spatch -oram:Convolve.effect -pram:convolve.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 11228 (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:histogram.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 5676 (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.")
;				)
;				(run "spatch -oram:HSB.effect -pram:HSB.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 6452 (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:Average.effect -pram:Average.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 5728 (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 GEKEY2NEWHB.")
;				)
;				(run "spatch -oram:Gamma.effect -pram:Gamma.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 14360 (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:Maximum.effect -pram:Maximum.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 6256 (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 GEKEY2NEWHB.")
;				)
;				(run "spatch -oram:Minimum.effect -pram:Minimum.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 6244 (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 GEKEY2NEWHB.")
;				)
;				(run "spatch -oram:Median.effect -pram:Median.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 6252 (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 GEKEY2NEWHB.")
;				)
;				(run "spatch -oram:Solarize.effect -pram:Solarize.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 4628 (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 GEKEY2NEWHB.")
;				)
;				(run "spatch -oram:Threshold.effect -pram:Threshold.pch SoftLogik:Special/Keys/Gary.key")
;				(if (= 5032 (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 GEKEY2NEWHB.")
;				)
;			)
;		)
;		(delete "ram:Convolve.effect" (safe))
;		(delete "ram:Histogram.effect" (safe))
;		(delete "ram:HSB.effect" (safe))
;		(delete "ram:Average.effect" (safe))
;		(delete "ram:Gamma.effect" (safe))
;		(delete "ram:Maximum.effect" (safe))
;		(delete "ram:Minimum.effect" (safe))
;		(delete "ram:Median.effect" (safe))
;		(delete "ram:Solarize.effect" (safe))
;		(delete "ram:Threshold.effect" (safe))
;	)
;)
;(delete "ram:Convolve.pch" (safe))
;(delete "ram:Histogram.pch" (safe))
;(delete "ram:HSB.pch" (safe))
;(delete "ram:Average.pch" (safe))
;(delete "ram:Gamma.pch" (safe))
;(delete "ram:Maximum.pch" (safe))
;(delete "ram:Minimum.pch" (safe))
;(delete "ram:Median.pch" (safe))
;(delete "ram:Solarize.pch" (safe))
;(delete "ram:Threshold.pch" (safe))

;(delete "Patch.LHA" (safe))

;UPDATE HHV
(working "Installing HTML Help Viewer...")
(run "ram:lhex >NIL: <NIL: -qfw=PageStream3: x hhv.lha")
(delete "ram:hhv.lha" (safe))

;UPDATE BME
(if (exists "PageStream3:BME")
	(
		(working "Patching BME to new version...")
		(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 new version...\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 PageStream 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 LHEX/SPATCH AND .info FILE
(delete "ram:lhex" (safe))
(delete "spatch" (safe))

(delete "Install-3.3a.info" (safe))

;DONE
(exit "Finished patching PageStream to version 3.3a.")
