;***************************************************************************************************
;***************************************************************************************************
;***
;***	hyperIO installation script
;***	===========================
;***
;***	$VER: 1.0 (23.12.98)
;***
;***	©1998 by Carsten 'michelangelo' Scholling
;***
;***
;***
;***	No changes outside of strings- and main-part!
;***
;***
;***************************************************************************************************
;***************************************************************************************************


;***************************************************************************************************
;***	Debugging stuff
;***************************************************************************************************


;***************************************************************************************************
;***	Error handling stuff
;***************************************************************************************************
(onerror (P_Cleanup))


;***************************************************************************************************
;***	Configuration defaults
;***************************************************************************************************
(set #prgname		"hyperIO")					;*** Simply the program name.
(set #dirname		"hyperIO")					;*** Directory name to be created at first install.

(set #devspat		"hyper#?.device")			;*** Devs hyperCOM/PAR file pattern
(set #libspat		"vmc#?.library")			;*** Libs VMC file pattern
(set #devsisdnpat	"vmcisdn#?.device")			;*** If this is found, some components should not be deleted!

(set #destdevs		"Devs:")					;*** Default device installation path. Primary needed for update check.
(set #destlibs		"Libs:")					;*** Default libs installation path. Primary needed for update check.
(set #destdocs		"Sys:Utilities")			;*** Default documentation installation path.
(set #destdocsdir	"hyperIO")					;*** Default utils directory.
(set #destutil		"Sys:Utilities")			;*** Default utils installation path.
(set #destutildir	"hyperIO")					;*** Default utils directory.
(set #destback		"SYS:Storage")				;*** Default backup path.
(set #destbackdir	"hyperIO_backup")			;*** Default backup directory.

(set #minosver		36)							;*** Minimum OS version
(set #mincpu		0)							;*** Minimum CPU.

(set #instchoice	0)							;*** Global installation choice (new, back, update, deinstall, end)
(set #instparts		15)							;*** Bit mask of parts to install (0 = devs, 1 = libs, 2 = docs, 3 = utils)
(set #instcards		127)						;*** Bit mask of cards to install drivers for (0 = hc1, 1 = hc3, 2 = hc3z, 3 = hc4, 4 = hc3ihc4, 5 = hc3ihc3z, 6 = hp)
(set #instutil		63)							;*** Bit mask of utilities to install (0 = ncomm, 1 = ncomm-pk, 2 = hydra, 3 = porth. 4 = prtman, 5 = auxh.)

(set #vmchc1		"hyperCOM1.device")			;***
(set #vmchc3		"hyperCOM3.device")			;***
(set #vmchc4		"hyperCOM4?.device")		;***
(set #vmchc3z		"hyperCOM3?Z.device")		;***
(set #vmchp			"hyperPAR.device")			;***
(set #vmcrsc		"vmcresource.library")		;***

(set #utilncomm		"ncomm306")					;***
(set #utilncommpk	"NComm306PubKey")			;***
(set #utilhydra		"hydra")					;***
(set #utilporth		"porthandler")				;***
(set #utilprtman	"prtman39")					;***
(set #utilauxh		"auxhandler")				;***


;***************************************************************************************************
;***	Strings
;***************************************************************************************************

;***
;*** German strings
;***
(if (= @language "deutsch") (

	(set #wronginstaller	(cat    "Achtung! Es ist eine alte Version des Programmes 'Installer' auf "
									"Ihrem Amiga!\n\nDie Installation benötigt mindestens Installer "
									"43.3.\n\nBitte überprüfen Sie Ihre Konfiguration!"))

	(set #msgmakedir				"Folgendes Verzeichnis wird nun erstellt: ")

	(set #msgdelete					"\nFolgende Datei wird jetzt gelöscht:\n\n")

	(set #msgcopy					"\nFolgende Datei wird jetzt kopiert:\n\n")

	(set #msgcopyover1		(cat	"\nEs wurde in der Quelldatei keine Versionsangabe gefunden.\nSoll diese Datei kopiert werden?\n\n"
									"Zu installierende Datei: "))
	(set #msgcopyover2				"\nBisher installierte Datei: ")
	(set #msgcopyovernofile			"Bisher ist keine Datei installiert.")

	(set #msgwelcome1		(cat	"\nWillkommen zur \n\n" #prgname))
	(set #msgwelcome2				" Installation.\n\n")

	(set #msgcopyright		(cat	"Copyright ©1992-1998 by VMC Harald Frank\n"
									"<vmc@vmc.de>\n"
									"http://www.vmc.de\n\n"
									"Installer script ©1998 by Carsten 'michelangelo' Scholling\n"
									"<cscholling@vmc.de>\n"))

	(set #msgoldinst		(cat	"Ich habe eine alte " #prgname " Installation auf Ihrem System gefunden.\n"
									"Bitte wählen Sie, wie die Installation fortgesetzt werden soll.\n"))

	(set #msgoldfilesexp	(cat	"\n\n\nEs werden nun einige alte Dateien aus dem System entfernt.\n"
									"Sie können im folgenden das Löschen jeder Datei einzeln bestätigen.\n"))

	(set #msgoldfilesave			"\n\n\nEs werden nun einige alte Dateien aus dem System entfernt.\n")

	(set #msgoldfiles2				"Bitte deselektieren Sie die Dateien/Verzeichnisse\ndie nicht gelöscht werden sollen:\n")

	(set #msgoldinstupdate			"Update der alten Version")
	(set #msgoldinstnew				"Komplette Neuinstallation")
	(set #msgoldinstback			"Backup anlegen, anschließend neu installieren")
	(set #msgoldinstdeinst			"Alte Version deinstallieren")
	(set #msgoldinstend				"Programm beenden")

	(set #msgwhichparts		(cat	"\nWelche Komponenten sollen installiert werden?\nAlle nicht selektierten Komponenten werden,\n"
									"sofern vorhanden, automatisch deinstalliert!\n"))
	(set #msgwhichdevs				"Devices")
	(set #msgwhichlibs				"Libraries")
	(set #msgwhichdocs				"Dokumentation")
	(set #msgwhichutil				"Goodies")

	(set #msgworkingbackup			"\nErstelle ein Backup der alten Installation...\n")
	(set #msgworkingsearchold		"\nSuche nach bereits installierten Komponenten... ;-)\n")
	(set #msgworkingprepareinst		"\nBereite die Installation vor...\n")
	(set #msgworkingpreparedeinst	"\nBereite die Deinstallation vor...\n")
	(set #msgworkinginst			"\nArbeite an der Installation...\n")
	(set #msgworkingdeinst			"\nArbeite an der Deinstallation...\n")

	(set #msguptodate		(cat	"Die zu installierende " #prgname " Version ist auf dem neusten Stand.\n"
									"Bitte wählen Sie, ob Sie eine Neu- oder Deinstallation wünschen, oder\n"
									"ob der Installer beendet werden soll.\n"))

	(set #msgaskdevs		(cat	"In welchem Verzeichnis sollen die Device-Treiber installiert werden?\n"
									"Es wird KEIN Verzeichnis erstellt!\n"))
	(set #msgasklibs		(cat	"In welchem Verzeichnis sollen die Bibliotheken installiert werden?\n"
									"Es wird KEIN Verzeichnis erstellt!\n"))
	(set #msgaskdocs		(cat	"In welchem Verzeichnis soll die Dokumentation installiert werden?\n"
									"Es wird ein Verzeichnis " #destdocsdir " erstellt!\n"))
	(set #msgaskutil		(cat	"In welchem Verzeichnis sollen die Goodies installiert werden?\n"
									"Es wird ein Verzeichnis " #destutildir " erstellt!\n"))
	(set #msgaskback		(cat	"In welchem Verzeichnis soll das Backup angelegt werden?\n"
									"Es wird ein Verzeichnis " #destbackdir " erstellt!\n"))

	(set #msgconfirm		(cat	"\nDie folgenden Daten werden zur Installation herangezogen:\n"))
	(set #msgconfirmdeinst	(cat	"\nDie folgenden Daten werden zur Deinstallation herangezogen:\n"))
	(set #msgconfirmcpu				"\nProzessor: ")
	(set #msgconfirmfpu				"\nFPU: ")
	(set #msgconfirmos				"\nBetriebssystem: ")
	(set #msgconfirmdevsdest		"\nDevices: ")
	(set #msgconfirmlibsdest		"\nLibraries: ")
	(set #msgconfirmdocsdest		"\nDokumentation: ")
	(set #msgconfirmutildest		"\nGoodies: ")
	(set #msgconfirmbackdest		"\nBackup: ")
	(set #msgconfirmask				"\n\nSoll ich mit diesen Einstellungen fortfahren?\n")

	(set #msgdelrsclib		(cat	"\nAuf Ihrem System wurde eine VMC-ISDN Installation\n"
									"gefunden welche auch die " #vmcrsc " benötigt.\n"
									"Die installierte Version der " #vmcrsc "\n"
									"ist neuer als die zu installierende Version.\n"
									"Soll sie trotzdem gelöscht werden?\n"))

	(set #msgcardinst				"Bitte wählen Sie aus, welche Karten in\nIhrem System installiert sind.\n(Hilfe beachten!)")
	(set #msgvmchc1d				"hyperCOM1 Karte")
	(set #msgvmchc3d				"hyperCOM3 Karte")
	(set #msgvmchc3z				"hyperCOM3z/hyperCOM3plus Karte")
	(set #msgvmchc4d				"hyperCOM4/hyperCOM4plus Zorro Karte")
	(set #msgvmchc3ihc4d			"hyperCOM3i installiert auf hyperCOM4")
	(set #msgvmchc3ihc3zd			"hyperCOM3i installiert auf hyperCOM3z")
	(set #msgvmchpd					"hyperPAR.device für alle Karten")

	(set #msgcardinsthelp	(cat	"!!! NEU !!!\n\n"
									"Eine hyperCOM3i welche auf einer hyperCOM4 montiert ist wird über das "
									"hyperCOM4X.device auf Unit 4 und Unit 5 angesprochen.\n\n"
									"Eine hyperCOM3i welche auf einer hyperCOM3z montiert ist wird über das "
									"hyperCOM3Xz.device auf Unit 2 und Unit 3 angesprochen.\n\n"
									"Alle parallelen Schnittstellen auf den hyperCOM-Karten werden grundsätzlich "
									"über das hyperPAR.device angesteuert.\n\nDie LPT-Schnittstelle einer hyperCOM3 "
									"im A1200 liegt immer auf Unit 0.\n"))

	(set #msgutilinst				"Bitte wählen Sie aus, welche der Goodie-Archive Sie kopieren möchten")
	(set #msgutilncommd				"NComm V3.06 - Terminalprogramm")
	(set #msgutilncommpkd			"Freies Keyfile für NComm")
	(set #msgutilhydrad				"Hydra V1.0r9 - Bidirektionales Transferprotokoll")
	(set #msgutilporthd				"PortHandler V41 - Ersatz für original PortHandler")
	(set #msgutilprtmand			"PrintManager V39 - Drucker Spooler")
	(set #msgutilauxhd				"Aux-Handler V2 - Ermöglicht Remote-Login")

	(set #msgutilinsthelp	(cat	"Achtung!\n\n"
									"Die beigelegten Archive werden NICHT installiert sondern nur in das gewählte "
									"Zielverzeichnis kopiert. Mit anderen Worten: Selbst ist die Frau/der Mann. "))

	(set #msgendinst		(cat	"\n" #prgname " Installation beendet!\n\n"))
	(set #msgenddeinst		(cat	"\n" #prgname " Deinstallation beendet!\n\n"))
	(set #msgend2			(cat	"\n" #prgname " Programm durch Benutzer beendet!\n\n"))

	(set #msgshowreadme				"\nSoll jetzt die Datei LiesMichZuerst.guide angezeigt werden?\n")

	(set #msgreboot					"\nDer Rechner MUß nach dieser Installation neu gestartet\nwerden. Soll das jetzt geschehen?\n")
	(set #msgrebootyes				"Reboot")
	(set #msgrebootno				"KEIN Reboot")
)

;***
;*** English strings
;***
(
	(set #wronginstaller	(cat    "Attention! I found an old version og the programm 'Installer' on "
					"your Amiga!\n\nThe installation need at least Installer version "
					"43.3.\n\nPlease check your configuration!"))

	(set #msgmakedir		"The following dir will be created now: ")

	(set #msgdelete			"\nThe following file will be deletet now:\n\n")

	(set #msgcopy			"\nThe following file will be copied now:\n\n")

	(set #msgcopyover1	(cat	"\nI found no version info in the source file.\nShould i copy this file now?\n\n"
					"To installed file:     "))
	(set #msgcopyover2		"\nActual installed file: ")
	(set #msgcopyovernofile		"No file installed now.")

	(set #msgwelcome1	(cat	"\nWelcome to the\n\n" #prgname))
	(set #msgwelcome2		" Installation.\n\n")

	(set #msgcopyright	(cat	"Copyright ©1992-1998 by VMC Harald Frank\n"
					"<vmc@vmc.de>\n"
					"http://www.vmc.de\n\n"
					"Installer script ©1998 by Carsten 'michelangelo' Scholling\n"
					"<cscholling@vmc.de>\n"))

	(set #msgoldinst	(cat	"I found an old " #prgname " Installation on your system.\n"
					"Please choose, how to continue the installation.\n"))

	(set #msgoldfilesexp	(cat	"\n\n\nI delete now some old files from your system.\n"
					"You can confirm the action for each file and dir.\n"))

	(set #msgoldfilesave		"\n\n\nI delete now some old files from your system.\n")

	(set #msgoldfiles2		"Please deselect all files/dirs,\nthat should not to be deleted:\n")

	(set #msgoldinstupdate		"Update the old version")
	(set #msgoldinstnew		"Complete new installation")
	(set #msgoldinstback		"Backup and install all new")
	(set #msgoldinstdeinst		"Remove the installation")
	(set #msgoldinstend		"Abort the installation")

	(set #msgwhichparts	(cat	"\nWhich components should to be installed?\nAll NOT selected components will be,\n"
					"if installed, automatically deinstalled!\n"))
	(set #msgwhichdevs		"Devices")
	(set #msgwhichlibs		"Libraries")
	(set #msgwhichdocs		"Documentation")
	(set #msgwhichutil		"Goodies")

	(set #msgworkingbackup		"\nCreate backup of the old installation...\n")
	(set #msgworkingsearchold	"\nSearch actuall installed components... ;-)\n")
	(set #msgworkingprepareinst	"\nPrepare the installation...\n")
	(set #msgworkingpreparedeinst	"\nPrepare the deinstallation...\n")
	(set #msgworkinginst		"\nWork on the installation...\n")
	(set #msgworkingdeinst		"\nWork on the deinstallation...\n")

	(set #msguptodate	(cat	"The installed " #prgname " version is up to date.\n"
					"Please choose if you want an New- or Deinstallation, or\n"
					"if you want to quit the Installation.\n"))

	(set #msgaskdevs	(cat	"In which dir should i install the devices?\n"
					"No directory will be created!\n"))
	(set #msgasklibs	(cat	"In which dir should i install the librarys?\n"
					"No directory will be created!\n"))
	(set #msgaskdocs	(cat	"In which dir should i install the doc files?\n"
					"The " #destdocsdir " directory will be created!\n"))
	(set #msgaskutil	(cat	"In which dir should i copy the goodies?\n"
					"The " #destutildir " directory will be created!\n"))
	(set #msgaskback	(cat	"In which dir should i copy the backup files?\n"
					"The " #destbackdir " directory will be created!\n"))

	(set #msgconfirm	(cat	"\nThe follow information will be used by the installation:\n"))
	(set #msgconfirmdeinst	(cat	"\nThe follow information will be used by the deinstallation:\n"))
	(set #msgconfirmcpu		"\nCPU: ")
	(set #msgconfirmfpu		"\nFPU: ")
	(set #msgconfirmos		"\nOS-Type: ")
	(set #msgconfirmdevsdest	"\nDevices: ")
	(set #msgconfirmlibsdest	"\nLibraries: ")
	(set #msgconfirmdocsdest	"\nDocumentation: ")
	(set #msgconfirmutildest	"\nGoodies: ")
	(set #msgconfirmbackdest	"\nBackup: ")
	(set #msgconfirmask		"\n\nShould i use this settings?\n")

	(set #msgdelrsclib	(cat	"\nAuf Ihrem System wurde eine VMC-ISDN Installation\n"
					"gefunden welche auch die " #vmcrsc " benötigt.\n"
					"Die installierte Version der " #vmcrsc "\n"
					"ist neuer als die zu installierende Version.\n"
					"Schould i delete it?\n"))

	(set #msgcardinst		"Please choose the cards, that are installed in your Amiga.\n(See Help!)")
	(set #msgvmchc1d		"HyperCOM1/PortJnr card")
	(set #msgvmchc3d		"HyperCOM3/PortPlus card")
	(set #msgvmchc3z		"HyperCOM3z/hyperCOM3plus Zorro card")
	(set #msgvmchc4d		"HyperCOM4/hyperCOM4plus Zorro card")
	(set #msgvmchc3ihc4d		"HyperCOM3i plugin on hyperCOM4")
	(set #msgvmchc3ihc3zd		"HyperCOM3i plugin on hyperCOM3z")
	(set #msgvmchpd			"hyperPAR.device for all HyperCOM's")

	(set #msgcardinsthelp	(cat	"!!! NEW !!!\n\n"
					"Eine hyperCOM3i welche auf einer hyperCOM4 montiert ist wird über das "
					"hyperCOM4X.device auf Unit 4 und Unit 5 angesprochen.\n\n"
					"Eine hyperCOM3i welche auf einer hyperCOM3z montiert ist wird über das "
					"hyperCOM3Xz.device auf Unit 2 und Unit 3 angesprochen.\n\n"
					"Alle parallelen Schnittstellen auf den hyperCOM-Karten werden grundsätzlich "
					"über das hyperPAR.device angesteuert.\n\nDie LPT-Schnittstelle einer hyperCOM3 "
					"im A1200 liegt immer auf Unit 0.\n"))

	(set #msgutilinst		"Please choose which part of the goodies you want to copy")
	(set #msgutilncommd		"NComm V3.06 - Terminalsoftware")
	(set #msgutilncommpkd		"Free & Public Keyfile for NComm")
	(set #msgutilhydrad		"Hydra V1.0r9 - Bidirectional Transferprotokoll")
	(set #msgutilporthd		"PortHandler V41 - Replacement for the old one")
	(set #msgutilprtmand		"PrintManager V39 - Printer Spooler")
	(set #msgutilauxhd		"Aux-Handler V2 - Shell over serial Remote-Login")

	(set #msgutilinsthelp	(cat	"Attention!\n\n"
					"The included goodies will NOT be installed, there is only an copy done, "
					"to the selected destination dir. Goodie-Installation is -> do it yourself. "))

	(set #msgendinst	(cat	"\n" #prgname " Installation done!\n\n"))
	(set #msgenddeinst	(cat	"\n" #prgname " Deinstallation done!\n\n"))
	(set #msgend2		(cat	"\n" #prgname " Installation aborted by user!\n\n"))

	(set #msgshowreadme		"\nDo you want to read the ReadMeeFirst.guide now?\n")

	(set #msgreboot			"\nYou MUST reboot after this installation to use\nthe new drivers. Should i reboot now?\n")
	(set #msgrebootyes		"Reboot")
	(set #msgrebootno		"No Reboot")
))



;***************************************************************************************************
;***************************************************************************************************
;***
;***	!!! NO CHANGES BEHIND THIS LINE !!!
;***
;***************************************************************************************************
;***************************************************************************************************






;***************************************************************************************************
;***************************************************************************************************
;***
;***	Standard procedures
;***
;***************************************************************************************************
;***************************************************************************************************

;***************************************************************************************************
;***	Procedure CheckOS
;***************************************************************************************************
(procedure P_CheckOS
	(set os	(/ (getversion "libs:version.library") 65536))

	(if (= os 37)	(set osname "2.0"))
	(if (= os 38)	(set osname "2.1"))
	(if (= os 39)	(set osname "3.0"))
	(if (= os 40)	(set osname "3.1"))
	(if (= os 41)	(set osname "3.5"))
	(if (> os 41)	(set osname "3.5+ (not known)"))

	(if (>= os minosver)
		(set ret 1)
		(set ret 0)
	)
)


;***************************************************************************************************
;***	Procedure CheckCPU
;***************************************************************************************************
(procedure P_CheckCPU
	(set cpuname	(database "cpu"))
	(set fpuname	(database "fpu"))

	(if (= cpuname "68000")	(set cpu 0))
	(if (= cpuname "68010")	(set cpu 1))
	(if (= cpuname "68020")	(set cpu 2))
	(if (= cpuname "68030")	(set cpu 3))
	(if (= cpuname "68040")	((set cpu 4) (set fpuname "FPU040")))
	(if (> (exists ("sys:libs/68060.library")) 0) (
		(set cpuname "68060")
		(set cpu 6)
	))

	(if (= fpuname "NOFPU")		(set fpu 0))
	(if (= fpuname "68881")		(set fpu 1))
	(if (= fpuname "68882")		(set fpu 2))
	(if (= fpuname "FPU40")		(set fpu 4))
	(if (= fpuname "FPU040")	(set fpu 4))
	(if (> (exists ("sys:libs/68060.library")) 0) (
		(set fpuname "FPU060")
	))

	(if (>= cpu mincpu)
		(set ret 1)
		(set ret 0)
	)
)


;***************************************************************************************************
;***	Procedure GetVersion <file>
;***************************************************************************************************
(procedure P_GetVersion p_file
	(set ver	(shiftright (BITAND (getversion p_file) $ffff0000) 16))
)


;***************************************************************************************************
;***	Procedure GetRevision <file>
;***************************************************************************************************
(procedure P_GetRevision p_file
	(set rev	(BITAND (getversion p_file) $ffff))
)


;***************************************************************************************************
;***	Procedure GetFullVersion <file>
;***************************************************************************************************
(procedure P_GetFullVersion p_file
	(set vers	(cat (P_GetVersion p_file ) "." (P_GetRevision p_file )))
)


;***************************************************************************************************
;***	Procedure CheckExists <file>
;***************************************************************************************************
(procedure P_CheckExists p_file
	(set ret (exists p_file (noreq)))
)


;***************************************************************************************************
;***	Procedure CheckExistsPat <path> <pattern>
;***************************************************************************************************
(procedure P_CheckExistsPat p_path p_pat

	(set patexists 0)

	(if (P_CheckExists p_path) (

		(run (cat "list >t:csinstcheckpat.temp " p_path " pat " p_pat " lformat \"%n\""))

		(if (> (getsize "t:csinstcheckpat.temp") 0) (set patexists 1))

		(delete "t:csinstcheckpat.temp")
	))

	(set patexists patexists)
)


;***************************************************************************************************
;***	Procedure Rename <file> <newname>
;***************************************************************************************************
(procedure P_Rename p_file p_new p_conf
	(if (= 2 @user-level)
		(rename p_file p_new
			(confirm)
			(prompt (cat #msgrename1 p_file #msgrename2 p_new))
			(help (cat #msgrename1 p_file #msgrename2 p_new))
		)

		(rename p_file p_new)
	)
)


;***************************************************************************************************
;***	Procedure MakeDir <path> <name> <NOICONS>
;***************************************************************************************************
(procedure P_MakeDir p_path p_name p_noicons

	(if (OR (> (P_CheckExists p_path) 0) (= p_name "")) (

		(set full (tackon p_path p_name))

		(if (< (P_CheckExists full) 2) (

			(if (= 2 @user-level)
				(if (= p_noicons "noicons")
					(makedir full
						(prompt (cat #msgmakedir full))
						(help (cat #msgmakedir full "\n\n" @makedir-help))
						(confirm)
					)
					(makedir full
						(prompt (cat #msgmakedir full))
						(help (cat #msgmakedir full "\n\n" @makedir-help))
						(confirm)
						(infos)
					)
				)
				(if (= p_noicons "icons")
					(makedir full
						(prompt (cat #msgmakedir full))
						(help (cat #msgmakedir full "\n\n" @makedir-help))
					)
					(makedir full
						(prompt (cat #msgmakedir full))
						(help (cat #msgmakedir full "\n\n" @makedir-help))
						(infos)
					)
				)
			)
		))
	))
)


;***************************************************************************************************
;***	Procedure Delete <file> <NOICONS> <NOREQ>
;***************************************************************************************************
(procedure P_Delete p_file p_noicons p_noreq

	(if (= p_noreq "noreq") (

		(if (= p_noicons "noicons")
			(delete p_file
				(prompt (cat #msgdelete p_file))
				(help (cat #msgdelete p_file))
				(optional "force" "askuser")
				(all)
			)
			(delete p_file
				(prompt (cat #msgdelete p_file))
				(help (cat #msgdelete p_file))
				(optional "force" "askuser")
				(all)
			)
		)
	)
	(
		(if (= p_noicons "noicons")
			(delete p_file
				(prompt (cat #msgdelete p_file))
				(help (cat #msgdelete p_file))
				(optional "force" "askuser")
				(confirm)
				(all)
			)
			(delete p_file
				(prompt (cat #msgdelete p_file))
				(help (cat #msgdelete p_file))
				(optional "force" "askuser")
				(confirm)
				(infos)
				(all)
			)
		)
	))
)


;***************************************************************************************************
;***	Procedure SelectDir <default dest> <text> <helptext>
;***************************************************************************************************
(procedure P_SelectDir p_dest p_text p_help

	;*** Ask the user for any directory.
	;***
	(set p_dest
		(askdir
			(prompt		p_text)
			(help		(cat p_help "\n\n" @askdir-help))
			(default	p_dest)
		)
	)

	(set p_dest p_dest)
)


;***************************************************************************************************
;***	Procedure CopyNewer <source dir> <pattern> <dest dir>
;***************************************************************************************************
(procedure P_CopyNewer p_srcdir p_pat p_destdir

	;*** Compare the version/size
	;***
	(foreach p_srcdir p_pat (

		(set res 1)

		;*** Recursively call.
		;***
		(if (= 2 (P_CheckExists (tackon p_srcdir @each-name)))
		(
			(P_MakeDir p_destdir @each-name "icons")

			(set savesrc	p_srcdir)
			(set savepat	p_pat)
			(set savedest	p_destdir)

			(P_CopyNewer (tackon p_srcdir @each-name) "#?" (tackon p_destdir @each-name))

			(set p_srcdir	savesrc)
			(set p_pat		savepat)
			(set p_destdir	savedest)
		)
		(
			;*** Get the two version numbers.
			;***
			(if (= 0 (getversion (tackon p_srcdir @each-name)))
			(
				(set srcvers (cat "  (" (/ (getsize (tackon p_srcdir @each-name)) 1024) "kB)"))

				(if ((P_CheckExists (tackon p_destdir @each-name)))
				(
					(set destname @each-name)
					(set msgcopyover2 #msgcopyover2)

					(if (= 0 (getversion (tackon p_destdir @each-name)))
						(set destvers (cat "  (" (/ (getsize (tackon p_destdir @each-name)) 1024) "kB)"))
						(set destvers (cat (P_GetFullVersion (tackon p_destdir @each-name)) "  (" (/ (getsize (tackon p_destdir @each-name)) 1024) "kB)"))
					)
				)
				(
					(set destname #msgcopyovernofile)
					(set destvers "")
					(set msgcopyover2 "\n")
				))

				(set res (askbool
					(prompt		(cat #msgcopyover1 @each-name " " srcvers msgcopyover2 destname " " destvers))
					(help		(cat #msgcopyover1 @each-name " " srcvers msgcopyover2 destname " " destvers))
					(default	1)
				))

				(if (= 1 res) (
					(copyfiles
						(prompt #msgcopy)
						(help (cat #msgcopy @copyfiles-help))
						(source	p_srcdir)
						(dest	p_destdir)
						(pattern @each-name)
						(infos)
					)
				))
			)
			(
				(if (= 2 @user-level)
					(copylib
						(prompt (cat #msgcopy @each-name))
						(help (cat #msgcopy @each-name "\n\n" @copylib-help))
						(source	(tackon p_srcdir @each-name))
						(dest 	p_destdir)
						(confirm)
						(infos)
					)
					(copylib
						(prompt (cat #msgcopy @each-name))
						(help (cat #msgcopy @each-name "\n\n" @copylib-help))
						(source	(tackon p_srcdir @each-name))
						(dest 	p_destdir)
						(infos)
					)
				)
			))
		))
	))
)


;***************************************************************************************************
;***	Procedure CopyNewerExists
;***************************************************************************************************
(procedure P_CopyNewerExists p_srcdir p_pat p_destdir

	(if (P_CheckExistsPat p_destdir p_pat) (P_CopyNewer p_srcdir p_pat p_destdir))
)




;***************************************************************************************************
;***	Procedure PreInstall
;***************************************************************************************************
(procedure P_PreInstall

	(set @default-dest (tackon #destdocs #destdocsdir))
)


;***************************************************************************************************
;***	Procedure Welcome
;***************************************************************************************************
(procedure P_About p_update

;	(set date (getenv (tackon (pathonly @icon) "hyperIOVersion")))
;	(set ver			(/ vers 65536))
;	(set rev			(- vers (* ver 65536)))
;	(set version		(cat ver "." rev))

;	(message (cat #msgwelcome1 " " version #msgwelcome2 #msgcopyright))
	(message (cat #msgwelcome1 #msgwelcome2 #msgcopyright))
)


;***************************************************************************************************
;***	Procedure CheckOldInst
;***************************************************************************************************
(procedure P_CheckOldInst

	(set ret 1)

	(working #msgworkingsearchold)

	;*** Check for a version file in devs:
	;***
	(if (= 0 (P_CheckExists (tackon #destdevs "hyperIOVersion")))
	(
		(set patcnt 0)

		;*** Search for devices and libs (resource lib does not bother if isdn installed)
		;***
		(if (P_CheckExistsPat #destdevs #devspat) (set patcnt (+ 1 patcnt)))
		(if (AND (P_CheckExistsPat #destlibs #libspat) (= 0 (P_CheckExistsPat #destdevs #devsisdnpat))) (set patcnt (+ 1 patcnt)))
		(if (P_CheckExistsPat (tackon #destdocs #destdocsdir) "(Documentaion|Dokumentation)") (set patcnt (+ 1 patcnt)))
		(if (P_CheckExistsPat (tackon #destutil #destutildir) "Goodies") (set patcnt (+ 1 patcnt)))

		;*** Found some very old files
		;***
		(if (> patcnt 0)
		(
			(set ret 2)

			;*** Let the user select what to do (update, install new).
			;***
			(set	#instchoice
				(askchoice
					(prompt		#msgoldinst)
					(help		(cat #msgoldinst "\n\n" @askchoice-help))
					(choices	#msgoldinstnew #msgoldinstback #msgoldinstdeinst #msgoldinstend)
					(default    0)
				)
			)

			;*** Add 1 to the choice (If very old, no update possible!)
			;***
			(set #instchoice (+ 1 #instchoice))
		)
		(
			;*** No previous installation found! Install new.
			;***
			(set #instchoice 1)
			(set ret 3)
		))
	)
	(
		;*** Else, we look vor the verion number
		;*** coded as version=high-byte and revision=low-byte.
		;***
		(set oldvers (getenv (tackon #destdevs "hyperIOVersion")))
		(set newvers (getenv (tackon (pathonly @icon) "hyperIOVersion")))

		(if (< oldvers newvers) (

			;*** Let the user select what to do (update, install new).
			(set	#instchoice
				(askchoice
					(prompt		#msgoldinst)
					(help		(cat #msgoldinst "\n\n" @askchoice-help))
					(choices	#msgoldinstupdate #msgoldinstnew #msgoldinstback #msgoldinstdeinst #msgoldinstend)
					(default    0)
				}
			))
		)
		(
			(set ret 1)

			;*** All files up to date. May the user want to deinstall the files...
			(set	choice
				(askchoice
					(prompt		#msguptodate)
					(help		(cat #msguptodate "\n\n" @askchoice-help))
					(choices	#msgoldinstnew #msgoldinstdeinst #msgoldinstend)
					(default    0)
				}
			))

			(if (= 0 choice)
				(set #instchoice 1)

				(if (= 1 choice)
					(set #instchoice 3)

					(if (= 2 choice)
						(set #instchoice 4)
					)
				)
			)
		))
	))

	;*** We have to cancel (end) the installation script
	;***
	(if (= 4 #instchoice) (set ret 0))

	(set ret ret)
)


;***************************************************************************************************
;***	Procedure PrepareInstall
;***************************************************************************************************
(procedure P_PrepareInstall

	;*** Only ask, if not deinstallation.
	;***
	(if (<> 3 #instchoice) (

		;*** Let the user select which parts of the software should be installed
		;***
		(set #instparts
			(askoptions
				(prompt		#msgwhichparts)
				(help		(cat #msgwhichparts "\n\n" @askchoice-help))
				(choices	#msgwhichdevs #msgwhichlibs #msgwhichdocs #msgwhichutil)
				(default	#instparts)
			}
		))

		;*** Let the user select which cards are installed and which utils should be installed (if NO update)
		;***
		(if (<> 0 #instchoice) (
			(if (IN #instparts 0)
				(set	#instcards
					(askoptions
						(prompt		#msgcardinst)
						(help		(cat #msgcardinsthelp "\n\n" @askoptions-help))
						(choices	#msgvmchc1d #msgvmchc3d #msgvmchc3z #msgvmchc4d #msgvmchc3ihc4d #msgvmchc3ihc3zd #msgvmchpd)
						(default	#instcards)
					)
				)
				(set #instcards 0)
		    )

			(if (IN #instparts 3)
				(set	#instutil
					(askoptions
						(prompt		#msgutilinst)
						(help		(cat #msgutilinsthelp "\n\n" @askoptions-help))
						(choices	#msgutilncommd #msgutilncommpkd #msgutilhydrad #msgutilporthd #msgutilprtmand #msgutilauxhd)
						(default	#instutil)
					)
				)
				(set #instutil 0)
		    )
		))

		;*** Ask for the destination dirs depending on selected parts
		;***
		(if (IN #instparts 0) (set #destdevs (P_SelectDir #destdevs #msgaskdevs #msgaskdevs)))
		(if (IN #instparts 1) (set #destlibs (P_SelectDir #destlibs #msgasklibs #msgasklibs)))
		(if (IN #instparts 2) (set #destdocs (P_SelectDir #destdocs #msgaskdocs #msgaskdocs)))
		(if (IN #instparts 3) (set #destutil (P_SelectDir #destutil #msgaskutil #msgaskutil)))

		;*** Let the user select a backup dir if backup selected
		;***
		(if (= 2 #instchoice) (set #destback (P_SelectDir #destback #msgaskback #msgaskback)))
	))
)


;***************************************************************************************************
;***	Procedure AskConfirmation
;***************************************************************************************************
(procedure P_AskConfirmation

	(set msgconfirm2 "")

	(if (<> 3 #instchoice)
	(
		(set msgconfirm1	(cat	#msgconfirm
									#msgconfirmcpu	cpuname
									#msgconfirmfpu	fpuname
									#msgconfirmos	osname
									"\n"))

		(if (IN #instparts 0) (set msgconfirm2 (cat msgconfirm2 #msgconfirmdevsdest #destdevs)))
		(if (IN #instparts 1) (set msgconfirm2 (cat msgconfirm2 #msgconfirmlibsdest #destlibs)))
		(if (IN #instparts 2) (set msgconfirm2 (cat msgconfirm2 #msgconfirmdocsdest (tackon #destdocs #destdocsdir))))
		(if (IN #instparts 3) (set msgconfirm2 (cat msgconfirm2 #msgconfirmutildest (tackon #destutil #destutildir))))
	)
	(

		(set msgconfirm1			#msgconfirmdeinst)

		(set msgconfirm2	(cat    #msgconfirmdevsdest	#destdevs
									#msgconfirmlibsdest	#destlibs
									#msgconfirmdocsdest	(tackon #destdocs #destdocsdir)
									#msgconfirmutildest	(tackon #destutil #destutildir)))

	))


	(if (= 2 #instchoice)
		(set msgconfirm3	(cat	#msgconfirmbackdest (tackon #destback #destbackdir)))
	)

	(set msgconfirm			(cat	msgconfirm1 msgconfirm2 msgconfirm3 #msgconfirmask))

	;*** All right?
	(set	choice
		(askbool
			(prompt		msgconfirm)
			(help		msgconfirm)
			(default	1)
		)
	)

	(set @default-dest (tackon #destdocs #destdocsdir))

	(set choice choice)
)



;***************************************************************************************************
;***	Procedure SetupInstall
;***************************************************************************************************
(procedure P_SetupInstall

	(if (<> 3 #instchoice) (working #msgworkingprepareinst) (working #msgworkingpreparedeinst))

	(if (= 0 #instchoice) (
		(P_PreUpdate)
	))

	(if (= 1 #instchoice) (
		(P_PreDeInstall)
		(P_PreNewInstall)
	))

	(if (= 2 #instchoice) (
		(P_PreNewInstall)
	))

	(if (= 3 #instchoice) (
		(P_PreDeInstall)
	))
)


;***************************************************************************************************
;***	Procedure DoInstall
;***************************************************************************************************
(procedure P_DoInstall

	(if (<> 3 #instchoice) (working #msgworkinginst) (working #msgworkingdeinst))

	(if (= 0 #instchoice) (
		(P_DoUpdate)
	))

	(if (= 1 #instchoice) (
		(P_DeInstall)
		(P_NewInstall)
	))

	(if (= 2 #instchoice) (
		(P_Backup)
		(P_NewInstall)
	))

	(if (= 3 #instchoice) (
		(P_DeInstall)
	))
)



;***************************************************************************************************
;***	Procedure PreUpdate
;***************************************************************************************************
(procedure P_PreUpdate

)


;***************************************************************************************************
;***	Procedure DoUpdate
;***************************************************************************************************
(procedure P_DoUpdate

	;*** Define the source dirs
	;***
	(set srcdir (pathonly @icon))
	(set srcdirdevs (tackon srcdir "devs"))
	(set srcdirlibs (tackon srcdir "libs"))
	(set srcdirdocs (tackon srcdir "docs"))
	(set srcdirutil (tackon srcdir "goodies"))

	;*** Now copy the files always needed
	;***

	;*** Copy the selected drivers.
	;***
	(if (IN #instparts 0) (

		(set copycard 0)
		(set copiedcards 0)
		(set instcards #instcards)

		(if (AND (IN instcards 2) (IN instcards 5)) (set instcards (- instcards 32)))
		(if (AND (IN instcards 3) (IN instcards 4)) (set instcards (- instcards 16)))

		(while (< copycard 7) (

			(if (IN instcards copycard) (

				(if (= copycard 0)						(set cardpat #vmchc1))
				(if (= copycard 1)						(set cardpat #vmchc3))
				(if (OR (= copycard 2) (= copycard 5))	(set cardpat #vmchc3z))
				(if (OR (= copycard 3) (= copycard 4))	(set cardpat #vmchc4))
				(if (= copycard 6)						(set cardpat #vmchp))

				(if (NOT (IN copiedcards copycard))	(
					(set copiedcards (BITOR copiedcards (shiftleft 1 copycard)))
					(P_CopyNewerExists srcdirdevs cardpat #destdevs)
				))
			))

			(set copycard (+ 1 copycard))
		))
	))


	;*** resource library
	;***
	(if (IN #instparts 1) (P_CopyNewerExists srcdirlibs #vmcrsc #destlibs))

	;*** documentation
	;***
	(P_MakeDir #destdocs #destdocsdir "icons")
	(if (IN #instparts 2) (P_CopyNewerExists srcdirdocs "#?" (tackon #destdocs #destdocsdir)))

	;*** Goodies
	;***
	(if (IN #instparts 3) (

		(P_MakeDir #destutil #destutildir "icons")
		(P_MakeDir (tackon #destutil #destutildir) "Goodies" "icons")

		(if (IN #instutil 0) (P_CopyNewerExists srcdirutil (cat #utilncomm "#?")	(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 1) (P_CopyNewerExists srcdirutil (cat #utilncommpk "#?")	(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 2) (P_CopyNewerExists srcdirutil (cat #utilhydra "#?")	(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 3) (P_CopyNewerExists srcdirutil (cat #utilporth "#?")	(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 4) (P_CopyNewerExists srcdirutil (cat #utilprtman "#?")	(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 5) (P_CopyNewerExists srcdirutil (cat #utilauxh "#?")		(tackon (tackon #destutil #destutildir) "Goodies")))
	))

	;*** Version ID file
	;***
	(copyfiles 
		(source (tackon srcdir "hyperIOVersion"))
		(dest #destdevs)
		(nogauge)
		(files)
	)
)


;***************************************************************************************************
;***	Procedure PreNewInstall
;***************************************************************************************************
(procedure P_PreNewInstall

)


;***************************************************************************************************
;***	Procedure NewInstall
;***************************************************************************************************
(procedure P_NewInstall

	;*** Define the source dirs
	;***
	(set srcdir (pathonly @icon))
	(set srcdirdevs (tackon srcdir "devs"))
	(set srcdirlibs (tackon srcdir "libs"))
	(set srcdirdocs (tackon srcdir "docs"))
	(set srcdirutil (tackon srcdir "goodies"))

	;*** Now copy the files always needed
	;***

	;*** Copy the selected drivers.
	;***
	(if (IN #instparts 0) (

		(set copycard 0)
		(set copiedcards 0)

		(while (< copycard 7) (

			(if (IN #instcards copycard) (

				(if (= copycard 0)						(set cardpat #vmchc1))
				(if (= copycard 1)						(set cardpat #vmchc3))
				(if (OR (= copycard 2) (= copycard 5))	(set cardpat #vmchc3z))
				(if (OR (= copycard 3) (= copycard 4))	(set cardpat #vmchc4))
				(if (= copycard 6)						(set cardpat #vmchp))

				(if (NOT (IN copiedcards copycard))	(
					(set copiedcards (BITOR copiedcards (shiftleft 1 copycard)))
					(P_CopyNewer srcdirdevs cardpat #destdevs)
				))
			))

			(set copycard (+ 1 copycard))
		))
	))


	;*** resource library
	;***
	(if (IN #instparts 1) (P_CopyNewer srcdirlibs #vmcrsc #destlibs))

	;*** documentation
	;***
	(P_MakeDir #destdocs #destdocsdir "icons")
	(if (IN #instparts 2) (P_CopyNewer srcdirdocs "#?" (tackon #destdocs #destdocsdir)))

	;*** Goodies
	;***
	(if (IN #instparts 3) (

		(P_MakeDir #destutil #destutildir "icons")
		(P_MakeDir (tackon #destutil #destutildir) "Goodies" "icons")

		(if (IN #instutil 0) (P_CopyNewer srcdirutil (cat #utilncomm "#?")		(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 1) (P_CopyNewer srcdirutil (cat #utilncommpk "#?")	(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 2) (P_CopyNewer srcdirutil (cat #utilhydra "#?")		(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 3) (P_CopyNewer srcdirutil (cat #utilporth "#?")		(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 4) (P_CopyNewer srcdirutil (cat #utilprtman "#?")		(tackon (tackon #destutil #destutildir) "Goodies")))
		(if (IN #instutil 5) (P_CopyNewer srcdirutil (cat #utilauxh "#?")		(tackon (tackon #destutil #destutildir) "Goodies")))
	))

	;*** Version ID file
	;***
	(copyfiles
		(source (tackon srcdir "hyperIOVersion"))
		(dest #destdevs)
		(nogauge)
		(files)
	)
)


;***************************************************************************************************
;***	Procedure Backup
;***************************************************************************************************
(procedure P_Backup

	(working #msgworkingbackup)

	;*** Create all needed dirs
	;***
	(P_MakeDir #destback "" "icons")
	(P_MakeDir #destback #destbackdir "icons")


	;*** Backup version information file
	;***
	(if (P_CheckExists (tackon #destdevs "hyperIOVersion")) (

		(copyfiles
			(source (tackon #destdevs "hyperIOVersion"))
			(dest (tackon #destback #destbackdir))
			(nogauge)
			(files)
		)

		(P_Delete (tackon #destdevs "hyperIOVersion") "noicons" "noreq")
	))


	;*** Backup Devs drawer
	;***
	(foreach #destdevs #devspat (

		(copyfiles
			(source (tackon #destdevs @each-name))
			(dest (tackon (tackon #destback #destbackdir) "devs"))
			(nogauge)
			(files)
		)

		(P_Delete (tackon #destdevs @each-name) "icons" "req")
	))


	;*** Backup Libs drawer
	;***
	(foreach #destlibs #libspat (

		(copylib
			(source (tackon #destlibs @each-name))
			(dest (tackon (tackon #destback #destbackdir) "libs"))
			(nogauge)
		)

		;*** Don't delete any library if isdn installed!
		;***
		(if (= 0 (P_CheckExistsPat #destdevs #devsisdnpat)) (P_Delete (tackon #destlibs @each-name) "icons" "req"))
	))

	;*** Backup documentation
	;***
	(if (P_CheckExistsPat (tackon #destdocs #destdocsdir) "Documentation") (

		(copyfiles
			(source (tackon #destdocs #destdocsdir))
			(dest (tackon #destback #destbackdir))
			(pattern "Documentation")
			(nogauge)
			(infos)
		)

		(P_Delete (tackon (tackon #destdocs #destdocsdir) "Documentation") "icons" "req")
	))

	(if (P_CheckExistsPat (tackon #destdocs #destdocsdir) "Dokumentation") (

		(copyfiles
			(source (tackon #destdocs #destdocsdir))
			(dest (tackon #destback #destbackdir))
			(pattern "Dokumentation")
			(nogauge)
			(infos)
		)

		(P_Delete (tackon (tackon #destdocs #destdocsdir) "Dokumentation") "icons" "req")
	))


	;*** Backup goodies
	;***
	(if (P_CheckExistsPat (tackon #destutil #destutildir) "Goodies") (

		(copyfiles
			(source (tackon #destutil #destutildir))
			(dest (tackon #destback #destbackdir))
			(pattern "Goodies")
			(nogauge)
			(infos)
		)

		(P_Delete (tackon (tackon #destutil #destutildir) "Goodies") "icons" "req")
	))

)


;***************************************************************************************************
;***	Procedure PreDeInstall
;***************************************************************************************************
(procedure P_PreDeInstall

	;*** Create a scriptfile header
	;***
	(run (cat "echo >t:csinstdelete.temp \";csinstdelete.temp - Temporary file - Do not edit or delete*n\""))

	(set match 0)

	;*** Check for files do delete
	;***
	(if (P_CheckExistsPat #destdevs #devspat)												(set match (BITOR match 1)))
	(if (P_CheckExistsPat #destlibs (cat "~(" #vmcrsc "|~(" #libspat "))"))					(set match (BITOR match 2)))
	(if (P_CheckExistsPat (tackon #destdocs #destdocsdir) "(Documentaion|Dokumentation)")	(set match (BITOR match 4)))
	(if (P_CheckExistsPat (tackon #destutil #destutildir) "Goodies")						(set match (BITOR match 8)))
	(if (P_CheckExistsPat #destlibs #vmcrsc)												(set match (BITOR match 16)))

	;*** Delete libs files if available AND no isdn installed (ask expert user)!
	;***
	(if (= 3 #instchoice) (

		(set isdninst (P_CheckExistsPat #destdevs #devsisdnpat))

		(if (<> 0 isdninst) (
			(if (IN match 4) (
				(if (> (getversion (tackon #destlibs #vmcrsc)) (getversion (tackon (tackon (pathonly @icon) "libs") #vmcrsc))) (

					(set delrsclib 0)

					(if (= 2 @user-level) (

						(set	delrsclib
							(askbool
								(prompt		#msgdelrsclib)
								(help		(cat #msgdelrsclib @askbool-help))
								(default	0)
							)
						)
					))

					(if (= 1 delrsclib) (P_DeleteConfirmFiles #destlibs #vmcrsc 0))
				))
			))
		))
	))

	;*** Reset vmcresource flag
	;***
	(set match (BITAND match 15))

	;*** Found some?
	;***
	(if (<> match 0 ) (

		(if (= 2 @user-level) (message #msgoldfilesexp) (message #msgoldfilesave))

		;*** Delete devs files.
		;***
		(if (IN match 0) (P_DeleteConfirmFiles #destdevs #devspat 0))

		;*** Delete libs files.
		;***
		(if (IN match 1) (P_DeleteConfirmFiles #destlibs #libspat 0))

		;*** Delete dokumentation files.
		;***
		(if (IN match 2) (P_DeleteConfirmFiles (tackon #destdocs #destdocsdir) "(Documentation|Dokumentation)" 1))

		;*** Delete goodie files.
		;***
		(if (IN match 3) (P_DeleteConfirmFiles (tackon #destutil #destutildir) "Goodies" 1))

		;*** Delete docs/goodies directory.
		;***
		(P_DeleteConfirmFiles #destdocs #destdocsdir 1)

		(if (OR (<> #destdocs #destutil) (<> #destdocsdir #destutildir)) (
			(P_DeleteConfirmFiles #destutil #destutildir 1)

		))
	))
)


;***************************************************************************************************
;***	Procedure DeleteConfirmFiles
;***************************************************************************************************
(procedure P_DeleteConfirmFiles p_dir p_pat p_isdir

	;*** Reset all used vars.
	;***
	(set cnt 0)
	(set defopt 0)

	(if (P_CheckExistsPat p_dir p_pat) (

		(foreach p_dir p_pat (

			(symbolset (cat "f" cnt) (tackon p_dir @each-name))

			(set defopt (BITOR defopt (shiftleft 1 cnt)))
			(set cnt (+ 1 cnt))

			(if (= 14 cnt) (
				(set usedopt (P_DeleteConfirmFiles2 defopt p_isdir f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13))

				(set cnt 0)
				(set defopt 0)
			))
		))

		(while (< cnt 14) (
			(symbolset (cat "f" cnt) "")
			(set cnt (+ 1 cnt))
		))

		(set usedopt (P_DeleteConfirmFiles2 defopt p_isdir f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13))
	))

	(set usedopt usedopt)
)


;***************************************************************************************************
;***	Procedure DeleteConfirmFiles2
;***************************************************************************************************
(procedure P_DeleteConfirmFiles2 p_defopt p_isdir p_f0 p_f1 p_f2 p_f3 p_f4 p_f5 p_f6 p_f7 p_f8 p_f9 p_f10 p_f11 p_f12 p_f13

	(if (= 2 @user-level)
	(
		(set	choice (
			(askoptions (
				(prompt		#msgoldfiles2)
				(help		#msgoldfiles2 @askoptions-help)
				(choices	p_f0 p_f1 p_f2 p_f3 p_f4 p_f5 p_f6 p_f7 p_f8 p_f9 p_f10 p_f11 p_f12 p_f13)
				(default	p_defopt)
			))
		))
	)
	(set choice p_defopt))

	(set cnt 0)

	(while (< cnt 14) (

		(if (IN choice cnt) (
			(set delfile (select cnt p_f0 p_f1 p_f2 p_f3 p_f4 p_f5 p_f6 p_f7 p_f8 p_f9 p_f10 p_f11 p_f12 p_f13))

			;*** Append a delete command for each file/dir.
			;***
			(if (<> 0 p_isdir )
				(run (cat "echo >>t:csinstdelete.temp \"delete " delfile " all\""))
				(run (cat "echo >>t:csinstdelete.temp \"delete " delfile "\""))
			)
		))

		(set cnt (+ 1 cnt))
	))

	(set choice choice)
)


;***************************************************************************************************
;***	Procedure DeInstall
;***************************************************************************************************
(procedure P_DeInstall

	;*** Now REALLY delete the old files (script made by SetupInstall/PreDeInstall).
	;***
	(if (<> 1 @pretend) (
		(execute "t:csinstdelete.temp")
	))

	(P_Delete (tackon #destdevs "hyperIOVersion") "noicons" "noreq")
)


;***************************************************************************************************
;***	Procedure AfterInstall
;***************************************************************************************************
(procedure P_AfterInstall

	(if (<> 3 #instchoice) (
		(if (<> 0 (P_CheckExists "sys:utilities/multiview"))
			(set mvpath "sys:utilities/multiview ")

			(if (<> 0 (P_CheckExists "sys:system/multiview"))
				(set mvpath "sys:utilities/multiview ")
				(set mvpath "multiview ")
			)
		)

		(if (= 1 (askbool
			(prompt #msgshowreadme)
			(default 1)
			(help (cat #msgshowreadme "\n\n" @askbool-help))))

			(if (= @language "deutsch")
				(run (cat mvpath "LiesMichZuerst.guide"))
				(run (cat mvpath "ReadMeFirst.guide"))
			)
		)

		(user 2)
		(if (= 1 (askbool
			(prompt #msgreboot)
			(help (cat #msgreboot "\n\n" @askbool-help))
			(default 1)
			(choices #msgrebootyes #msgrebootno)))
			(run (tackon (pathonly @icon) "reboot"))
		)
	))
)


;***************************************************************************************************
;***	Procedure Cleanup
;***************************************************************************************************
(procedure P_Cleanup

	(delete "t:csinstcheckpat#?.temp")
	(delete "t:csinstdelete.temp")
)


;***************************************************************************************************
;***	Entry point
;***************************************************************************************************
;*** No user should have a Installer version below 43.3!

(if (< @installer-version 2818051) (
	(message #wronginstaller)
	(exit (quiet))
))

(complete 0)

(P_PreInstall)

(welcome)

(P_About)

(if (P_CheckOldInst) (

	(complete 5)

	(P_CheckOS)
	(P_CheckCPU)

	(P_PrepareInstall)

	(complete 10)

	;*** Ask for confirmation
	(if (P_AskConfirmation) (

		(complete 20)
		(P_SetupInstall)

		(complete 40)
		(P_DoInstall)

		(complete 100)
		(P_AfterInstall)
	))

	(P_Cleanup)

	(if (<> 3 #instchoice) (exit #msgendinst (quiet)) (exit #msgenddeinst (quiet)))
))

(complete 100)
(P_Cleanup)
(exit #msgend2 (quiet))


