; $VER: Install InterWord (Dansk version) (19.10.92)

; Reset complete %
(complete 0)


; Set our path variables.
(set sourcepath "InterWord_Install:")
(set @default-dest "")

; Required harddisk space.
(set diskspace 2736000)

; Say HI!
(welcome)

; Get user-level.
(set @user-level 1)

; Recognize OS version.
(set osver (/ (getversion) 65535))



; Ask for floppy or Harddisk installation

(set floppy 0)
(set harddrive 0)
(set availmem (database "total-mem:"))

(set installto
				(askchoice
					(prompt "Where do you want to install InterWord ?")

					(help "You have to chose if you want to install InterWord to Hard disk "
							"or to Floppy disk. If you want to install to floppy disk you will "
							"need 4 empty disks.")

					(choices "Hard disk"
								"Floppy Disk")

					(default 0)
				)
)

(if(= installto 0)
	(
	;  Install to Harddisk
	(set @default-dest
		(askdir
			(prompt  "On which hard disk or in which drawer do you want to install InterWord ? "
						"A drawer with the name 'InterWord' will be made."
			)
			(help	 "You have to choose on which hard disk or in which drawer you want to install InterWord. "
						"Note, a drawer with the name 'InterWord' will be created by the installer."
			)
			(default @default-dest)
		)
	)
	;  Check free space
	(set spaceavail (getdiskspace @default-dest))
	(if (< spaceavail diskspace)
		(if (askbool
			(prompt  "\n\nYou need to have at least 2.7 MB free space on the hard disk.")
			(help	 "You need to have at least 2.7 MB free space on your hard disk to install Interword. "
						"There is currently not enough free space, so you have to chose if you want "
						"to continue or you want to delete some files and start the installation again."
			)
			(choices "Abort" "Continue"))
			(abort "InterWord installation Aborted")
		)
	)
	; Check that directory InterWord doesn't exist already.
	(set @default-dest (tackon @default-dest "InterWord"))
	(if (exists @default-dest)
		(if (askbool
				(prompt  "\n\n\n\n" @default-dest " drawer already exists. Do you want to abort ?")
				(help	 "InterWord seems to be installed on your system. You have to chose if you want "
							"to install this version and overwrite the current version. "
							"You could move the currently installed version to another location, and start the "
							"installation again.")
			 )
				(abort "InterWord Installation aborted")
		 )
	)
	(complete 20)

	; Creating directories in destination drawer.
	(makedir @default-dest (infos))
	(set temp (tackon @default-dest "Doc"))
	(makedir temp (infos))
	(set temp (tackon @default-dest "Printers"))
	(makedir temp)
	(set temp (tackon @default-dest "Dict"))
	(makedir temp)

	(complete 30)
	;  Copy lhx to ram:
	(copyfiles
					(source  "InterWord_Install:lhx")
					(dest	 "ram:")
	)
	;  Start copying
	(copyfiles
					(prompt  "Copying InterWord...")
					(help	 "This Will copy the InterWord main program")
					(source  "InterWord_Install:InterWord")
					(infos)
					(dest	 @default-dest)
	)

	(copyfiles
					(prompt  "Copying InterWord online help")
					(help	 "This Will copy the InterWord main program")
					(source  "InterWord_Install:InterWord.guide")
					(infos)
					(dest	 @default-dest)
	)
	(copyfiles
					(prompt  "Copying InterWord PrinterManager...")
					(help	 "This Will copy the InterWord main program")
					(source  "InterWord_Install:isc")
					(infos)
					(dest	 @default-dest)
	)

	(copylib
				(prompt	"Copying AmigaGuide.library...")
				(help		"This library is needed to use the online help in InterWord")
				(source	"InterWord_Install:libs/amigaguide.library")
				(dest		"libs:")
				(confirm)
	)

	(complete 40)
	; copy dict
	(set temp (tackon @default-dest "Dict"))
	(copyfiles
					(prompt  "Copying dictionary...")
					(help	 "This Will copy a part of the dictionary")
					(source  "InterWord_Install:dict")
					(all)
					(infos)
					(dest	 temp)
	)
	(complete 50)
	; copy doc
	(set temp (tackon @default-dest "Doc"))
	(copyfiles
					(prompt  "Copying documents...")
					(help	 "This Will copy the examples")
					(source  "InterWord_Install:doc")
					(all)
					(infos)
					(dest	 temp)
	)

	; copy printers
	(set temp (tackon @default-dest "Printers"))
	(copyfiles
					(prompt  "Copying printers...")
					(help	 "This Will copy the printerdrivers")
					(source  "InterWord_Install:printers")
					(all)
					(infos)
					(dest	 temp)
	)
	(complete 60)
	(set temp (tackon @default-dest "Dict/"))
	(copyfiles
					(source  "InterWord_Install:setup.hd")
					(dest	 temp)
					(newname "setup")
	)
	(set @execute-dir "InterWord_Install2:")
	(set unpackcommand (cat "ram:lhx -x x InterWord_Install2:uk_dict_2.lha " @default-dest "/dict/"))
	(run
			unpackcommand
			(prompt  "Unpacking part one of the dictionary")
			(help		"This will unpack a part of the dictionary"
			  			"to the your hard disk"
			)
			(confirm)
	)

	(complete 70)
	(working	 "Unpacking part 2 of the dictionary")
	(set @execute-dir "InterWord_Install2:")
	(set unpackcommand (cat "ram:lhx -x x InterWord_Install2:uk_dict_3.lha " @default-dest "/dict/"))
	(run
			unpackcommand
			(prompt  "Unpacking part two of the dictionary")
			(help		"This will unpack a part of the dictionary "
			  			"to your hard disk."
			)
			(confirm)
	)

	(complete 80)
	(working	 "Unpacking part 3 of the dictionary")
	(set @execute-dir "InterWord_Install2:")
	(set unpackcommand (cat "ram:lhx -x x InterWord_Install2:uk_dict_4.lha " @default-dest "/dict/"))
	(run
			unpackcommand
			(prompt  "UnPacking part three of the dictionary")
			(help		"This will unpack a part of the dictionary "
			  			"to your hard disk"
			)
			(confirm)
	)

	(complete 95)
	(startup "InterWord"
		(prompt  "Adding Interword Assignment to startup")
		(help	 "This will add the interword assignment to your startup-sequence.")
		(command "Assign InterWord: " @default-dest "\n")
	)

	(delete "ram:lhx")
	(delete "ram:format")
	(message	"Installation is now complete\n\n"
				"The InterWord assignment won't take effect until you re-boot. Select Proceed to reset your Amiga or Abort to return to Workbench."
		(confirm)
	)
	(run ("interword_install:C/Reboot"))

	)

) ;end of harddisk install

