; Install mNews v1.2b and NList*.mc? libraries
; $VER 1.0
;
; -- Happy language strings --
;
; ENGLISH ----------------------------------
(procedure english (
  (set MSG_INTRO        "This script will install mNews 1.2b\nand the required NList libraries.")
  (set MSG_PROG_DEST    "Where would you like mNews to reside?\n(No directory will be created.)")
  (set MSG_GUIDE_DEST   "Where do you want mNews.guide to be?")
  (set MSG_NLIST_VER1   "You have NList libraries version %d.%d\n")
  (set MSG_NLIST_VER2   "Installing version %d.%d.")
  (set MSG_NLIST_NONE   "You don't have the NList libraries.\nInstalling version %d.%d.")
  (set MSG_DONE         "Installation complete.  Have a lovely day.")
  (set MSG_COPY         "Copying %s to %s.")
  (set HELP_GET_DIR     "This is where the executable and\n the group files will reside.")
  (set HELP_GUIDE_DIR   "Where the mNews.guide file will be.")
  (set HELP_NLIST_EXIST "Copy the included versions of NList\nover the existing ones.")
))
; end ENGLISH ------------------------------
;
; MAIN  ------------------------------------
;
(if (= @language "english") (english))

(set MNEWS_DEST        "AmiTCP:")
(set GUIDE_DEST        "AmiTCP:")
(set NLIST_CUR_LIB     "MUI:Libs/MUI/NList.mcc")
(set NLIST_NEW_LIB     "/Libs/NList.mcc")
(set NLIST_DEST        "MUI:Libs/MUI")
(set NLIST_FILES       "/Libs")

(set MNEWS_EXEC        "/C/mNews1.2b")
(set GUIDE_EXEC        "/C/mNews.guide")

(message (MSG_INTRO))

(set MNEWS_DEST (askdir ((prompt (MSG_PROG_DEST))
                        (default MNEWS_DEST)
                        (help HELP_GET_DIR)
                        (newpath)))
)

(set @default-dest MNEWS_DEST)

(set GUIDE_DEST (askdir ((prompt (MSG_GUIDE_DEST))
                         (default GUIDE_DEST)
                         (help HELP_GUIDE_DIR)
                         (newpath)))
)

;---- copy the executable and guide file along with
;---- the icons
(copyfiles (source MNEWS_EXEC)
           (dest MNEWS_DEST)
           (infos)
)

(copyfiles (source GUIDE_EXEC)
           (dest GUIDE_DEST)
           (infos)
)

;---- get the library versions of NList.mcc

(set NEW_VER (getversion NLIST_NEW_LIB))
(set NEW_REV (- NEW_VER (* NEW_VER 65536)))

;---- see if the NList libraries exist
(if (= 0 (exists NLIST_CUR_LIB (NOREQ))) (
    (message (MSG_NLIST_NONE NEW_VER NEW_REV))
    (copyfiles (source NLIST_FILES)
               (dest NLIST_DEST)
               (all)
               (files)
    )
  )
;-- else
  (
    (set CUR_VER (getversion NLIST_CUR_LIB))
    (set CUR_REV (- CUR_VER (* CUR_VER 65536)))

    (if (= 1 (askbool (prompt (MSG_NLIST_VER1 CUR_VER CUR_REV) (MSG_NLIST_VER2 NEW_VER NEW_REV))
                      (help HELP_NLIST_EXIST))) (
        (copyfiles (source NLIST_FILES)
                   (dest NLIST_DEST)
                   (all)
                   (files)
        )
      )
    )
  )
)
