
; $VER: Easy Money Installation Script v1.0 (19/08/1998)
; Script written by Allan Savage © 1998.

; Set up variables

(set @error-msg "An unexpected error has occured. The installation has been aborted.")
(set #done 0)


; Get directory to install Easy Money in

(until (= #done 1) (
		(set #update 0)

		(set #inst_dir 
			(askdir
				(prompt	"Please select the drawer where Easy Money should be installed. "
							"(A drawer called Easy_Money will be created if it does not already exist)"
				)
				(help @askdir-help)
				(default @default-dest)
			)
		)
		(set @default-dest #inst_dir)
		(set #inst_dir (tackon #inst_dir "Easy_Money"))

		; Check if directory exists
		(set #flag (exists #inst_dir (noreq)))

		; It does not exist
		(if (= #flag 0) (
				(makedir #inst_dir)
				(set #prog_dir #inst_dir)
				(set #prog_name (tackon #prog_dir "Easy_Money"))
				(set #done 1)
			)
		)

		; It exists already
		(if (= #flag 2) (
				(set #prog_dir #inst_dir)
				(set #prog_name (tackon #prog_dir "Easy_Money"))
				(if (= 1 (exists #prog_name (noreq))) (
						(set #update 1)
					) (
						(set #done 1)
					)
				)
			)
		)

		; A file called Easy_Money exists
		(if (= #flag 1) (
				(set #prog_name #inst_dir)
				(set #prog_dir (pathonly #inst_dir))
				(set #update 1)
			)
		)

		(if (= #update 1) (
				(if (= @user-level 2) (
						(set #done
							(askbool
								(prompt
									"A copy of Easy Money has been detected in the drawer \"" #prog_dir
									"\".  Would you like to update this copy or choose another drawer?"
								)
								(help
									"If you select \"Update\" your current copy of Easy Money will be replaced, "
									"even if it is a newer version than the one you are replacing it with.  "
									"You will be given the choice of creating a backup of the current version "
									"before it is replaced.\n\n"
									"If you select \"Choose Again\" you will be able to choose an alternative "
									"directory to install the new copy of Easy Money."
								)
								(default 1)
								(choices "Update" "Choose Again")
							)
						)
					) (
						(set #done 1)
					)
				)
			)
		)
	)
)

(set @default-dest #prog_dir)
(complete 10)

(set #backup 0)
(if (= #update 1) (
		(if (= @user-level 2) (
				(set #backup
					(askbool
						(prompt
							"Would you like to backup the currently installed version of Easy Money "
							"before installing the new one?"
						)
						(help
							"If you select \"Backup\" your current copy of Easy Money will be renamed "
							"before it is replaced.  If you have any old backups then they will be lost.\n\n"
							"If you select \"Replace\" your current copy will just be replaced by the new "
							"one,  even if the new copy is an older version."
						)
						(default 1)
						(choices "Backup" "Replace")
					)
				)
			) (
				(set #backup 1)
			)
		)
	)
)

(complete 20)

(if (= #backup 1) (
		(rename
			(tackon #prog_dir "Easy_Money")
			(tackon #prog_dir "Easy_Money.BAK")
			(prompt "Renaming Easy Money.")
		)
		(complete 30)
		(rename
			(tackon #prog_dir "EM_Calc")
			(tackon #prog_dir "EM_Calc.BAK")
			(prompt "Renaming Calculator.")
		)
		(complete 40)
		(rename
			(tackon #prog_dir "Manual.Guide")
			(tackon #prog_dir "Manual.Guide.BAK")
			(prompt "Renaming Manual.")
		)
		(complete 50)
		(rename
			(tackon #prog_dir "Demo_File.EMNY")
			(tackon #prog_dir "Demo_File.EMNY.BAK")
			(prompt "Renaming demo file.")
		)
	)
)

(complete 60)

(copyfiles
	(prompt "Copying files now.")
	(help @copyfiles-help)
	(source "")
	(dest #prog_dir)
	(choices "Icon" "Demo_file.EMNY" "Easy_Money" "EM_Calc" "Manual.Guide")
	(confirm)
	(infos)
)

(complete 100)
