;$VER: Install 1.02 (19.01.1995) (C) Copyright Tomi Blinnikka 1995-96

(complete 0)

(set action
	(askchoice
		(prompt "Please choose action:")
		(help "You can either install or remove VoiceShell with this utility.\n\n" @askchoice-help)
		(choices "Install" "Remove")
		(default 0)
	)
)

(if (= action 0)

(

	(set vs-dest
		(tackon 
			(askdir
				(prompt "In which disk or drawer should VoiceShell and utilities be installed?\nA new drawer named VoiceShell will be created.")
				(help @askdir-help)
				(default @default-dest)
			)
		"VoiceShell"
		)
	)
	(makedir vs-dest (infos))
	(set @default-dest vs-dest)


	(complete 35)

	(copyfiles
		(source "VoiceShell")
		(choices "VoiceShell" "VSConv")
		(dest vs-dest)
		(prompt "Which files should be copied?")
		(help @copyfiles-help)
		(infos)
		(files)
		(confirm)
	)


	(complete 41)

	(copyfiles
		(prompt "Which languages should be installed?")
		(help @copyfiles-help)
		(source "VoiceShell/Catalogs")
		(dest "LOCALE:Catalogs")
		(all)
		(infos)
		(noposition)
		(confirm)
	)

	(complete 44)

	(set vsrexx-dest
		(askdir
			(prompt "Where should the script files be installed?")
			(help @askdir-help)
			(default "REXX:")
		)
	)

	(copyfiles
		(source "VoiceShell/Scripts")
		(dest vsrexx-dest)
		(prompt "Which script files should be installed?")
		(help @copyfiles-help)
		(all)
		(files)
		(confirm)
	)


	(complete 56)

	(set vsguide-dest
		(askdir
			(prompt "Where should the AmigaGuide help files be installed?")
			(help @askdir-help)
			(default "Guide:")
		)
	)


	(complete 65)

	(copyfiles
		(source "VoiceShell/Documents")
		(dest vsguide-dest)
		(prompt "Which documents should be installed?")
		(help @copyfiles-help)
		(infos)
		(choices "VoiceShell.guide" "VSConv.guide")
		(files)
	)


	(complete 71)

		(if (= (askbool
			(prompt "Do you wish to install the Assembler source files?")
			(help "Selecting 'Yes' will allow you specify a directory for the source files.")
			)
		1)

		(
			(set vssource-dest
				(askdir
					(prompt "Where should the Assembler source files be installed?")
					(help @askdir-help)
					(default vs-dest)
				)
			)


			(copyfiles
				(source "VoiceShell/Source")
				(dest vssource-dest)
				(prompt "Which Assembler source files should be installed?")
				(help @copyfiles-help)
				(all)
				(files)
				(confirm)
			)

		))

	(complete 83)

	(copylib
		(prompt "Copying voice.library to LIBS:.")
		(source "VoiceShell/Libs/voice.library")
		(dest "LIBS:")
		(help @copylib-help)
		(confirm)
	)

	(complete 88)

	(startup "VoiceShell"
		(help @startup-help)
		(prompt
		"Some commands need to be added to the \"S:User-Startup\".")
		(command "Path \""vs-dest"\" ADD\n")
		)


	(complete 90)

	(while (= (askbool
		(prompt "Do you wish to update (more) data files?")
		(help "Selecting 'Yes' will allow you to convert VCLI and old VoiceShell data files for the current version.")
		)
	1)

	(
		(set prefs "")
		(set data "")
		(set vsdata-dest "")
		(set OK 0)
		(set file "")
		(set delfile "")

		(set data
			(askfile
				(prompt "Please give data file")
				(help @askfile-help)
				(default "VoiceShell.DAT")
			)
		)

		(if (= (askbool
			(prompt "Do you wish to associate a prefs file with this data file?")
			(help "Selecting 'Yes' will allow you specify a VoiceShell prefs file to be used with the selected data file.")
			)
		1)

			(set prefs
				(askfile
					(prompt "Please give prefs file")
					(help @askfile-help)
					(default "ENVARC:VoiceShell.PREFS")
				)
			)
		)

		(set vsdata-dest
			(askfile
				(prompt "Please a name for destination file")
				(help @askfile-help)
				(default "Project.VS")
			)
		)

			(set file (cat "VoiceShell/VSConv FROM \"" data "\" \"" prefs "\" TO \"" vsdata-dest "\""))

			(Set OK
				(run file)
			)

			(if (= OK 5)
				(message "VSConv had a problem with the specified prefs file. Used defaults.")
			)
			(if (= OK 20)
				(abort "Sorry, a fatal error occured during conversion. File not converted.")
				(if (= (askbool
					(prompt "Do you wish to delete the old data and prefs files?")
					(help "Selecting 'Yes' will destroy the specified files.")
					)
				1)
					(set delfile (cat "Delete \"" data "\" \"" prefs "\ QUIET"))
					(run delfile)
				)
			)

	)

	)

	(complete 100)

	(exit)

))

