;** Disk Names
(set NumInstallDisks 4)
(set #RefLib1 "RefLibInstall-1")
(set #RefLib2 "RefLibInstall-2")
(set #RefLib3 "RefLibInstall-3")
(set #RefLib4 "RefLibInstall-4")

;** Floppy Disk Names Created
(set MaxNumFloppies 6)
(set #Floppy1 "Ww3Outlines-1")
(set #Floppy2 "Ww3Outlines-2")
(set #Floppy3 "Ww3Outlines-3")
(set #Floppy4 "Ww3Outlines-4")
(set #Floppy5 "Ww3Outlines-5")
(set #Floppy6 "Ww3Outlines-6")

;** Floppy disks to NOT format
(set #Ww3 "Wordworth3")
(set #WwSys "Ww3System")
(set #WwDict "Ww3Dict")
(set #WwThes "Ww3Thes")
(set #WwFiles "Ww3Files")


;** Heading Font Variables
(set #NumHeadFonts1 9)
(set #Font1Name "Futura Book II")
(set #Font1Path (cat #RefLib2 ":FuturaBookII.lzh"))
(set #Font1Size 63168)
(set #Font2Name "Futura Book Italic II")
(set #Font2Path (cat #RefLib2 ":FuturaBookItalicII.lzh"))
(set #Font2Size 64752)
(set #Font3Name "Futura Bold II")
(set #Font3Path (cat #RefLib2 ":FuturaBoldII.lzh"))
(set #Font3Size 62032)
(set #Font4Name "Futura Bold Italic II")
(set #Font4Path (cat #RefLib2 ":FuturaBoldItalicII.lzh"))
(set #Font4Size 63360)
(set #Font5Name "Gill Sans")
(set #Font5Path (cat #RefLib2 ":GillSans.lzh"))
(set #Font5Size 65728)
(set #Font6Name "ITC Avant Garde Book")
(set #Font6Path (cat #RefLib2 ":ITCAvantGardeBook.lzh"))
(set #Font6Size 60336)
(set #Font7Name "ITC Avant Garde Book Oblique")
(set #Font7Path (cat #RefLib2 ":ITCAvantGardeBookObl.lzh"))
(set #Font7Size 62176)
(set #Font8Name "ITC Avant Garde Bold")
(set #Font8Path (cat #RefLib2 ":ITCAvantGardeBold.lzh"))
(set #Font8Size 59984)
(set #Font9Name "ITC Avant Garde Bold Oblique")
(set #Font9Path (cat #RefLib2 ":ITCAvantGardeBoldObl.lzh"))
(set #Font9Size 61904)

(set #NumHeadFonts2 8)
(set #Font10Name "Univers Light Condensed")
(set #Font10Path (cat #RefLib2 ":UniversLightCond.lzh"))
(set #Font10Size 63568)
(set #Font11Name "Univers Light Condensed Italic")
(set #Font11Path (cat #RefLib2 ":UniversLightCondItal.lzh"))
(set #Font11Size 63552)
(set #Font12Name "Univers Medium Italic")
(set #Font12Path (cat #RefLib2 ":UniversMedItalic.lzh"))
(set #Font12Size 64784)
(set #Font13Name "Univers Medium Condensed Italic")
(set #Font13Path (cat #RefLib2 ":UniversMedCondItal.lzh"))
(set #Font13Size 65280)
(set #Font14Name "Univers Bold")
(set #Font14Path (cat #RefLib2 ":UniversBold.lzh"))
(set #Font14Size 63024)
(set #Font15Name "Univers Bold Italic")
(set #Font15Path (cat #RefLib2 ":UniversBoldItalic.lzh"))
(set #Font15Size 63856)
(set #Font16Name "Univers Bold Condensed")
(set #Font16Path (cat #RefLib2 ":UniversBoldCond.lzh"))
(set #Font16Size 62912)
(set #Font17Name "Univers Bold Condensed Italic")
(set #Font17Path (cat #RefLib2 ":UniversBoldCondItal.lzh"))
(set #Font17Size 63088)


;** Body Font Variables
(set #NumBodyFonts1 8)
(set #Font18Name "CG Goudy Old Style")
(set #Font18Path (cat #RefLib2 ":CGGoudyOldStyle.lzh"))
(set #Font18Size 101322)
(set #Font19Name "CG Goudy Old Style Italic")
(set #Font19Path (cat #RefLib2 ":CGGoudyOldStyleItalc.lzh"))
(set #Font19Size 101690)
(set #Font20Name "CG Goudy Bold")
(set #Font20Path (cat #RefLib3 ":CGGoudyBold.lzh"))
(set #Font20Size 101962)
(set #Font21Name "CG Goudy Extra Bold")
(set #Font21Path (cat #RefLib3 ":CGGoudyExtraBold.lzh"))
(set #Font21Size 104202)
(set #Font22Name "Clarendon")
(set #Font22Path (cat #RefLib3 ":Clarendon.lzh"))
(set #Font22Size 78762)
(set #Font23Name "Clarendon Condensed")
(set #Font23Path (cat #RefLib3 ":ClarendonCondensed.lzh"))
(set #Font23Size 85792)
(set #Font24Name "Clarendon Book")
(set #Font24Path (cat #RefLib3 ":ClarendonBook.lzh"))
(set #Font24Size 79082)
(set #Font25Name "Clarendon Book Condensed")
(set #Font25Path (cat #RefLib3 ":ClarendonBkCndnsd.lzh"))
(set #Font25Size 77418)

(set #NumBodyFonts2 8)
(set #Font26Name "Garamond Antiqua")
(set #Font26Path (cat #RefLib3 ":GaramondAntiqua.lzh"))
(set #Font26Size 101708)
(set #Font27Name "Garamond Kursiv")
(set #Font27Path (cat #RefLib3 ":GaramondKursiv.lzh"))
(set #Font27Size 96716)
(set #Font28Name "Garamond Halbfett")
(set #Font28Path (cat #RefLib3 ":GaramondHalbfett.lzh"))
(set #Font28Size 101436)
(set #Font29Name "Garamond Kursiv Halbfett")
(set #Font29Path (cat #RefLib3 ":GaramondKursivHlbft.lzh"))
(set #Font29Size 101068)
(set #Font30Name "Hiroshige Book")
(set #Font30Path (cat #RefLib3 ":HiroshigeBook.lzh"))
(set #Font30Size 96650)
(set #Font31Name "Hiroshige Book Italic")
(set #Font31Path (cat #RefLib3 ":HiroshigeBookItalic.lzh"))
(set #Font31Size 94362)
(set #Font32Name "Hiroshige Bold")
(set #Font32Path (cat #RefLib4 ":HiroshigeBold.lzh"))
(set #Font32Size 96394)
(set #Font33Name "Hiroshige Bold Italic")
(set #Font33Path (cat #RefLib4 ":HiroshigeBoldItalic.lzh"))
(set #Font33Size 94842)


;** Decorative Font Variables
(set #NumDecorFonts1 9)
(set #Font34Name "Agfa Nadianne Book")
(set #Font34Path (cat #RefLib4 ":AgfaNadianneBook.lzh"))
(set #Font34Size 89200)
(set #Font35Name "Agfa Nadianne Med")
(set #Font35Path (cat #RefLib4 ":AgfaNadianneMed.lzh"))
(set #Font35Size 86736)
(set #Font36Name "Agfa Nadianne Bold")
(set #Font36Path (cat #RefLib4 ":AgfaNadianneBold.lzh"))
(set #Font36Size 89216)
(set #Font37Name "Coronet")
(set #Font37Path (cat #RefLib4 ":Coronet.lzh"))
(set #Font37Size 97882)
(set #Font38Name "Delphian")
(set #Font38Path (cat #RefLib4 ":Delphian.lzh"))
(set #Font38Size 80522)
(set #Font39Name "Dom Casual")
(set #Font39Path (cat #RefLib4 ":DomCasual.lzh"))
(set #Font39Size 102324)
(set #Font40Name "Eccentric")
(set #Font40Path (cat #RefLib4 ":Eccentric.lzh"))
(set #Font40Size 57826)
(set #Font41Name "Lisbon Cursive")
(set #Font41Path (cat #RefLib4 ":LisbonCursive.lzh"))
(set #Font41Size 91010)
(set #Font42Name "Marigold")
(set #Font42Path (cat #RefLib4 ":Marigold.lzh"))
(set #Font42Size 104484)

(set #NumDecorFonts2 6)
(set #Font43Name "Microstyle")
(set #Font43Path (cat #RefLib4 ":Microstyle.lzh"))
(set #Font43Size 68560)
(set #Font44Name "Microstyle Extended")
(set #Font44Path (cat #RefLib4 ":MicrostyleExt.lzh"))
(set #Font44Size 66832)
(set #Font45Name "Peignot Demi Bold")
(set #Font45Path (cat #RefLib4 ":PeignotDemiBold.lzh"))
(set #Font45Size 58242)
(set #Font46Name "Peignot Bold")
(set #Font46Path (cat #RefLib1 ":PeignotBold.lzh"))
(set #Font46Size 58242)
(set #Font47Name "Oxford")
(set #Font47Path (cat #RefLib1 ":Oxford.lzh"))
(set #Font47Size 108618)
(set #Font48Name "University Roman")
(set #Font48Path (cat #RefLib1 ":UniversityRoman.lzh"))
(set #Font48Size 74716)


;** Symbol Font Variables
(set #NumSymbolFonts 2)
(set #Font49Name "Communication 6")
(set #Font49Path (cat #RefLib1 ":Communication6.lzh"))
(set #Font49Size 85792)
(set #Font50Name "Games And Sports 3")
(set #Font50Path (cat #RefLib1 ":GamesSports3.lzh"))
(set #Font50Size 59024)



;** General Vars
(set #SpaceNeeded 0)
(set #SizeHead1 563440)		;full install sizes
(set #SizeHead2 510064)
(set #SizeBody1 730230)
(set #SizeBody2 783176)
(set #SizeDecor1 799200)
(set #SizeDecor2 435210)
(set #SizeSymbol 144816)
(set #HeadChoice1 511)	;proper vars
(set #HeadChoice2 255)
(set #BodyChoice1 255)
(set #BodyChoice2 255)
(set #DecorChoice1 511)
(set #DecorChoice2 63)
(set #SymbolChoice 3)

(set #DestPath "Work:")
(set #FloppySpace 800000)	; bytes free on blank disk
(set #OldChoice 0)
(set #DisplayNeeded 0)
(set #DisplayAvail 0)
(set #AvailChar "bytes")
(set #FloppyNumber 0)
(set DiskNum 0)

(set #RamTemp "RAM:RefFonts")
(set #RamTools "RAM:RefTools")


;############# STRINGS
;** Font Type Strings
(set #FontType1 "Heading Fonts (Sans Serif)")
(set #FontType2 "  -More Heading Fonts")
(set #FontType3 "Body Text Fonts (Serif)")
(set #FontType4 "  -More Body Text Fonts")
(set #FontType5 "Decorative Fonts")
(set #FontType6 "  -More Decorative Fonts")
(set #FontType7 "Symbol Fonts")
(set #FontType8 "## Install Chosen Fonts ##")

;** Other Strings
(set #NotBootWwMsg
	(cat "\n\nYou must turn on your machine with the \"Wordworth3\" disk in the "
		"internal drive prior to running this installation.\n\nClick \"Proceed\" to "
		"Exit.")
)

(set #WwNotInstalledMsg
	(cat "\n\nWordworth 3 does not seem to be installed on your system.\n\nClick "
		"\"Proceed\" to Exit.")
)

(set #WwNotInstalledHelp
	(cat "\n    The installer could not find Wordworth installed on your system. "
		"You must install Wordworth 3 first, before running this installation, "
		"in order to use the fonts.")
)

(set #TypeStartPrompt
	(cat "Please choose which type of fonts to select from.\n\nFonts selected=")
)
(set #TypeFloppyEndPrompt "   Disks Needed=")
(set #TypeFloppyApproxPrompt "(approx.)")
(set #TypeHardEndPrompt "   Space Available=")
(set #Kilobyte "Kb")
(set #Megabyte "Mb")
(set #Bytes "bytes")
(set #TypeHelp
	(cat "\n    Choose the group of fonts you wish to view and click \"Proceed\" to "
		"view them. Each group has a maximum of 9 fonts that can be selected or "
		"deselected individually.\n    The amount of disk space needed for all of "
		"the selected fonts, and the number of disks, or available hard disk space, is "
		"displayed at the top of the requester.\n\n" @askchoice-help)
)

(set #InstallPlacePrompt "\n\nWhere do you want to install your fonts ?")
(set #InstallPlaceChoice1 "On Hard Disk")
(set #InstallPlaceChoice2 "On Floppy Disks")
(set #InstallPlaceHelp
	(cat "\n    Choose from the two options, where you would like your "
		"selected fonts installed.\n    If you wish to install \""
		#InstallPlaceChoice2 "\", then you will need to have six blank disks "
		"ready for the installer to format and install onto.\n    If you wish "
		"to install \"" #InstallPlaceChoice1 "\", then you will be able to "
		"either install the fonts into the default drawer for use with "
		"Wordworth3, or choose exactly where they are installed.\n\n" @askchoice-help)
)

(set #ChooseFontsPrompt
	(cat "Please select each of the fonts you wish to install.")
)
(set #ChooseFontsHelp
	(cat "\n    Select each of the fonts you wish to install and click \"Proceed\" to "
		"return to the main 'Font Types' screen. You will notice that the disk space "
		"needed for your selection of fonts has been worked out automatically and is "
		"displayed in the top of the requester.\n\n" @askoptions-help)
)

(set #NoDiskSpaceMsg
	(cat "\n\nSorry, there is not enough disk space for your choice of fonts."
		"\n\nPlease choose again from the various groups, keeping watch on the "
		"'Space Needed' and 'Space Available' displays at the top of the requester.")
)

(set #CopyRamWorkingMsg1
	(cat "\nPlease wait... The installer is unarchiving the font:\n\"")
)
(set #CopyRamWorkingMsg2
	(cat 	"\"\n\nto the destination:\n\"")
)

(set #InsertDiskPrompt "\n\nPlease insert your disk labelled\n\n\"")
(set #InsertDiskHelp
	(cat "\n    You must insert the disk requested into any drive before the "
		"installer will continue.\n    If you already have the requested disk in a "
		"drive, it may be incorrectly named. Ensure that 'copy of ' does not preceed "
		"the disk name on the Workbench screen, and that there are no spaces before, "
		"in or after the name.\n\n" @askdisk-help)
)

(set #FormatWorkingMsg
	(cat "\n\nPlease wait...\n\nThe installer is formatting your disk.")
)

(set #FontDestPrompt1 "\n\nThe fonts will be installed to the  ")
(set #FontDestPrompt2 
	(cat " destination.\n\nIs this okay, or would you like to choose a different "
		"destination ?")
)
(set #FontDestChoice1 "Install Them Now")
(set #FontDestChoice2 "Choose New Destination")
(set #FontDestHelp
	(cat "\n    By default, the installer will install the fonts in the "
		"WwFonts/Intellifont drawer located in your Wordworth3 drawer on your "
		"hard disk.\n    If you wish to choose an alternative destination, like "
		"your Scala drawer or the system '_bullet_outlines' drawer, click \""
		#FontDestChoice2 "\" and select the new destination from the drawer "
		"requester.")
)

(set #ChooseDestPrompt "\nPlease choose the fonts destination drawer.")
(set #ChooseDestHelp
	(cat "\n    From the file requester, either choose the destination disk or "
		"drawer from the scrolling list gadget, or type the destination into the text "
		"gadget beneath.\n    Once confirmed, the fonts will be copied to the "
		"chosen destination and installed for use with Wordworth 3.\n\n" @askdir-help)
)
	
(set #FloppyBackupsMsg
	(cat "\nIMPORTANT\n\nDo not use your original disks for this installation "
		"and write-protect all install disks before proceeding.")
)

(set #BlankDiskWarningMsg
	(cat "\n\n\nPlease insert a 'blank' disk in the internal disk drive and "
		"click \"Proceed\" when ready.\n\nWARNING: This procedure will destroy all "
		"information that may already be on the disk.")
)
(set #BlankDiskWarningHelp
	(cat 	"\n    This procedure uses the Workbench 'format' command to wipe "
		"and prepare the disk in the internal disk drive for copying the "
		"fonts onto.\n    Write-protect your install disks before clicking "
		"the \"Proceed\" button, to avoid accidentally damaging them.\n\n"
		@askdisk-help)
)

(set #NotBlankMsg1 "\nYou have the \"")
(set #NotBlankMsg2
	(cat "\" disk in your internal disk drive.\n\nPlease replace this disk with "
		"a blank one, before clicking the \"Proceed\" button.")
)

(set #FormatCompleteMsg1
	(cat "\nFormatting Complete.\n\nPlease take out the disk in the internal disk "
		"drive and label it \"")
)
(set #FormatCompleteMsg2
	(cat "\".\n\nPlease place another blank disk in the internal disk drive and "
		"then click the \"Proceed\" button.")
)
(set #FormatCompleteMsgLast "\".\n\nClick the \"Proceed\" button to continue.")

(set #FormatError
	(cat 	"\nAn error occured when trying to format this disk.\n\nPlease ensure "
		"that a blank disk is in the disk drive and that it is not write-protected "
		"before you click the \"Proceed\" button. Alternatively, put another "
		"disk in the drive and try again.")
)
(set #FormatErrorHelp
	(cat "\n    An error has occured during the formatting of your disk. This "
		"could be for many reasons, but more commonly one of the following:\n"
		"      1. Either the disk was corrupt or the drive was faulty. Please try a "
		"different disk, check the drive and if the problem persists, contact the "
		"Technical Support Department. Information on how to get support is "
		"explained in the Wordworth Instruction Book.\n      2. A blank disk "
		"was not in the drive or it was write-protected. Put a write-enabled "
		"blank disk in a drive and click \"Proceed\".")
)

(set #OutlinesWorkingMsg1 "Installing chosen fonts on \"")
(set #OutlinesWorkingMsg2 "\" for use with Wordworth 3.")

(set #SwapDisksMsg
	(cat "\n\nTo avoid excessive disk swaps, you should swap the \"" #Ww3
		"\" disk and the \"" #RefLib1 "\" disk in one disk drive and swap "
		"the created outline font disks in the other drive when requested.")
)





;############# PROCEDURE DECLARATIONS

;** Procedure to find the font destination
(procedure @ChooseDest
	(
		(if (<> (expandpath "SYS:") "Wordworth:")
			(
				(if (exists "ENV:Wordworth/WwFonts")
					(
						(set #UFSTPath (getenv "Wordworth/WwFonts"))
						(if (= #OnFloppy 0)
							(set #DestPath (tackon (getenv "Wordworth/WwFonts") "Intellifont"))
						)
					)
					( ;else
						(message #WwNotInstalledMsg (help #WwNotInstalledHelp))
						(exit)
					)
				)
			)
			(
				(message #NotBootWwMsg)
				(exit)
			)
		)
	)
)



;** Procedure for user to select which type of fonts to view
(procedure @ChooseType
	(
		(set #SpaceNeeded (+ #SizeHead1 (+ #SizeBody1 (+ #SizeDecor1 #SizeSymbol))))
		(set #SpaceNeeded (+ #SpaceNeeded (+ #SizeHead2 (+ #SizeBody2 #SizeDecor2))))

		(set #DisplayNeeded (/ #SpaceNeeded 1024))
		(set #DisplayAvail (/ (/ #AvailSpace 1024) 1024))
		(set #AvailChar #Megabyte)

		(if (< #AvailSpace 1048576)
			(
				(set #DisplayAvail (/ #AvailSpace 1024))
				(set #AvailChar #Kilobyte)
			)
		)
		(if (< #AvailSpace 1024)
			(
				(set #DisplayAvail (/ (/ #AvailSpace 1024) 1024))
				(set #AvailChar #Bytes)
			)
		)		
			
		(if (= #OnFloppy 1)
			(
				(set #FloppyNumber (/ #SpaceNeeded #FloppySpace))
				(if (> #SpaceNeeded 0)
					(set #FloppyNumber (+ #FloppyNumber 1))
				)
				(set #TypePrompt (cat #TypeStartPrompt #DisplayNeeded #Kilobyte
					#TypeFloppyEndPrompt #FloppyNumber #TypeFloppyApproxPrompt))
			)
			(set #TypePrompt (cat #TypeStartPrompt #DisplayNeeded #Kilobyte
					 #TypeHardEndPrompt #DisplayAvail #AvailChar))
		)
		
		(set #TypeChoice
			(askchoice
				(prompt #TypePrompt)
				(choices #FontType1 #FontType2 #FontType3 #FontType4
								 #FontType5 #FontType6 #FontType7 #FontType8)
				(help #TypeHelp)
				(default #OldChoice)
			)
		)
		(set #OldChoice #TypeChoice)
	)
)



;** Procedure to select choice of heading fonts
(procedure @ChooseHeading
	(
		(set #SizeHead1 0)
		(set #Choice
			(askoptions
				(prompt #ChooseFontsPrompt)
				(choices #Font1Name #Font2Name #Font3Name #Font4Name #Font5Name
					#Font6Name #Font7Name #Font8Name #Font9Name)
				(help #ChooseFontsHelp)
				(default #HeadChoice1)
			)
		)
		(set Loop 0)
		(while (< Loop #NumHeadFonts1)
			(
				(set #FindSize 0)
				(if (> (IN #Choice Loop) 0)
					(set #FindSize
						(select Loop
							#Font1Size
							#Font2Size
							#Font3Size
							#Font4Size
							#Font5Size
							#Font6Size
							#Font7Size
							#Font8Size
							#Font9Size
						)
					)
				)
				(set Loop (+ Loop 1))
				(set #SizeHead1 (+ #SizeHead1 #FindSize))
			)
		)
		(set #HeadChoice1 #Choice)
	)
)



;** Procedure to select choice of heading fonts
(procedure @ChooseHeading2
	(
		(set #SizeHead2 0)
		(set #Choice
			(askoptions
				(prompt #ChooseFontsPrompt)
				(choices #Font10Name #Font11Name #Font12Name #Font13Name
					#Font14Name #Font15Name #Font16Name #Font17Name)
				(help #ChooseFontsHelp)
				(default #HeadChoice2)
			)
		)
		(set Loop 0)
		(while (< Loop #NumHeadFonts2)
			(
				(set #FindSize 0)
				(if (> (IN #Choice Loop) 0)
					(set #FindSize
						(select Loop
							#Font10Size 
							#Font11Size 
							#Font12Size 
							#Font13Size 
							#Font14Size 
							#Font15Size 
							#Font16Size 
							#Font17Size 
						)
					)
				)
				(set Loop (+ Loop 1))
				(set #SizeHead2 (+ #SizeHead2 #FindSize))
			)
		)
		(set #HeadChoice2 #Choice)
	)
)



;** Procedure to select chocie of body fonts
(procedure @ChooseBody
	(
		(set #SizeBody1 0)
		(set #Choice
			(askoptions
				(prompt #ChooseFontsPrompt)
				(choices #Font18Name #Font19Name #Font20Name #Font21Name
					#Font22Name #Font23Name #Font24Name #Font25Name)
				(help #ChooseFontsHelp)
				(default #BodyChoice1)
			)
		)
		(set Loop 0)
		(while (< Loop #NumBodyFonts1)
			(
				(set #FindSize 0)
				(if (> (IN #Choice Loop) 0)
					(set #FindSize
						(select Loop
							#Font18Size
							#Font19Size
							#Font20Size
							#Font21Size
							#Font22Size
							#Font23Size
							#Font24Size
							#Font25Size
						)
					)
				)
				(set Loop (+ Loop 1))
				(set #SizeBody1 (+ #SizeBody1 #FindSize))
			)
		)
		(set #BodyChoice1 #Choice)
	)
)



;** Procedure to select chocie of body fonts
(procedure @ChooseBody2
	(
		(set #SizeBody2 0)
		(set #Choice
			(askoptions
				(prompt #ChooseFontsPrompt)
				(choices #Font26Name #Font27Name #Font28Name #Font29Name
					#Font30Name #Font31Name #Font32Name #Font33Name)
				(help #ChooseFontsHelp)
				(default #BodyChoice2)
			)
		)
		(set Loop 0)
		(while (< Loop #NumBodyFonts2)
			(
				(set #FindSize 0)
				(if (> (IN #Choice Loop) 0)
					(set #FindSize
						(select Loop
							#Font26Size
							#Font27Size
							#Font28Size
							#Font29Size
							#Font30Size
							#Font31Size
							#Font32Size
							#Font33Size
						)
					)
				)
				(set Loop (+ Loop 1))
				(set #SizeBody2 (+ #SizeBody2 #FindSize))
			)
		)
		(set #BodyChoice2 #Choice)
	)
)



;** Procedure to select chocie of decorative fonts
(procedure @ChooseDecorative
	(
		(set #SizeDecor1 0)
		(set #Choice
			(askoptions
				(prompt #ChooseFontsPrompt)
				(choices #Font34Name #Font35Name #Font36Name #Font37Name
					#Font38Name #Font39Name #Font40Name #Font41Name #Font42Name)
				(help #ChooseFontsHelp)
				(default #DecorChoice1)
			)
		)
		(set Loop 0)
		(while (< Loop #NumDecorFonts1)
			(
				(set #FindSize 0)
				(if (> (IN #Choice Loop) 0)
					(set #FindSize
						(select Loop
							#Font34Size
							#Font35Size
							#Font36Size
							#Font37Size
							#Font38Size
							#Font39Size
							#Font40Size
							#Font41Size
							#Font42Size
						)
					)
				)
				(set Loop (+ Loop 1))
				(set #SizeDecor1 (+ #SizeDecor1 #FindSize))
			)
		)
		(set #DecorChoice1 #Choice)
	)
)



;** Procedure to select chocie of decorative fonts
(procedure @ChooseDecorative2
	(
		(set #SizeDecor2 0)
		(set #Choice
			(askoptions
				(prompt #ChooseFontsPrompt)
				(choices #Font43Name #Font44Name #Font45Name
					#Font46Name #Font47Name #Font48Name)
				(help #ChooseFontsHelp)
				(default #DecorChoice2)
			)
		)
		(set Loop 0)
		(while (< Loop #NumDecorFonts2)
			(
				(set #FindSize 0)
				(if (> (IN #Choice Loop) 0)
					(set #FindSize
						(select Loop
							#Font43Size
							#Font44Size
							#Font45Size
							#Font46Size
							#Font47Size
							#Font48Size
						)
					)
				)
				(set Loop (+ Loop 1))
				(set #SizeDecor2 (+ #SizeDecor2 #FindSize))
			)
		)
		(set #DecorChoice2 #Choice)
	)
)



;** Procedure to select chocie of symbol fonts
(procedure @ChooseSymbol
	(
		(set #SizeSymbol 0)
		(set #Choice
			(askoptions
				(prompt #ChooseFontsPrompt)
				(choices #Font49Name #Font50Name)
				(help #ChooseFontsHelp)
				(default #SymbolChoice)
			)
		)
		(set Loop 0)
		(while (< Loop #NumSymbolFonts)
			(
				(set #FindSize 0)
				(if (> (IN #Choice Loop) 0)
					(set #FindSize
						(select Loop
							#Font49Size
							#Font50Size
						)
					)
				)
				(set Loop (+ Loop 1))
				(set #SizeSymbol (+ #SizeSymbol #FindSize))
			)
		)
		(set #SymbolChoice #Choice)
	)
)



;** Procedure to allow user to choose the fonts to install
(procedure @ChooseFonts
	(
		(if (= #OnFloppy 0)
			(set #AvailSpace (getdiskspace #DestPath))
		)
		(set #InstallFonts 0)
		(until (= #InstallFonts 1)
			(
				(@ChooseType)
				(if (= #TypeChoice 0)
					(@ChooseHeading)
					(if (= #TypeChoice 1)
						(@ChooseHeading2)
						(if (= #TypeChoice 2)
							(@ChooseBody)
							(if (= #TypeChoice 3)
								(@ChooseBody2)
								(if (= #TypeChoice 4)
									(@ChooseDecorative)
									(if (= #TypeChoice 5)
										(@ChooseDecorative2)
										(if (= #TypeChoice 6)
											(@ChooseSymbol)
											(if (= #TypeChoice 7)
												(if (= #OnFloppy 0)
													(
														(if (<= #AvailSpace #SpaceNeeded)
															(
																(message #NoDiskSpaceMsg)
																(set #InstallFonts 0)
															)
															(set #InstallFonts 1)
														)
													)
													(set #InstallFonts 1)
												)
											)
										)
									)
								)
							)
						)
					)
				)
			)
		)
	)
)



;** Procedure to unpack font in #UnpackFontName to #DestPath
(procedure @UnpackFont
	(
		(set Length (strlen #DestPath))
		(set CheckDevice (substr #DestPath (- Length 1) 1))
		(if (<> CheckDevice ":")
			(set #InstallPath (cat #DestPath "/"))
			(set #InstallPath #DestPath)
		)
		(set RunLZ
			(cat "\"" #RamTools "/LZ\" e \"" #UnpackFontName "\" \"" #InstallPath "\"")
		)
		(run RunLZ)
	)
)


(procedure @ActualCopy
	(
		(set SizeLoop (- CopyLoop 1))
		(foreach #RamTemp "#?.lzh"
			(
				(set #UnpackFontName (tackon #RamTemp @each-name))
				(if (= #OnFloppy 1)
					(
						(set #FontSize
							(select SizeLoop
								#Font1Size
								#Font2Size
								#Font3Size
								#Font4Size
								#Font5Size
								#Font6Size
								#Font7Size
								#Font8Size
								#Font9Size
								#Font10Size
								#Font11Size
								#Font12Size
								#Font13Size
								#Font14Size
								#Font15Size
								#Font16Size
								#Font17Size
								#Font18Size
								#Font19Size
								#Font20Size
								#Font21Size
								#Font22Size
								#Font23Size
								#Font24Size
								#Font25Size
								#Font26Size
								#Font27Size
								#Font28Size
								#Font29Size
								#Font30Size
								#Font31Size
								#Font32Size
								#Font33Size
								#Font34Size
								#Font35Size
								#Font36Size
								#Font37Size
								#Font38Size
								#Font39Size
								#Font40Size
								#Font41Size
								#Font42Size
								#Font43Size
								#Font44Size
								#Font45Size
								#Font46Size
								#Font47Size
								#Font48Size
								#Font49Size
								#Font50Size
							)
						)
						(set #SpaceOK 0)
						(while (= #SpaceOK 0)
							(
								(if (= #OnFloppy 1)
									(askdisk
										(prompt #InsertDiskPrompt #DestPath "\"")
										(dest #DestPath)
										(help #InsertDiskHelp)
									)
								)
								
								(set #FloppySpaceLeft (getdiskspace (cat #DestPath ":")))
								(if (< #FloppySpaceLeft (+ #FontSize 10240)) ;* Add extra bit for safety
									(
										(set disknum (+ disknum 1))
										(set #SpaceOK 0)
									)
									(set #SpaceOK 1)	; else alright
								)
								(set #DestPath
									(select disknum
										#Floppy1
										#Floppy2
										#Floppy3
										#Floppy4
										#Floppy5
										#Floppy6
									)
								)
							)
						)
					)
				)
				(if (= #OnFloppy 1)
					(askdisk
						(prompt #InsertDiskPrompt #DestPath "\"")
						(dest #DestPath)
						(help #InsertDiskHelp)
					)
				)
				(set #OldDest #DestPath)
				(if (= #OnFloppy 1)
					(set #DestPath (cat #DestPath ":"))
				)
				(working #CopyRamWorkingMsg1 #UnpackFontName #CopyRamWorkingMsg2 #DestPath "\"")
				(@UnpackFont)
				(set #DestPath #OldDest)
			)
		)
		(set #DeleteFonts
			(cat #RamTools "/delete " (cat #RamTemp "/#?.lzh"))
		)
		(run #DeleteFonts)
	)
)


;** Procedure to copy chosen fonts to the #DestPath
(procedure @CopyFonts
	(
		(set CopyLoop StartNum)
		(while (< CopyLoop (+ #NumFonts StartNum))
			(
				(set #FontChoice "")
				(if (> (IN #CopyChoice (- CopyLoop StartNum)) 0)
					(
						(set #FontChoice
							(select CopyLoop
								#Font1Path	; #HeadChoice1
								#Font2Path
								#Font3Path
								#Font4Path
								#Font5Path
								#Font6Path
								#Font7Path
								#Font8Path
								#Font9Path
								#Font10Path	; #HeadChoice2
								#Font11Path
								#Font12Path
								#Font13Path
								#Font14Path
								#Font15Path
								#Font16Path
								#Font17Path
								#Font18Path	; #BodyChoice1
								#Font19Path
								#Font20Path
								#Font21Path
								#Font22Path
								#Font23Path
								#Font24Path
								#Font25Path
								#Font26Path	; #BodyChoice2
								#Font27Path
								#Font28Path
								#Font29Path
								#Font30Path
								#Font31Path
								#Font32Path
								#Font33Path
								#Font34Path	; #DecorChoice1
								#Font35Path
								#Font36Path
								#Font37Path
								#Font38Path
								#Font39Path
								#Font40Path
								#Font41Path
								#Font42Path
								#Font43Path	; #DecorChoice2
								#Font44Path
								#Font45Path
								#Font46Path
								#Font47Path
								#Font48Path
								#Font49Path	; #SymbolChoice
								#Font50Path
							)
						)
						(set Loop 0)
						(set #Char "")
						(until (= #Char ":")
							(
								(set #Char (substr #FontChoice Loop 1))
								(set Loop (+ Loop 1))
							)
						)
						(set #DiskName (substr #FontChoice 0 (- Loop 1)))
						(askdisk
							(prompt	#InsertDiskPrompt #DiskName "\"")
							(dest #DiskName)
							(help #InsertDiskHelp)
						)
						(copyfiles
							(source #FontChoice)
							(dest #RamTemp)
						)
					)
				)
				(set CopyLoop (+ CopyLoop 1))
			)
		)
		(@ActualCopy)
	)
)



;** Check that the disk in the internal drive is not #FormatDiskName
(procedure @CheckInternalDrive
	(
		(if (= (getassign "df0" "d") (cat #CheckDiskName ":"))
			(	;disk is blank
				(set DiskBlank 0)
			)
		)
	)
)



;** Proedure to make sure disk in drive is alright to format
(procedure @CheckDisks
	(
		;** Check to make sure that none of the Reference Library disks
		;** are in the internal drive before creating blank ones.
		(set NumberDisks (+ NumInstallDisks MaxNumFloppies))
		(set DiskBlank 1)
		(set n 0)
		(until (OR (= n NumberDisks) (= DiskBlank 0))
			(
				(set #CheckDiskName
					(select n
						#Ww3
						#WwSys
						#WwDict
						#WwThes
						#WwFiles
						#RefLib1
						#RefLib2
						#RefLib3
						#RefLib4
						#Floppy1
						#Floppy2
						#Floppy3
						#Floppy4
						#Floppy5
						#Floppy6
					)
				)
				(@CheckInternalDrive)
				(set n (+ n 1))
			)
		)
	)
)



;** Format and name the disk given in #FormatDiskName
(procedure @FormatDisks
	(
		(working #FormatWorkingMsg)

		(set #RunFormat
			(cat #RamTools "/Format drive=df0: " ("name=%s FFS NOICONS" #FormatDiskName))
		)
		(set NoError
			(run #RunFormat)
		)
	)
)





;############# MAIN ROUTINE

;** Copy necessary progs to RAM: for later
(if (NOT (exists #RamTools))
	(makedir #RamTools (safe))
)
(askdisk
	(prompt #InsertDiskPrompt #RefLib1 "\"")
	(dest #RefLib1)
	(help #InsertDiskHelp)
)
(copyfiles
	(source (cat #RefLib1 ":Tools"))
	(dest #RamTools)
	(pattern "#?")
	(nogauge)
)

;multi user libs to ram: because of arp.library for LZ
(set #AssignStr (tackon #RamTools ("assign LIBS: %s ADD" #RamTools)))
(run #AssignStr)

(set #DestOkay 0)

(set #InstallType
	(askchoice
		(prompt #InstallPlacePrompt)
		(choices #InstallPlaceChoice1 #InstallPlaceChoice2)
		(help #InstallPlaceHelp)
	)
)

(if (= #InstallType 0)
	(	;** On Hard Disk
		(set #OnFloppy 0)

		(@ChooseDest)
		(until (= #DestOkay 1)
			(
				(if (= @user-level 2)
					(
						(set #BoolChoice
							(askbool
								(prompt #FontDestPrompt1 "\"" #DestPath "\"" #FontDestPrompt2)
								(choices #FontDestChoice1 #FontDestChoice2)
								(help #FontDestHelp)
							)
						)
						(if (= #BoolChoice 0)
							(
								(set #DestOkay 0)
								(set #OldDest #DestPath)
								(set #DestPath
									(askdir
										(prompt #ChooseDestPrompt)
										(help #ChooseDestHelp)
										(default #OldDest)
									)
								)
							)
							(set #DestOkay 1)
						)
					)
				)
			)
		)
	)
	(	;** On Floppy Disk
		(set #OnFloppy 1)

		(@ChooseDest)
		(set #DestPath #Floppy1)
		
		(message #FloppyBackupsMsg)
	)
)

(@ChooseFonts)

(if (NOT (exists #RamTemp))
	(makedir #RamTemp (safe))
)

(if (= #OnFloppy 1)
	(
		(message #BlankDiskWarningMsg (help #BlankDiskWarningHelp))

		;** Check there is a blank disk in the drive, if so we will format it
		(set x 0)
		(while (< x #FloppyNumber)
			(
				;** Make sure that the install disks are not in the drive
				(run (cat #RamTools "/Wait 6"))  ;Wait a bit for disk access to stop
				(@CheckDisks)
				(if (= DiskBlank 0)
 					(message #NotBlankMsg1 #CheckDiskName #NotBlankMsg2)
      		(
						;** Else for each disk in turn, Format it
						(set #FormatDiskName
							(select x
								#Floppy1
								#Floppy2
								#Floppy3
								#Floppy4
								#Floppy5
          			#Floppy6
							)
						)
						(set NoError 1)
						
						(@FormatDisks)
	       		(if (= NoError 0)
  	     			(
								(set x (+ x 1))
								(if (< x #FloppyNumber)
									(message (cat #FormatCompleteMsg1 #FormatDiskName #FormatCompleteMsg2))
									(message (cat #FormatCompleteMsg1 #FormatDiskName #FormatCompleteMsgLast))
								)
							)
							(
								(message #FormatError (help #FormatErrorHelp))
							)
						);endif
					)
				);endif
			)
		)
	)
)

(set #CopyChoice #HeadChoice1)
(set StartNum 0)
(set #NumFonts #NumHeadFonts1)
(@CopyFonts)

(set #CopyChoice #HeadChoice2)
(set StartNum 9)
(set #NumFonts #NumHeadFonts2)
(@CopyFonts)

(set #CopyChoice #BodyChoice1)
(set StartNum 17)
(set #NumFonts #NumBodyFonts1)
(@CopyFonts)

(set #CopyChoice #BodyChoice2)
(set StartNum 25)
(set #NumFonts #NumBodyFonts2)
(@CopyFonts)

(set #CopyChoice #DecorChoice1)
(set StartNum 33)
(set #NumFonts #NumDecorFonts1)
(@CopyFonts)

(set #CopyChoice #DecorChoice2)
(set StartNum 42)
(set #NumFonts #NumDecorFonts2)
(@CopyFonts)

(set #CopyChoice #SymbolChoice)
(set StartNum 48)
(set #NumFonts #NumSymbolFonts)
(@CopyFonts)

(if (= #OnFloppy 0)
	(
		(set #RunInstallOutlines (cat "\"" (tackon #RamTools "InstallOutlines") "\" \"" #DestPath "\""))
		
		(working #OutlinesWorkingMsg1 #DestPath #OutlinesWorkingMsg2)
		(run #RunInstallOutlines)
		(set @default-dest #DestPath)
	)
	(	;** on floppy
		(set Loop 0)
		(message #SwapDisksMsg)
		(while (<> Loop (+ disknum 1))
			(
				(set #InstallFontDisk
					(select Loop
						#Floppy1
						#Floppy2
						#Floppy3
						#Floppy4
						#Floppy5
						#Floppy6
					)
				)

				(set #RunInstallOutlines (cat "\"" (tackon #RamTools "InstallOutlines") "\" \"" #InstallFontDisk ":\""))

				(askdisk
					(prompt	#InsertDiskPrompt #InstallFontDisk "\" ")
					(dest #InstallFontDisk)
					(help #InsertDiskHelp)
				)
				(working #OutlinesWorkingMsg1 #InstallFontDisk #OutlinesWorkingMsg2)
				(run #RunInstallOutlines)
				(set Loop (+ Loop 1))
			)
		)
		(set @default-dest "")
	)
)

(complete 100)
;** Clean up
(copyfiles
	(source #RamTools)
	(dest "RAM:")
	(pattern "delete")
	(nogauge)
)
(run ("RAM:delete %s all" #RamTemp))
(run ("RAM:delete %s all" #RamTools))
(delete "RAM:delete")