(if(= installto 1)
	(
		(copyfiles
						(source  "InterWord_Install:system/format")
						(dest	 "ram:")
		)
		;  Copy lhx to ram:
		(copyfiles
						(source  "InterWord_Install:lhx")
						(dest	 "ram:")
		)

		;  Install to floppy
		(textfile
						(dest "ram:nl_file")
						(append "\n")
		)
		;  Formatere den første ordbogs diskette og pak 1. Del ud
		(run
			("ram:format <ram:nl_file drive DF0: name InterWord_2")
			(prompt	"Insert New/empty disk in df0:\n"
						"Wait until the drive light goes off, then press 'Proceed'\n\n"
						"!!! WARRNING !!!\n\nEverything on this disk will be deleted !"
						"\n\nThe name of the disk will be 'InterWord_2'"
			)
			(help		"This will format the disk in df0:")
			(confirm)
		)

		(copyfiles
				(source "InterWord_Install2:uk_dict_2.lha")
				(dest	"ram:")
				(safe)
		)

		(run
			("ram:lhx -x x ram:uk_dict_2.lha InterWord_2:")
			(prompt  "Insert disk 'InterWord_2' in any drive\n\n"
			  			"UnPacking a part of the dictionary"
			)
			(help		"This will unpack a part of the dictionary "
			  			"to the previous formated disk"
			)
			(confirm)
		)
		(delete "ram:uk_dict_2.lha")

		;
		;  Formatere disk og udpakker en del af ordbogen
		;
		(run
			("ram:format <ram:nl_file drive DF0: name InterWord_3")
			(prompt	"Insert New/empty disk in df0:\n"
						"Wait until the drive light goes off, then press 'Proceed'\n\n"
						"!!! WARRNING !!!\n\nEverything on this disk will be deleted !"
						"\n\nThe name of the disk will be 'InterWord_3'"
			)
			(help		"This will format the disk in df0:")
			(confirm)

		)
		(copyfiles
			(source "InterWord_Install2:uk_dict_3.lha")
			(dest	"ram:")
			(safe)
		)
		(run
			("ram:lhx -x x ram:uk_dict_3.lha InterWord_3:")
			(prompt  "UnPacking a part of the dictionary")
			(help		"This will unpack a part of the dictionary "
						"to the previous formated disk"
		)
						(confirm)
		)
		(delete "ram:uk_dict_3.lha")

		;
		;  Formatere disk og udpakker en del af ordbogen
		;
		(run
			("ram:format <ram:nl_file drive DF0: name InterWord_4")
			(prompt	"Insert New/empty disk in df0:\n"
						"Wait until the drive light goes off, then press 'Proceed'\n\n"
						"!!! WARRNING !!!\n\nEverything on this disk will be deleted !"
						"\n\nThe name of the disk will be 'InterWord_4'"
			)
			(help		"This will format the disk in df0:")
			(confirm)

		)
		(copyfiles
			(source "InterWord_Install2:uk_dict_4.lha")
			(dest	"ram:")
			(safe)
		)
		(run
			("ram:lhx -x x ram:uk_dict_4.lha InterWord_4:")
			(prompt  "UnPacking a part of the dictionary")
			(help		"This will unpack a part of the dictionary "
						"to the previous formated disk"
			)
			(confirm)
		)
		(delete "ram:uk_dict_4.lha")
		(delete "ram:lhx")
		(delete "ram:format")
		(delete "ram:nl_file")

		(message	"Installation is now complete")
		(run ("interword_install:C/Reboot"))

	)
) ; end of floppy install

(exit)
