; $VER: 1.0


(delopts "oknodelete" "force" "askuser")
(complete 0)

(if (exists "GOLDED:" (NOREQ))

    (
        (set vernum (getversion "golded:golded"))

        (set ver (/ vernum 65536))
        (set rev (- vernum (* ver 65536)))

        (set version (+ (* 10 ver) rev))

        (if (< version 30)

            (
                (message "\nSorry, GoldED 3.0.1 or better required")
                (exit (quiet))
            )
        )

        (message (cat "\n"

            "GolDICE C programmers package               \n"
            "                                            \n"
            "1995 Stefan Berendes                       \n"
            "      BERENDES@reze-1.rz.rwth-aachen.de     \n"
            "                                            \n"
            "GoldED Release 3.0.1+ required.             \n"
            "                                            \n"
            "This package is NOT 'freely distributable'. \n"
            "Please have a look at the licence file      \n"
            "before using this software. Thank you.      \n"
        ))

        (copyfiles

            (source "arexx")
            (dest "GOLDED:arexx")
            (all)
        )

        (copyfiles

            (source "presets")
            (dest "GoldED:presets")
            (all)
        )

        (complete 50)

        ; install QuickStarter

        (set progname (askchoice

            (prompt " Choose a name for the QuickStarter")
            (help   (cat "\n"

                " This is a modified version of the QuickStarter.   \n"
                " Please replace the one that came with the GoldED  \n"
                " distribution, ie select the same dir and name.    \n"))

            (choices 

                "GED"
                "ED"
                "(other)"
            )

            (default 1)
        ))

        (complete 60)

        (if (= progname 0) (set name "GED"))
        (if (= progname 1) (set name "ED" ))

        (if (= progname 2)

            (set name (askstring

                (prompt " Enter a name:\n")
                (help (cat "\n"
                    " Any name (GED, ED, ...) will do. Existing files are \n"
                    " overwritten. If you decide for 'ED', the original ED\n"
                    " is replaced.                                        \n"))

                (default "ED")
            ))
        )

        (set comdir (askdir

            (prompt (cat "\n"
                " Now let's place the QuickStarter within a valid\n"
                " command directory. Select a directory:         \n"))
            (help   (cat "\n"
                " You should select one of these directories if you\n"
                " want to run the editor simply by typing its name,\n"
                " no matter what your current path is:             \n"
                "                                                  \n"
                " SYS:C, SYS:TOOLS, SYS:UTILITIES or SYS:SYSTEM    \n"
                "                                                  \n"
                " If you choose ED as default name, you must either\n"
                " place the quick starter into c: or delete the old\n"
                " ED from c: to prevent unpredictable behaviour.   \n"))

            (default "C:")
        ))

        (copyfiles 

            (source  "quickstarter/ed")
            (dest     comdir)
            (newname  name)
        )


        (complete 75)

        (copyfiles

            (source "quickstarter")
            (dest   "GOLDED:tools/source/new_ed")
            (all)
        )

        (complete 100)

        (message "\nInstallation complete. Have fun :-)")

        (run (cat "gx FORCE MACRO=\"" (tackon (pathonly @icon) "auto.ged\"")))
    )

    (message (cat "\n"

        "Please install GoldED before attempting to\n"
        "install this package.                     \n"))
)
(exit (quiet))

(welcome)
