
(set #language (getenv "Language"))

; English strings
(set #docu-welcome "Install AmigaOS 3.5 documentation on your harddisk.")
(set #docu-which-dir 
	(cat
		"In which drawer should the documentation be installed?\n"
		"A new drawer is created for each language."
	)
)
(set #docu-which-dir-help
	(cat
		"\nChoose a drawer where the OS 3.5 documentation should "
		"be installed. The documentation is copied from your "
		"AmigaOS 3.5 CD ROM and automatically reformatted."
		"\nEach language automatically gets its own drawer within the drawer "
		"you choose.\n\n"
		@askdir-help
	)
)
(set #docu-which-languages "Select the languages to install")
(set #docu-which-languages-help @askoptions-help)
(set #docu-languages-default 1)
(set #docu-which-browser "Select a browser to use for documentation reading")
(set #docu-which-browser-help
	(cat
		"\nSelect the browser you want to use to read the "
		"AmigaOS 3.5 documentation. The file you select is "
		"used as the default tool for the documentation icon.\n\n"
		@askfile-help
	)
)
(set #docu-which-browser-default "Sys:Internet/AWeb3SE/AWeb-II")
(set #docu-run-nicer-fmt "Modifing %s manual. Please wait...")
(set #docu-drawer "AmigaOS 3.5 Manual")

(complete 0)

; ****************************

(if (= #language "deutsch")
(
(set #docu-welcome "AmigaOS 3.5 Installation der Dokumentation.")
(set #docu-which-dir 
	(cat
		"In welche Schublade installieren?\n"
		"Für jede Sprache wird eine eigene erzeugt."
	)
)
(set #docu-which-dir-help
	(cat
		"\nWählen Sie eine Schublade aus, in der die OS 3.5 "
		"Dokumentation installiert werden soll. Die Dokumentation "
		"wird von Ihrer AmigaOS 3.5 CD ROM kopiert und automatisch "
		"neu formatiert."
		"\nFür jede Sprache, die Sie installieren wird eine eigene "
		"Schublade in der von Ihnen ausgewählten Schublade erzeugt. "
		"Obwohl als Vorschlag SYS: angegeben wird, sollten Sie eine "
		"andere Festplatte auswählen, wenn Sie nicht noch wenigstens "
		"10 MB Platz auf Ihrer Systemplatte frei haben.\n\n"
		@askdir-help
	)
)
(set #docu-which-languages "Wählen Sie die Sprache(n)")
(set #docu-which-languages-help @askoptions-help)
(set #docu-languages-default 2)
(set #docu-which-browser "Wählen Sie Ihren Browser aus")
(set #docu-which-browser-help
	(cat
		"\nWählen Sie den Browser, den Sie zum Lesen der AmigaOS 3.5 "
		"Dokumentation benutzen wollen. Das Programm, daß Sie "
		"auswöhlen wird als Standardprogramm im Piktogramm "
		"eingetragen.\n\n"
		@askfile-help
	)
)
(set #docu-run-nicer-fmt "Formatiere %s Anleitung. Bitte warten...")
(set #docu-drawer "AmigaOS 3.5 Anleitung")
))

; ****************************

(procedure @initcomplete _start _full _steps
	(set complete_start _start)
	(set complete_step (/ _full _steps))
	(complete _start)
)

(procedure @completer step
	(complete (+ complete_start (* complete_step step)))
)

; ****************************

(procedure @copydocu _start _step
	(@initcomplete _start _step 2)
	(if (IN docu-languages 0)
		(
			(set ct (tackon docu-target "AmigaOS 3.5 Manual"))
			(copyfiles
				(source "AmigaOS3.5:OS-Version3.5/AmigaOS 3.5 Manual")
				(dest ct)
				(all)
				(infos)
				(optional nofail force askuser)
			)
			(copyfiles
				(source "AmigaOS 3.5 Manual")
				(dest ct)
				(all)
				(infos)
				(optional nofail force askuser)
			)
		)
	)
	(@completer 1)
	(if (IN docu-languages 1)
		(
			(set ct (tackon docu-target "AmigaOS 3.5 Anleitung"))
			(copyfiles
				(source "AmigaOS3.5:OS-Version3.5/AmigaOS 3.5 Anleitung")
				(dest ct)
				(all)
				(infos)
				(optional nofail force askuser)
			)
			(copyfiles
				(source "AmigaOS 3.5 Anleitung")
				(dest ct)
				(all)
				(infos)
				(optional nofail force askuser)
			)
		)
	)
	(@completer 2)
)

(procedure @patchdocu _start _step
)

(procedure @donicer _lang _dir _name _args
	(set ct (tackon docu-target _lang))
	(set ct (tackon ct _dir))
	(rename (tackon ct "book-main.html") (tackon ct "book-main-old.html"))
	(set cmd
		(cat 
			"NicerDocu >>t:log FROM \"" 
			(tackon ct "book-main-old.html")
			"\" TO \""
			(tackon ct "book-main")
			"\" "
			_args
		)
	)
	(working (#docu-run-nicer-fmt _name))
	(run cmd)
	(delete (tackon ct "book-main-old.html"))
)

(procedure @doindex _lang _dir _name
	(set ct (tackon docu-target _lang))
	(set ct (tackon ct _dir))
	(rename (tackon ct "book-index.html") (tackon ct "book-index-old.html"))
	(set cmd
		(cat
			"NicerDocu FROM \""
			(tackon ct "book-index-old.html")
			"\" TO \""
			(tackon ct "book-index.html")
			"\" CHANGEINDEX"
		)
	)
	(working (#docu-run-nicer-fmt _name))
	(run cmd)
	(delete (tackon ct "book-index-old.html"))
)

(procedure @dotoc _lang _dir _name
	(set ct (tackon docu-target _lang))
	(set ct (tackon ct _dir))
	(rename (tackon ct "book-toc.html") (tackon ct "book-toc-old.html"))
	(set cmd
		(cat
			"NicerDocu FROM \""
			(tackon ct "book-toc-old.html")
			"\" TO \""
			(tackon ct "book-toc.html")
			"\" CHANGEINDEX"
		)
	)
	(working (#docu-run-nicer-fmt _name))
	(run cmd)
	(delete (tackon ct "book-toc-old.html"))
)

(procedure @donicerdocu _start _step
	(@initcomplete _start _step 10)
	(if (IN docu-languages 0)
		(
			(set buttons "CUT H2 PT=\"Previous\" ST=\"Next\" CT=\"Chapter\" TT=\"Top\"")
			(@donicer "AmigaOS 3.5 Manual" "arexx" "ARexx" buttons)
			(@doindex "AmigaOS 3.5 Manual" "arexx" "ARexx Index")
			(@dotoc "AmigaOS 3.5 Manual" "arexx" "ARexx Contents")
			(@completer 1)
			(@donicer "AmigaOS 3.5 Manual" "dos" "DOS" buttons)
			(@doindex "AmigaOS 3.5 Manual" "dos" "DOS Index")
			(@dotoc "AmigaOS 3.5 Manual" "dos" "DOS Contents")
			(@completer 2)
			(@donicer "AmigaOS 3.5 Manual" "harddisk" "Harddisk" buttons)
			(@doindex "AmigaOS 3.5 Manual" "harddisk" "Harddisk Index")
			(@dotoc "AmigaOS 3.5 Manual" "harddisk" "Harddisk Contents")
			(@completer 3)
			(@donicer "AmigaOS 3.5 Manual" "installation" "Installation" buttons)
			(@doindex "AmigaOS 3.5 Manual" "installation" "Installation Index")
			(@dotoc "AmigaOS 3.5 Manual" "installation" "Installation Contents")
			(@completer 4)
			(@donicer "AmigaOS 3.5 Manual" "workbench" "Workbench" buttons)
			(@doindex "AmigaOS 3.5 Manual" "workbench" "Workbench Index")
			(@dotoc "AmigaOS 3.5 Manual" "workbench" "Workbench Contents")
			(@completer 5)
			(tooltype 
				(dest (tackon docu-target "AmigaOS 3.5 Manual/index.html"))
				(setdefaulttool docu-browser)
			)
		)
	)
	(if (IN docu-languages 1)
		(
			(set buttons "CUT H2 PT=\"Zurück\" ST=\"Weiter\" CT=\"Kapitel\" TT=\"Hoch\"")
			(@donicer "AmigaOS 3.5 Anleitung" "arexx" "ARexx" buttons)
			(@doindex "AmigaOS 3.5 Anleitung" "arexx" "ARexx Index")
			(@dotoc "AmigaOS 3.5 Anleitung" "arexx" "ARexx Inhalt")
			(@completer 6)
			(@donicer "AmigaOS 3.5 Anleitung" "dos" "DOS" buttons)
			(@doindex "AmigaOS 3.5 Anleitung" "dos" "DOS Index")
			(@dotoc "AmigaOS 3.5 Anleitung" "dos" "DOS Context")
			(@completer 7)
			(@donicer "AmigaOS 3.5 Anleitung" "harddisk" "Festplatten" buttons)
			(@doindex "AmigaOS 3.5 Anleitung" "harddisk" "Festplatten Index")
			(@dotoc "AmigaOS 3.5 Anleitung" "harddisk" "Festplatten Inhalt")
			(@completer 8)
			(@donicer "AmigaOS 3.5 Anleitung" "installation" "Installation" buttons)
			(@doindex "AmigaOS 3.5 Anleitung" "installation" "Installation Index")
			(@dotoc "AmigaOS 3.5 Anleitung" "installation" "Installation Inhalt")
			(@completer 9)
			(@donicer "AmigaOS 3.5 Anleitung" "workbench" "Workbench" buttons)
			(@doindex "AmigaOS 3.5 Anleitung" "workbench" "Workbench Index")
			(@dotoc "AmigaOS 3.5 Anleitung" "workbench" "Workbench Inhalt")
			(@completer 10)
			(tooltype 
				(dest (tackon docu-target "AmigaOS 3.5 Anleitung/index.html"))
				(setdefaulttool docu-browser)
			)
		)
	)
)

; ****************************

(trace)
(message #docu-welcome (all))

(trace)
(set docu-target 
	(askdir 
		(prompt #docu-which-dir)
		(help #docu-which-dir-help)
		(default @default-dest)
		(back (retrace))
	)
)
(set @default-dest docu-target)
(trace)
(set docu-languages
	(askoptions
		(prompt #docu-which-languages)
		(help #docu-which-languages-help)
		(choices "English" "Deutsch")
		(default #docu-languages-default)
		(back (retrace))
	)
)
(trace)
(set docu-browser
	(askfile
		(prompt #docu-which-browser)
		(help #docu-which-browser-help)
		(default #docu-which-browser-default)
		(back (retrace))
	)
)

(@copydocu 10 20)

(@patchdocu 30 20)

(@donicerdocu 50 50)

(complete 100)

(if (BITAND docu-languages #docu-languages-default)
	(
		(set wbobj (tackon docu-target #docu-drawer))
		(openwbobject wbobj)
		(showwbobject (tackon wbobj "index.html"))
	)
)
