;==========================================================
; For now, only experts

(complete 0)
(welcome "I'm going to install \"DataProc\". \"DataProc\" is a processor "
         "for the analysis of experimental data and may be used at best "
         "together with \"TeX\" and \"GNUPLOT\" - both free software, but "
         "not included in this package. Anyhow, \"DataProc\" does NOT "
         "rely on those packages.\n"
         "If you encounter problems, contact:\n\n"
         "Internet: mgr@asgard.bo.open.de\n"
         "    FIDO: Lars Hanke 2:243/4802.22\n\n"
         "\"DataProc\" is copyrighted © 1990-1993 by MGR-Software, Asgard - "
         "Lars Hanke and distributed under the concept of SHAREWARE."
)

(set @user-level 2)

(set @root (pathonly @icon))

;==========================================================
; Check where we are and if we might be complete

(if (NOT (exists (tackon @root "DataProc")))
   (abort "Sorry, the program is missing!"))

(if (NOT (exists (tackon @root "Read.Me")))
  (abort "I won't install without the \"Read.Me\" file."))

(if (NOT (exists (tackon @root "docs/Register.txt")))(
  (set s1 (cat "This software is SHAREWARE. Unfortunately your distribution package "
               "does not contain the registration form. I cannot install the package. "
               "Give me a note and I will gladly replace the package:\n\n"
               "MGR-Software, Asgard\nLars Hanke\nSchlachthofstr. 67\n44649 Herne\n\n"
               "or\n\n    FIDO: Lars Hanke 2:243/4802.22\nInterNet: mgr@asgard.bo.open.de"
          ))
  (abort s1)))

(if (NOT (exists (tackon @root "SCalc"))) (if (NOT (askbool
  (prompt "The SCalc program is missing. Continue anyway?")
  ( help (cat "SCalc is a scientific calculator useful to learn the \"DataProc\" "
        "mathematics as well as to do stand alone computations."))
  (default 0) (choices "Continue" "Abort")))
  (abort ("See the Read.Me file, where to get the complete package."))))

;==========================================================
; Now that we now that the most important things are available
; try an installation

(if (exists "TeX:bin" (noreq)) (set @dest "TeX:bin") (set @dest @default-dest))

(set executes (askdir (prompt "Destination path:")
        (help "Path to put the \"DataProc\" executables")
        (default @dest) (newpath)))

(complete 14)

(copyfiles (source (tackon @root "DataProc"))
           (dest executes) (infos))
(complete 27)
(if (exists (tackon @root "SCalc")) (copyfiles (source (tackon @root "SCalc"))
           (dest executes) (infos) ))
(complete 30)
(copyfiles (source (tackon @root "Read.Me"))
           (dest executes) (infos))

;==========================================================
; Change default tools to "more" instead of "most"

(if (exists (tackon executes "Read.Me.info") (noreq))
    (tooltype (prompt "Working on icons ...")
              (help   "The original distribution uses \"Most\" to view texts, "
                      "but this archive has to get along with \"More\"!")
              (dest (tackon executes "Read.Me"))
              (setdefaulttool "more")))

;==========================================================
; Check languages to install

(if (exists "LOCALE:catalogs" (noreq))

   ((set langs
     (askoptions
        (prompt "Which languages would you like to install?")
        (choices "English"
                 "Deutsch"
                 "Françias")
        (help "According to the selected language in the preferences messages "
              "and online help will appear in that language, if you install it "
              "and the translation is available. Too be sure the documentation "
              "may not be fully translated. "
              "Note that you need Workbench 2.1 or higher to profit from the "
              "localization.")
     )
   )

   (if (IN langs 1)
     (copyfiles (source (tackon @root "catalogs/deutsch"))
                (pattern "DataProc.catalog")
                (dest "LOCALE:catalogs/deutsch"))
   )
   (if (IN langs 2)
     (copyfiles (source (tackon @root "catalogs/français"))
                (pattern "DataProc.catalog")
                (dest "LOCALE:catalogs/français"))
   ))
)

;==========================================================
; Now install the documentation

(if (exists "MAN:" (noreq)) (set @dest "MAN:")
  (if (exists "TeX:docs" (noreq)) (set @dest "TeX:docs")
       (set @dest (tackon executes "docs"))))

(set docs (askdir (prompt "Where do you want me to put the documentation?")
   (help "Supply a name for the documentation path. Concerning details, you will be asked later.")
   (default @dest) (newpath)))
(complete 34)
(if (exists (tackon docs "DataProc.guide") (noreq))
    (delete (tackon docs "DataProc.guide") (optional force)))
(if (exists (tackon docs "DataProc.guide.info") (noreq))
    (delete (tackon docs "DataProc.guide.info") (optional force)))
