; Install-Script for Blacks Editor 1.0

(set #installing "Installing ")

(set #bad-kick
   (cat "\n\nSorry! You must have Workbench 2.04 or"
        "\nhigher to to use this package."
        "\n\nAborting Installation!"))


(complete 0)

(if (< (getversion) (* 37 65536))
        (abort #bad-kick)
)

; determine cpu type
(set cpu (database "cpu"))

(set defcpu
     (if (OR (= cpu "68000") (= cpu "68010"))
          (set defcpu 0)
          (set defcpu 1)
     )
)

(set @default-dest
     (askdir
          (prompt "In which directory would you like Blacks Editor installed?\n(A directory will be created there.)")
          (help @askdir-help)
          (default @default-dest)
     )
)

(set maindir (tackon @default-dest "BlacksEditor"))
(set @default-dest maindir)

(set eucver
     (askchoice
          (prompt "Which executable of Blacks Editor would you like installed?")
          (help @askchoice-help)
          (choices "68000" "68030+")
          (default defcpu)
     )
)

(set rexxdir
     (askdir
          (prompt "In which directory would you like Blacks Editor's ARexx scripts installed?")
          (help @askdir-help)
          (default (tackon maindir "Rexx"))
          (newpath)
     )
)

(set helpdir
     (askdir
          (prompt "In which directory would you like Blacks Editor's AmigaGuide documentation installed?")
          (help @askdir-help)
          (default maindir)
          (newpath)
     )
)

(select eucver
     (copyfiles
          (prompt "Copying main executable (68000)...")
          (help @copyfiles-help)
          (source "BED")
          (dest maindir)
          (infos)
          (optional "nofail")
     )

     (copyfiles
          (prompt "Copying main executable (68030+)...")
          (help @copyfiles-help)
          (source "BED030+")
          (dest maindir)
          (infos)
          (newname "BED")
          (optional "nofail")
     )
)

(complete 25)

(copyfiles
     (help @copyfiles-help)
     (source "Docs/BED.guide")
     (dest helpdir)
     (infos)
     (optional "nofail")
)

; .guide file uses AmigaGuide instead of MultiView for OS <= V38
(set ver (/ (getversion) 65536))

(if (<= ver 38)
     (tooltype
          (dest (tackon maindir "BED.guide"))
          (setdefaulttool "AmigaGuide")
     )
)

(complete 30)

(copyfiles
     (prompt "Copying ARexx scripts...")
     (help @copyfiles-help)
     (source "Rexx")
     (dest rexxdir)
     (all)
     (infos)
     (optional "nofail")
)

(complete 50)

; Support files (required)
(copyfiles
     (prompt "Copying Blacks Editor support files...")
     (help @copyfiles-help)
     (source "Support")
     (dest (tackon maindir "Support"))
     (all)
     (infos)
     (optional "nofail")
)

(complete 65)

; Icons (optional)
(copyfiles
     (prompt "Copying Blacks Editor icons...")
     (help @copyfiles-help)
     (source "Icons")
     (dest (tackon maindir "Icons"))
     (all)
     (infos)
     (optional "nofail")
)

(complete 80)

; Catalogs (optional)
(copyfiles
     (prompt "Copying Blacks Editor catalog files...")
     (help @copyfiles-help)
     (source "Catalogs")
     (dest (tackon maindir "Catalogs"))
     (all)
     (confirm)
     (infos)
     (optional "nofail")
)

(complete 95)

(set #startup-cmd (cat "Assign BED: " maindir "\nPath BED: " "BED:" (fileonly rexxdir) " ADD"))
(startup "BED"
     (prompt (cat "Adding the command\n\n" #startup-cmd "\n\nto your s:User-Startup."))
     (help @startup-help)
     (command #startup-cmd)
)

(makeassign "BED" maindir)

(run "More IMPORTANT!")

(complete 100)

(exit)

