; Installer script for MCommands
; $VER: Install MCommands 37.3 (31.1.95)

(complete 0)

(set @default-dest "C:")
(set @script-dest "S:Shell-Startup")

(set #comm-dir "/C/")
(set #script-name "/S/RX-Startup")

; ***************************************************************************
; English strings

(if (= @language "english")
	(
		(set #bad-kick
			(cat "You must have AmigaDOS 2.04 or higher to use MCommands!"))

		(set #welcome
			(cat "\nMCommands installation\n\n\n"
           "This script installs MCommands 1.2\n"
           "on your Amiga.\n\n\n\n"
           "MCommands package is\n"
           "Copyright © 1994-95 Michael Letowski\n"
           "All rights reserved.\n\n"))

		(set #where-commands
			(cat "Where should MCommands be installed?"))

		(set #where-help
			(cat "\nBy default, all CLI commands are placed in C:"
           " logical directory. Hovewer, the commands can be"
           " placed in any directory, as long as it is added to"
           " search path by using \"Path\" command.\n\n"))

		(set #script
			(cat "Shall RXControl aliases be added to " @script-dest "?"))

		(set #script-help
			(cat "\nTo make RXControl fully compatible with"
           " default setup, aliases may be added to"
           " your Shell-Startup file that emulate"
           " commands from SYS:Rexxc directory."))

		(set #which-commands
			(cat "Which MCommands should be installed?"))

		(set #which-commands-help
			(cat "\n\n\"ChangeFont\" replaces topaz.font with user supplied one;"
           "\n\n\"ClickStart\" enables/disables AmigaDOS features;"
           "\n\n\"Examine\" checks type of file;"
           "\n\n\"For\" executes a command for multiple arguments;"
           "\n\n\"RXControl\" controls ARexx;"
           "\n\n\"Time\" times command execution;"
           "\n\n\"Touch\" changes date of file creation.\n\n\n"))
	)
)

; ***************************************************************************
; Polish strings

(if (= @language "polski")
	(
		(set #bad-kick
			(cat "Musisz posiadaź AmigaDOS w wersji 2.04 lub wyūszej aby uūyź pakietu!"))

		(set #welcome
			(cat "\nInstalacja \"MCommands\"\n\n\n"
           "Skrypt ten zainstaluje pakiet\n"
           "\"MCommands\" w wersji 1.2\n"
           "na twojej Amidze.\n\n\n\n"
           "Pakiet \"MCommands\" jest\n"
           "Copyright © 1994-95 Michaī Īėtowski\n"
          "All rights reserved.\n\n"))

		(set #where-commands
			(cat "Gdzie powinny zostaź zainstalowane rozkazy z pakietu?"))

		(set #where-help
			(cat "\nDomyōlnie, miejscem dla rozkazów CLI jest"
           " logiczny katalog C:. Moūna jednak umieōciź"
           " rozkazy w dowolnym miejscu tak dīugo, jak"
           " bėdzie ono w ōcieūce wyszukiwania"
           " (ustawianej rozkazem \"Path\").\n\n"))

		(set #script
			(cat "Czy mam dodaź skróty (\"aliasy\") do pliku " @script-dest "?"))

		(set #script-help
			(cat "\nAby uczyniź RXControl bardziej"
           " zgodnym z typowym systemem, pewne"
           " skróty emulujāce rozkazy z katalogu"
           " SYS:Rexxc mogā zostaź doīāczone do"
           " pliku Shell-Startup."))

		(set #which-commands
			(cat "Które rozkazy z pakietu powinny zostaź zaistalowane?"))

		(set #which-commands-help
			(cat "\n\n\"ChangeFont\" zamienia \"topaz.font\" na czcionkė wybranā"
           " przez uūytkownika;"
           "\n\n\"ClickStart\" wīācza/wyīācza funkcje AmigaDOS;"
           "\n\n\"Examine\" okreōla typy plików;"
           "\n\n\"For\" wykonuje podany rozkaz dla wielu argumentów;"
           "\n\n\"RXControl\" pozwala na kotrolė ARexx'a;"
           "\n\n\"Time\" mierzy czas wykonania rozkazu;"
           "\n\n\"Touch\" uaktualnia datė modyfikacji pliku.\n\n\n"))

	)
)

; ***************************************************************************
; Install MCommands

; Check AmigaDOS version
(set #version (/ (getversion) 65536))
(if (< #version 37)
	(
		(abort #bad-kick)
	)
)

(message #welcome)

(welcome)
(set old_level @user-level)

(user 2)
(set #mcommands-dir
	(askdir
		(prompt #where-commands)
		(help #where-help)
		(default @default-dest))
)

; Choose commands
(if (< #version 39)
	(
		(set commands
			(askoptions
				(prompt #which-commands)
				(help #which-commands-help @askoptions-help)
				(choices
					"ChangeFont"
					"ClickStart"
					"For"
					"RXControl"
					"Time"
					"Touch")
			)
		)
		(set install-rx (IN commands 3))
	)
	(
		(set commands
			(askoptions
				(prompt #which-commands)
				(help #which-commands-help @askoptions-help)
				(choices
					"ChangeFont"
					"ClickStart"
					"Examine"
					"For"
					"RXControl"
					"Time"
					"Touch")
			)
		)
		(set install-rx (IN commands 4))
	)
)

; Do copy
(user old_level)
(set n 0)
(if (< #version 39)
	(while
		(set comm
			(select n
				"ChangeFont"
				"ClickStart"
				"For"
				"RXControl"
				"Time"
				"Touch"
				"")
		)
		(
			(if (IN commands n)
				(copyfiles
					(source (cat #comm-dir comm))
					(dest #mcommands-dir)
				)
			)
			(set n (+ n 1))
			(complete (* n 14))
		)
	)
; 3.0 Install
	(while
		(set comm
			(select n
				"ChangeFont"
				"ClickStart"
				"Examine"
				"For"
				"RXControl"
				"Time"
				"Touch"
				"")
		)
		(
			(if (IN commands n)
				(copyfiles
					(source (cat #comm-dir comm))
					(dest #mcommands-dir)
				)
			)
			(set n (+ n 1))
			(complete (* n 12))
		)
	)
)

; Append RX-Startup if RXControl was chosen
(if install-rx
	(if (askbool
				(prompt #script)
				(help #script-help)
			)
		(textfile
			(dest @script-dest)
			(include @script-dest)
			(include #script-name)
		)
	)
)

(set @default-dest #mcommands-dir)
(complete 100)
(exit)