(if (= action 1)

(

	(set @abort-button "Abort Removal")

	(if (= 1 (exists "C:VoiceShell" (noreq)))
		(
			(if (= (askbool
				(prompt "Going to delete C:VoiceShell. \n\nAre you sure you want to continue?")
				(help "Selecting 'Proceed' will destroy the specified file.")
				(choices "Proceed" "Skip This Part")
				)
			1)

				(
					(run "Delete C:VoiceShell QUIET")
					(run "Delete C:VoiceShell.info QUIET")
				)
			)
		)
	)

	(complete 6)

	(set name
		(askdir
			(prompt "Where is VoiceShell installed?")
			(help @askdir-help)
			(default @default-dest)
		)
	)

	(complete 10)


	(if (= (askbool
		(prompt "Do you wish to delete the directory \"" name "\"?\n\nNote! The directory itself may still exist after this procedure. After this program is finished, please reset your Amiga and re-run this program to remove the directory.")
		(help "Selecting 'Proceed' will destroy the directory and everything in it")
		(choices "Proceed" "Skip This Part")
		)
	1)

		(
			(set file (cat "Delete \"" name "\" ALL FORCE"))
			(run file)

			(set file (cat "Delete \"" name ".info\""))
			(run file)
		)
	)

	(complete 32)

	(startup "VoiceShell"
		(help @startup-help)
		(prompt
		"Some commands might need to be removed from \"S:User-Startup\".\n\nNote! Two lines will still remain! Please remove these yourself.")
		(command "")
		)

	(complete 38)

	(if (= (askbool
		(prompt "Going to delete ALL files in the S: directory that have 'VoiceShell' in file name.\n\nAre you sure you want to continue?")
		(help "Selecting 'Proceed' will destroy the specified files.")
		(choices "Proceed" "Skip This Part")
		)
	1)

		(run "Delete S:#?VoiceShell#? QUIET")
	)

	(complete 44)


	(if (= (askbool
		(prompt "Going to delete ALL files in the S: directory that have the postfix '.VS'.\n\nAre you sure you want to continue?")
		(help "Selecting 'Proceed' will destroy the specified files.")
		(choices "Proceed" "Skip This Part")
		)
	1)

		(run "Delete S:#?.VS QUIET")
	)

	(complete 57)


	(if (= (askbool
		(prompt "Going to delete ALL files in the ENVARC: directory that have 'VoiceShell' in file name.\n\nAre you sure you want to continue?")
		(help "Selecting 'Proceed' will destroy the specified files.")
		(choices "Proceed" "Skip This Part")
		)
	1)

		(run "Delete ENVARC:#?VoiceShell#? QUIET")
	)

	(complete 65)


	(if (= (askbool
		(prompt "Going to delete VoiceShell ARexx scripts from REXX:.\n\nAre you sure you want to continue?")
		(help "Selecting 'Proceed' will destroy the specified files.")
		(choices "Proceed" "Skip This Part")
		)
	1)
		(
			(run "Delete REXX:VSOn.rexx QUIET")
			(run "Delete REXX:VSOff.rexx QUIET")
			(run "Delete REXX:VSOn QUIET")
			(run "Delete REXX:VSOff QUIET")
		)
	)

	(complete 78)


	(delete "LIBS:voice.library"
		(prompt "Going to delete Libs:voice.library.\n\nAre you sure you want to continue?")
		(help @delete-help)
		(confirm)
		(optional force askuser)
	)

	(delete "LOCALE:Catalogs/suomi/voiceshell.catalog"
		(prompt "Going to delete LOCALE:Catalogs/suomi/voiceshell.catalog.\n\nAre you sure you want to continue?")
		(help @delete-help)
		(confirm)
		(optional force askuser)
	)


	(complete 87)


	(if (= 2 (exists "Guide:" (noreq)))
		(
			(if (= (askbool
				(prompt "Going to delete Guide:VoiceShell.guide.\n\nAre you sure you want to continue?")
				(help "Selecting 'Proceed' will destroy the specified file.")
				(choices "Proceed" "Skip This Part")
				)
			1)

				(
					(run "Delete Guide:VoiceShell.guide QUIET")
					(run "Delete Guide:VoiceShell.guide.info QUIET")
				)
			)

			(complete 93)

			(if (= (askbool
				(prompt "Going to delete Guide:VSConv.guide.\n\nAre you sure you want to continue?")
				(help "Selecting 'Proceed' will destroy the specified file.")
				(choices "Proceed" "Skip This Part")
				)
			1)

				(
					(run "Delete Guide:VSConv.guide QUIET")
					(run "Delete Guide:VSConv.guide.info QUIET")
				)
			)

			(complete 98)

		)
	)

	(complete 100)

	(message "Removal Complete!\n\nVoiceShell should now be removed from your system. Some data files may still exist.")

	(exit (quiet))

))
