; Installation script for XES
; Copyright (c) 1995 Fergus Duniho

(transcript "Installing the XDME Excelsior Suite ...")

(set @default-dest (getassign "XES"))
(if (> (strlen @default-dest) 0)
    (
        (set response
            (askchoice
                (prompt
                    "Because I sometimes remove stuff from XES, it is best "
                    "to delete your present XES installation before the "
                    "installation of the present version commences.  Do "
                    "you wish to delete it?"
                )
                (help @askchoice-help)
                (choices "Yes" "No")
            )
        )
        (if (= response 0)
            (run "delete XES:#? ALL")
        )
    )
    (
        (set @default-dest "Work:")
        (set appdir
            (askdir
                (prompt "In which drawer should the XES drawer reside?")
                (help @askdir-help)
                (default @default-dest)
            )
        )
        (set @default-dest (tackon appdir "XES"))

        (makedir @default-dest
            (infos)
            (prompt "Creating XES directory")
        )
        (makeassign "XES" @default-dest)
        ; Make changes to the startup sequence
        (working "Modifying the user-startup")
        (startup "XES"
            (prompt "Adding XES: assignment to user-startup")
            (help @startup-help)
            (command "; The XDME Excelsior Suite\n")
            (command "; Copyright (c) 1995 Fergus Duniho.\n")
            (command (cat "Assign XES: " @default-dest "\n"))
        )
    )
)

(makedir (tackon @default-dest "S")
    (prompt "Creating S directory")
)
(makedir (tackon @default-dest "GUI")
    (prompt "Creating GUI directory")
)
(makedir (tackon @default-dest "Rexx")
    (prompt "Creating Rexx directory")
)
(makedir (tackon @default-dest "Docs")
    (infos)
    (prompt "Creating Docs directory")
)

(copyfiles
    (prompt "Copying XDME scripts")
    (help @copyfiles-help)
    (source "S/")
    (dest (tackon @default-dest "S"))
    (confirm)
    (files)
    (all)
)

(copyfiles
    (prompt "Copying Graphical User Interfaces")
    (help @copyfiles-help)
    (source "GUI/")
    (dest (tackon @default-dest "GUI"))
    (confirm)
    (files)
    (all)
)

(copyfiles
    (prompt "Copying Documentation")
    (help @copyfiles-help)
    (source "Docs/")
    (dest (tackon @default-dest "Docs"))
    (infos)
    (confirm)
    (all)
)

(copyfiles
    (prompt "Copying ARexx Scripts")
    (help @copyfiles-help)
    (source "Rexx/")
    (dest (tackon @default-dest "Rexx"))
    (infos)
    (confirm)
    (all)
)

(set @default-dest
    (askdir
        (prompt "Install Paginate where?")
        (help @askdir-help)
        (default "C:")
    )
)

(copyfiles
    (prompt "Copying utility programs")
    (help @copyfiles-help)
    (source "C/Paginate")
    (dest @default-dest)
    (confirm)
)

(set response
    (askchoice
        (prompt
            "To make use of XES, your .edrc file must contain a line "
            "which reads: source XES:S/xes.xrc.  If you have your own "
            "macros, keymappings, or settings in your .edrc file, then "
            "you should just add this line to it.  Append it to get the "
            "full benefit of XES, or prepend to give priority to what is "
            "already in your .edrc file.  If you don't have an .erdc file, "
            "or if you are just using one from a previous version of XES, "
            "you should just write a new .edrc file."
        )
        (help @askchoice-help)
        (choices "Append to .edrc" "Prepend to .edrc" "Write new .edrc")
    )
)

(set edrc
    (tackon
        (askdir
            (prompt "In which drawer does (or will) your .edrc file reside?")
            (help @askdir-help)
            (default "S:")
        )
        ".edrc"
    )
)

(if (= response 0)
    (run (cat "echo >>" edrc " source XES:S/xes.xrc"))
)

(if (= response 1) (
    (run (cat "copy " edrc " t:"))
    (run (cat "echo >" edrc " source XES:S/xes.xrc"))
    (run (cat "type >>" edrc " t:.edrc"))
))

(if (= response 2)
    (run (cat "echo >" edrc " source XES:S/xes.xrc"))
)

(message
    "The XDME Excelsior Suite has been successfully installed. "
    "It will be available to you the next time you use XDME."
)

(exit (quiet))
