;	$VER: Install_dt 39.40 (10.07.2000)
;	Copyright © 2000 A.S.Munde.
;	If you want to use this installer script for other datatype use please
;	contact me by email
;	email: docdatatypes@yahoo.com

(welcome "Welcome to the " @app-name " Datatype Installer\n")

(if (< (/ (getversion) 65536) 39) (message "\nDataTypes require Amiga OS 3.0 or higher."))

(set mode
	(askchoice
		(prompt "What do you want to do")
		(help (cat "To remove the datatypes this installer must be in the original package directory.\n\n" @askchoice-help))
		(choices "Install" "Remove")
	)
)

(if mode
	(set pmode "Remove")
	(set pmode "Install")
)

; get classes dir
(set classdir
	(askdir
		(prompt "Where do the Classes belong")
		(help (cat "The classes directory is where Datatypes, Gadgets, etc belong\n\n" @askdir-help))
		(default "SYS:Classes")
	)
)

; now do install or remove
(if mode
	; Remove
	(
		; Show what we are doing
		(working "Removing " @app-name)
		; Remove the non-standard pieces
		(foreach "Devs/Datatypes" "#?"
			(delete
				(cat "devs:datatypes/" @each-name)
				(infos)
			)
		)
		(foreach "Classes/Datatypes" "#?.datatype"
			(delete (tackon (tackon classdir "Datatypes") @each-name))
		)

		; Don't want to use the confusing "Installation Complete" message
		; when what we really did was remove things...
		(message "The \"" @app-name "\" components "
			"that you specified have been successfully removed")
	)

	; Install
	(
		(working "Removing Old Data...")
		(delete "devs:datatypes/WordPerfect Doc7"
			(infos)
		)
		(delete "devs:datatypes/MS WinWord Doc8"
			(infos)
		)
		(delete "devs:datatypes/Rich Text Format Doc1"
			(infos)
		)

		(working "Installing " @app-name)

		(foreach "Devs/Datatypes" "#?"
			(copylib
				(prompt (cat "Copying " @each-name " Descriptor"))
				(help (cat "If the file version is newer select install.\n\n" @copylib-help))
				(source (cat "Devs/DataTypes/" @each-name))
				(dest "SYS:Devs/DataTypes")
				(infos)
				(optional "nofail" "force")
				(confirm)
			)
		)

		(foreach "Classes/Datatypes" "#?.datatype"
			(copylib
				(prompt (cat "Copying " @each-name " Datatype"))
				(help (cat "If the file version is newer select install.\n\n" @copylib-help))
				(source (cat "Classes/DataTypes/" @each-name))
				(dest (tackon classdir "Datatypes"))
				(optional "nofail" "force")
				(confirm)
			)
		)

		(run "C:AddDataTypes QUIET REFRESH")

		(message "\nInstallation complete.\n")
	)
)
(exit (quiet))