(if (exists (tackon docs "Register.txt") (noreq))
    (delete (tackon docs "Register.txt") (optional force)))
(if (exists (tackon docs "Register.txt.info") (noreq))
    (delete (tackon docs "Register.txt.info") (optional force)))
(copyfiles (source (tackon @root "docs"))
           (pattern "DataProc.guide#?")
           (dest docs) (infos))
(complete 40)
(copyfiles (source (tackon @root "docs"))
           (pattern "Register.txt#?")
           (dest docs))

(if (exists (tackon @root "docs/DataProc.dvi"))
   (if (askbool (prompt "Install the TeX \".dvi\" File?")
                (help "If you have a DVI printer that is usually shipped with a TeX "
                      "implementation, you can print this file for a documentation "
                      "on paper.")
                (default 1))
      ((if (exists (tackon docs "DataProc.dvi") (noreq))
        (delete (tackon docs "DataProc.dvi") (optional force)))
      (if (exists (tackon docs "DataProc.dvi.info") (noreq))
        (delete (tackon docs "DataProc.dvi.info") (optional force)))
      (copyfiles (source (tackon @root "docs"))
                 (pattern "DataProc.dvi#?")
                 (dest docs)))
   )
)
(complete 48)
(if (askbool (prompt "Install TeXInfo file?")
   (help "The AmigaGuide© hypertext documentation is already installed "
         "and maybe you've just installed the \".dvi\" file as well. "
         "The TeXInfo is the source of both and might still be converted "
         "to other formats of your preference.")
   (default 0))
   ((if (exists (tackon docs "DataProc.texinfo") (noreq))
     (delete (tackon docs "DataProc.texinfo") (optional force)))
   (copyfiles (source (tackon @root "docs/DataProc.texinfo"))
              (dest docs)))
)

(complete 69)
;==========================================================
; Change default tools to "more" instead of "most"

(if (exists (tackon docs "Register.txt.info") (noreq))
    (tooltype (prompt "Working on icons ...")
              (help   "The original distribution uses \"Most\" to view texts, "
                      "but this archive has to get along with \"More\"!")
              (dest (tackon docs "Register.txt"))
              (setdefaulttool "more")))


;==========================================================
; Now install the demos

(if (= 2 (exists (tackon @root "demo") (noreq)))
   ((set @dest (tackon docs "demo")) (if (askbool (prompt "Install the demos?")
    (help "For Novices I would always recommend demos.")
    (default 1))(
      (if (NOT (exists "ENV:DP_KEY" (noreq))) (set @dest executes))
      (set demo (askdir (prompt "Where would you like the demos?")
                        (help "Select the destination directory for the demo files. "
                              "\nNOTE: Unregistered users MUST have the demo files "
                              "in the same directory as \"DataProc\" itself!")
                        (default @dest) (newpath)))
      (copyfiles (source (tackon @root "demo"))
                 (dest demo) (all))
    ))
))

(complete 98)

;==========================================================
; Now show the Read.Me and set the paths

(set @execute-dir executes)
(set @default-dest executes)

(if (askbool (prompt "Do you want me to set a \"path\" on \"DataProc\"?")
             (help "With registered versions this will allow you to start "
                   "\"DataProc\" from any location and NOT only from its "
                   "home directory. With unregistered versions this feature "
                   "is disabled.\n\n"
                   "NOTE: If your main startup-sequence is NOT in \"root:s\" "
                   "Installer will fail. So if you do dirty tricks during your "
                   "startup (grin!), better skip this point.")
             (default 0))
    (startup "DataProc" (prompt "Setting \"DataProc\" paths")
             (help "With registered versions this will allow you to start "
                   "\"DataProc\" from any location and NOT only from its "
                   "home directory. With unregistered versions this feature "
                   "is disabled.")
             (command ("path \"%s\" add" executes)))
)

(complete 99)
(if (askbool (prompt "Do you want an icon for \"DataProc\"?")
              (help "The icon will open a \"Shell\" in the \"DataProc\" "
                    "home directory. You can then start \"DataProc\" from "
                    "WorkBench© easily.")
              (default 1))
    ((if (NOT (exists "s:shell-startup"))
         (copyfiles (source (tackon @root "s/shell-startup"))
                    (dest "s:")))
     (copyfiles (source (tackon @root "s/DataProc.shell"))
                (dest "s:"))
     (copyfiles (source (tackon @root "s/DataProc.info"))
                (dest executes))
    ))

(set @show-read (cat ("\"%s\" " ("sys:utilities/more")) ("\"%s\"" (tackon executes "Read.Me"))))
(working "Showing \"Read.Me\" file ...")
(run (cat "run <NIL: >NIL: " @show-read))
(complete 100)

