; $VER: Installation script for MUIFuzzyShadows 1.0 (01. April 2000)
; © Michael Merkel
; Created with GoldED 6.15


; -----------------------------------------------------------------------------
; some default values...

(set #prgname		"MUIFuzzyShadows")						; program name.
(set #dest			"PageStream:Scripts")				    ; path for installation
(set #readme		(cat #prgname ".readme"))				; ReadME Datei

(set @default-dest #dest)

; -----------------------------------------------------------------------------
; check if we are running under correct OS
(if (< (/ (getversion) 65536) 39)
    (
        (abort "Incorrect OS version (software requires OS 39 or better )!")
    )
)

; -----------------------------------------------------------------------------
; error handling
(onerror
    (if (> @ioerr 0)
        (
			(message
                ("An error has occurred during installation. Please check the log file to understand the error.")
            )
        )
    )
    (exit (quiet))
)

; -----------------------------------------------------------------------------
; set installation mode
(set #installmode
    (askbool
        (prompt "Choose the installation mode:")
        (help @askbool-help)
        (choices
            "Install"
            "Uninstall"
        )
        (default 1)
    )
)

(if (= #installmode 1)
; -----------------------------------------------------------------------------
; 	normal installation
    (
        (welcome)
        ; --- insert your code below ---
		(message "Welcome to the installation of " #prgname "\n")
		(set #dest
			(askdir
				(prompt ("Where should \"%s\" be installed?\nA directory called \"%s\" will be created there" #prgname #prgname))
				(help @askdir-help)
				(default @default-dest)
			)
		)
		(set #dest 	(tackon #dest #prgname))
		(set @default-dest #dest)

		(if (exists #dest (noreq))
			(message #prgname " will be installed in the path"
					 "\n\n\"" #dest "\"\n")

			(
				(message #prgname " will be installed in the path"
						 "\n\n\"" #dest "\"\n"
						 "\nA new directory will be created")
				(makedir #dest (infos))
			)
		)

		(set #prog_path		(cat (tackon #dest #prgname) ".rexx"))
		(set #msg_inst		(cat ("\"%s\" is now installed in \"%s\".\n" #prgname #dest)
							" If you want to use this script inside PageStreams script palette"
							" you have to do it in this way:\n\n"
							"1. open the script palette\n"
							"2. select NEW from the script palette menu\n"
							("3. insert a name for the entry (like %s)\n" #prgname)
							"4. in the SCRIPT field enter:\n"
							("        rx \"%s\"\n" #prog_path)
							"   and press OK\n"
							"5. select SAVE from the scrip palette menu\n"))

		(if (exists #prog_path (noreq))
			(
				(set 	#goon
						(askbool (prompt "Script already installed. Do you want to install it anyway?")
								 (help "This will overwrite the script AND the default prefs file!"))
				)
				(if (= #goon 0)
					(exit "Installation cancelled. Script already installed." (quiet))
				)
			)
		)

		(copyfiles
			(source "")
			(dest   #dest)
		    (infos)
		    (files)
			(pattern "~(Install#?|PGSScriptPathUpdater)")
		)
		(set #pathUpdater ("pgsScriptPathUpdater \"%s.rexx\" \"%s/%s.rexx\" \"%s\" \"pgsInstallDir =\"" #prgname #dest #prgname #dest))
;		(message "command:\n" #pathUpdater "")
		(run #pathUpdater)
		(message #msg_inst)

        ; --- end of your code ---
        (exit)
    )

; -----------------------------------------------------------------------------
; 	uninstall application
    (
        ; --- insert your code below ---
        ; -- end of your code ---

        (message "Uninstallation completed.")
        (exit (quiet))
    )
)
