; Installation script for SkoEd

(set vernum (getversion "SkoEd"))
(set ver (/ vernum 65536))
(set rev (- vernum (* ver 65536) ) )

(welcome "Ready to install SkoEd V1.16")

(if (< (/ (getversion) 65536) 37)

    (
      (message "\nSkoEd is for OS v2.04 or greater\n")
      (exit (quiet))
    )
)

(
        ;get destination dir for executable
        (set mydest
                (askdir
                        (prompt "Select the directory to store SkoEd executable.")
                        (help   "The directory where you store the executable "
                                "should be easily accessible via WorkBench or CLI/Shell.\n\n"
                                @askfile-help
                        )
                        (default "C:")
                        (disk)
                )
        )

        (set @default-dest mydest)

        (set thedest (tackon mydest "SkoEd"))

        (copylib
                (prompt ("Copying SkoEd V%ld.%ld to %s." ver rev mydest))
                (help @copyfiles-help)
                (source "SkoEd")
                (dest mydest)
                (infos)
        )

        (set thedest (tackon mydest "Gadgets"))

        (copyfiles
                (prompt ("Copying Gadgets to %s" mydest))
                (help @copyfiles-help)
                (source "Gadgets/")
                (dest thedest)
                (infos)
                (all)
        )

        (set thedest (tackon mydest "SkoEd.Config"))

        (if (= 1 (exists thedest))
            (
               (if (= 1
                      (askbool
                         (prompt "SkoEd.Config found. Do you wish to overwrite it?\n\n")
                         (help @askbool-help)
                         (default 1)
                         (choices "Copy" "NO Copy")
                      )
                   )
                   (copyfiles
                       (prompt ("Copying SkoEd.Config to %s." mydest))
                       (help @copyfiles-help)
                       (source "SkoEd.Config")
                       (dest mydest)
                   )

               )
            )
            (copyfiles
                (prompt ("Copying SkoEd.Config to %s." mydest))
                (help @copyfiles-help)
                (source "SkoEd.Config")
                (dest mydest)
            )
        )

        (set thedest (tackon mydest "SkoEd.Macro"))

        (if (= 1 (exists thedest))
            (
               (if (= 1
                      (askbool
                         (prompt "SkoEd.Macro found. Do you wish to overwrite it?\n\n")
                         (help @askbool-help)
                         (default 1)
                         (choices "Copy" "NO Copy")
                      )
                   )
                   (copyfiles
                           (prompt ("Copying SkoEd.Macro to %s." mydest))
                           (help @copyfiles-help)
                           (source "SkoEd.Macro")
                           (dest mydest)
                   )
               )
            )
            (copyfiles
                    (prompt ("Copying SkoEd.Macro to %s." mydest))
                    (help @copyfiles-help)
                    (source "SkoEd.Macro")
                    (dest mydest)
            )
        )

)
(run "makedir >NIL: ENV:SkoEd")
(run "makedir >NIL: ENVARC:SkoEd")

