; --------------------------------------------------------------
; CBM installer script to install Imagemaster R/t on users
; hard-drive. Loosely derived from the original Imagemaster
; installation script.
; --------------------------------------------------------------
;  Copyright 1993,1994, Black Belt Systems, ALL RIGHTS RESERVED
; --------------------------------------------------------------
;     Written by: Ben Williams
;   Date Written: July 26th, 1993
;            For: Imagemaster R/t
; --------------------------------------------------------------
;        Updates
;        -------
;September 01/93: Now deletes the old .info file on re-installs
;                 so that new icon shows up.
;
;September 13/93: Now asks user if they wish to have ApAsisst
;                 placed in c: (which is suggested)
;
;September 16/93: Now adds a path add statement to the user's
;                 shell-startup file so that ApAssist and
;                 Imagemaster can run successfully from shell;
;                 Also copies "ReadMeFirst" document into the
;                 Imagemaster R/t install directory.
;
;    March 28/94: Modified to work with early assigns as target
;                 to get around extraction utility's problem with
;                 spaces in paths. Modified to be smarter about
;                 ApAssist installation. Modified to be smarter
;                 about float & non-float archive fragments, uses
;                 less ram during install. If there is NO
;                 s:user-startup file, we'll create one for the
;                 user. "imblock" file changed to remove leading
;                 space for BEGIN and END segments; this was
;                 preventing SMOD from correctly removing the
;                 older block. Changed to 7 disk install to
;                 accomodate large expansion in documentation
; --------------------------------------------------------------
;Notes:
;------->
;  (1) We force a minimum level of AVERAGE user so that they
;      must specify the target directory for the install and
;      answer some basic questions such as "Do you have an FPU"
;
;  (2) There must be sufficient diskspace to install the software
;      or we won't even try to install.
;
;  (3) The ARexx REXX assign must be available, or we can't install
;
;  (4) If the user has already assigned targets for ALL of:
;           RXPI:
;           CMPI:
;           IMDOC:
;           IMCAT:
;      Then we will not attempt to create directories in the
;      Imagemaster R/t drawer for them. Instead, we will install
;      the relevant portions of the software to the specified
;      locations. This MAY defeat the available space checking
;      code in the install script, if these locations are on
;      a different volume than the target volume.
;
;------------------------------------------------------------------

; Install script is initiated from disk one of the install group,
; so we do all things we possibly can from disk 1, first.
; Disk 1 is where most of the miscellaneous items are stored.
;----------------------------------------------------------------

; cleanup routine
;----------------
(onerror)

; Create disk filesystem names and volume names
; Some installer functions want the ":" character, and
; some don't. Another blow for consistancy in programming.
; --------------------------------------------------------
(set d1 "IM_Install1:") (set v1 "IM_Install1")
(set d2 "IM_Install2:") (set v2 "IM_Install2")
(set d3 "IM_Install3:") (set v3 "IM_Install3")
(set d4 "IM_Install4:") (set v4 "IM_Install4")
(set d5 "IM_Install5:") (set v5 "IM_Install5")
(set d6 "IM_Install6:") (set v6 "IM_Install6")
(set d7 "IM_Install7:") (set v7 "IM_Install7")

; This IM R/t release is (approximately) sized as follows:
;---------------------------------------------------------
(set misc_spc 50000)
(set imrt_spc 2100000)
(set film_spc 180000)
(set isha_spc 25000)
(set devl_spc 10000)
(set pimo_spc 2000000)
(set apas_spc 90000)
(set adoc_spc 3161088)

; Make certain rexx: directory exists - if ARexx isn't running, we
; can (sortof) live with that, though the user will be seriously
; crippled in capability. If no assignment exists, we're toast
;-----------------------------------------------------------------
(if (= (getassign "rexx") "")
    ( ; Then...
        (abort "Cannot install - no REXX: assignment in this system. "
               "You MUST have ARexx and a drawer assigned to REXX: "
               "to hold ARexx scripts in order to successfully "
               "install Imagemaster. Please properly configure "
               "your computer and try again. If you do not know how "
               "to accomplish this, call your dealer or consultant."
        )
    )
)

; Find out where user wants to put Imagemaster
;---------------------------------------------
(set user_place
    (askdir
        (prompt "On which Volume shall we place the Imagemaster DRAWER? ")
        (help @askdir-help "It is important that you realize that the destination volume you specify "
                           "here is where the DRAWER in which Imagemaster and its associated data "
                           "files will be placed. Even if this is an update to an earlier "
                           "installation, you still need to specify this location the same way. "
                           "Otherwise, a new \"Imagemaster\" drawer will be created INSIDE your "
                           "old one, causing much confusion and not amusing anyone.")
        (default @default-dest)
    )
)

; Check to see if assigns are already made
; This accounts for custom installs by techno-types
;--------------------------------------------------
(set as_made 0)
(if (<> (getassign "rxpi:") "")
    (if (<> (getassign "cmpi:") "")
        (if (<> (getassign "IMDOC:") "")
            (if (<> (getassign "IMCAT:") "")
               (set as_made 1) ; All four assigns must be made!
            )
        )
    )
)

; Find out if user wants the developer code
;------------------------------------------
(set dev_install
    (askoptions
        (prompt "Would you like to have the Public Interface developer "
                "C and ARexx code, with documentation? This will allow "
                "you to create public interface modules of your own, IF "
                "you own the SAS C compiler and have typical Amiga "
                "developer skills.")
                (help @askoptions-help "If you are NOT a technical type, "
                "you have no need for this data. If you are, then by all "
                "means install it!")
        (choices "Install SAS C and ARexx developer code?")
        (default 0)
    )
)

; Check with user if they want the floating point version
;--------------------------------------------------------
(set float_install
    (askchoice
        (prompt "Install the hardware floating-point version? ")
        (help "An FPU is a special hardware mathematics processor "
              "which allows a computer which uses it to figure out "
              "answers to math problems using floating point math "
              "much faster than it could without an FPU. A 68000 "
              "Amiga has no FPU. 68020 or 68030 based-Amigas may "
              "have an FPU - check your documentation if you're not "
              "certain. 68040-based Amigas always have the FPU built "
              "right in. The non-FPU version will work on an Amiga "
              "with an FPU, however it will be much slower which "
              "will cost you unecessary time when processing images. "
              @askchoice-help)
        (choices "Install Floating Point (FPU) version"
                 "Install standard (NON-FPU) version")
        (default 1)
    )
)

; Derive total install space
; for required elements of installation:
; ----------------------------------------------------------------
(set total_size imrt_spc)                ; Imagemaster R/t
(set total_size (+ total_size film_spc)) ; Filmstrip Viewer
(set total_size (+ total_size isha_spc)) ; IShapes files
(set total_size (+ total_size pimo_spc)) ; PI Modules
(set total_size (+ total_size adoc_spc)) ; Hypertext Documentation
(set total_size (+ total_size misc_spc)) ; Any remaining items...

; Add space for developer code, if desired
; ----------------------------------------
(if (= dev_install 1)
    ( ; Then...
        (set total_size (+ total_size devl_spc)) ; Developer Code
    )
)

; Decide if we can install ApAssist in the c: directory
; If we can, we do it immediately, before we do the rest
; of the install - this will ensure that the disk space
; check will take it into account if it is on the same
; volume by virtue of its already taking up space; if
; it's not on the same volume, then we won't "see" it in
; the disk space check, and that works fine too. This
; install comes from disk one:
; -----------------------------------------------------
(set app_in_c 1) ; assume ApAssist will fit in c:
(set app_space  (getdiskspace "c:"))
(copyfiles (source d1) (dest "ram:") (pattern "ApAssist") (files))
(if (< app_space apas_spc)
    ( ; Then must go to IM R/t directory
        (set app_in_c 0)
        (set total_size (+ total_size apas_spc)) ; ApAssist executable
    )
    ( ; Else _could_ go in c:
      ; Find out if user wants ApAssist in c:
      ;--------------------------------------
        (set apa_install
            (askoptions
                (prompt "It has been determined that you do have enough "
                        "free space on the volume that your c: assignment "
                        "points at to install ApAssist in c:. This is the "
                        "suggested location, the most generally useful. If "
                        "for some reason this is not acceptable, ApAssist "
                        "will be installed in the Imagemaster R/t drawer "
                        "along with the rest of the software.")
                        (help @askoptions-help
                        " ApAssist is Black Belt Systems' hypertext online "
                        "Documentation system. It runs the online manual "
                        "for Imagemaster R/t; the reason that it is a very "
                        "good idea to place it in your c: assigned location "
                        "is because in this location, other software can "
                        "also use it (because c: is always part of the "
                        "path AmigaDOS searches for commands.)")
                (choices "Install ApAssist in your c: assigned location?")
                (default 0)
            )
        )
    )
)

; At this point, we've got a pretty good handle on installation
; storage requirements, with the possible exception of if the
; user has created custom assignments for all of RXPI, CMPI,
; IMDOC and IMCAT - in which case we can mistakenly abort here
; if the target disk is short on space. Hopefully a technically
; competant user such as would intentionally redirect the
; installation using assigns will manage their system well
; enough to avoid that problem. If we can't do the main install,
; we quit immediately with an informative message.
; -------------------------------------------------
(set tgt_space  (getdiskspace user_place))
(if (< tgt_space total_size)
    ( ; Then...
        (abort "This installation requires about " ("%ld" total_size)
               " bytes free on the "
               "volume where you wish to install Imagemaster. Please "
               "make this space available and then re-install. For your "
               "information, the volume you have selected has only "
               ("%ld " tgt_space) "bytes free. You need "
               ("%ld " (- total_size tgt_space)) "more bytes."
        )
    )
)

; Get the items we need from disk 1
;----------------------------------
(if (= float_install 0)
    ( ; Then...
        (copyfiles (source d1)
                   (dest "ram:")
                   (pattern "(bss|extract|ReadMeFirst|ReadMeFirst.info|smod|imblock|join|delete|fv.lzh|ish.lzh|imi.lzh|dc.lzh|imb.lzh.partb|makedata.diag)")
                   (files)
        )
    )
    ( ; Else...
        (copyfiles (source d1)
                   (dest "ram:")
                   (pattern "(bss|extract|ReadMeFirst|ReadMeFirst.info|smod|imblock|join|delete|fv.lzh|ish.lzh|imi.lzh|dc.lzh|ima.lzh.partb|makedata.diag)")
                   (files)
        )
    )
)

(if (= dev_install 1)
    ( ; Then...
        (copyfiles (source d1)
                   (dest "ram:")
                   (pattern "dd.lzh")
                   (files)
        )
    )
)

; We've got the target; now we need to make sure that we have our main DIR
;-------------------------------------------------------------------------
(set im_dest (tackon user_place "Imagemaster"))
(if (not (exists im_dest))
    ( ; Then...
        (makedir im_dest (infos))
    )
)
(makeassign "TMPTGT" im_dest (safe))
(set @default-dest "TMPTGT:")

; If it is _possible_ to put ApAssist in c:
;------------------------------------------
(if (= app_in_c 1)
    ( ; Then it is _possible_ to put ApAssist in c:
        (if (= apa_install 1)
            ( ; then they _want_ ApAssist in c:
                (copyfiles
                    (source d1)
                    (dest "c:")
                    (pattern "ApAssist")
                    (files)
                )
            )
            ( ; Else they do NOT want it in c:, put it in IM R/t location
                (set total_size (+ total_size apas_spc)) ; ApAssist executable
                (copyfiles
                       (source d1)
                       (dest "TMPTGT:")
                       (pattern "ApAssist")
                       (files)
                )
            )
        )
    )
    ( ; Else not possible for it to fit in c:, goes to IM dir
        (copyfiles
            (source d1)
            (dest "TMPTGT:")
            (pattern "ApAssist")
            (files)
        )
    )
)

; Create subordinate target strings
;----------------------------------
(set rxpi_dir   "TMPTGT:rxpi")
(set wipe_dir   (tackon rxpi_dir "wipes"))
(set cmpi_dir   "TMPTGT:cmpi")
(set ish_dir    "TMPTGT:IShapes")
(set dev_dir    "TMPTGT:Developer")
(set imdoc_dir  "TMPTGT:imdoc")
(set imcat_dir  "TMPTGT:imcat")
(set lib_dir    "libs:")
(set rexx_dir   "rexx:")

; Create targets for assign statements for user-startup file
;-----------------------------------------------------------
(set vrxpi_dir   (tackon im_dest "rxpi"))
(set vwipe_dir   (tackon rxpi_dir "wipes"))
(set vcmpi_dir   (tackon im_dest "cmpi"))
(set vish_dir    (tackon im_dest "IShapes"))
(set vdev_dir    (tackon im_dest "Developer"))
(set vimdoc_dir  (tackon im_dest "imdoc"))
(set vimcat_dir  (tackon im_dest "imcat"))

; Create RXPI drawer if it's not already there
; and if user doesn't have it custom assigned
; elsewhere
;---------------------------------------------
(if (not (exists rxpi_dir))
    ( ; Then...
        (if (= as_made 0)
            ( ; Then...
                (makedir rxpi_dir (infos))
            )
        )
    )
)

; Create wipes drawer if it's not already there
;----------------------------------------------
(if (not (exists wipe_dir))
    ( ; Then...
        (makedir wipe_dir (infos))
    )
)

; Create CMPI drawer if it's not already there
; and if user doesn't have it custom assigned
; elsewhere
;---------------------------------------------
(if (not (exists cmpi_dir))
    ( ; Then...
        (if (= as_made 0)
            ( ; Then...
                (makedir cmpi_dir (infos))
            )
        )
    )
)

; Create IShapes drawer if it's not already there
;------------------------------------------------
(if (not (exists ish_dir))
    ( ; Then...
        (makedir ish_dir (infos))
    )
)

; Create IMDOC drawer if it's not already there
; and if user doesn't have it custom assigned
; elsewhere
;----------------------------------------------
(if (not (exists imdoc_dir))
    ( ; Then...
        (if (= as_made 0)
            ( ; Then...
                (makedir imdoc_dir (infos))
            )
        )
    )
)

; Create IMCAT drawer if it's not already there
; and if user doesn't have it custom assigned
; elsewhere
;----------------------------------------------
(if (not (exists imcat_dir))
    ( ; Then...
        (if (= as_made 0)
            ( ; Then...
                (makedir imcat_dir (infos))
            )
        )
    )
)

; Make assignments so user can operate immediately
; If the user has already specially made these assignments,
; then we'll use those locations as targets instead
;----------------------------------------------------------
(if (= as_made 0)
    ( ; Then...
        (makeassign "RXPI" rxpi_dir (safe))
        (makeassign "CMPI" cmpi_dir (safe))
        (makeassign "IMDOC" imdoc_dir (safe))
        (makeassign "IMCAT" imcat_dir (safe))
    )
)
(makeassign "IMIMIM" "TMPTGT:" (safe))

; Extract this portion of the installation
;-----------------------------------------
(run ("ram:extract >con:0/50/640/100/extract -m e ram:imi TMPTGT:"))
(run ("ram:extract >con:0/50/640/100/extract -m e ram:fv TMPTGT:"))
(run ("ram:extract >con:0/50/640/100/extract -m e ram:ish %s/" ish_dir))

; Decide about .info file name
;-----------------------------
(if (= float_install 0)
    ( ; Then...
        (if (exists "TMPTGT:imf.info")
            (delete "TMPTGT:imf.info"))
        (rename ("TMPTGT:iminfo") ("TMPTGT:imf.info"))
    )
    ( ; Else...
        (if (exists "TMPTGT:im.info")
            (delete "TMPTGT:im.info"))
        (rename ("TMPTGT:iminfo") ("TMPTGT:im.info"))
    )
)

; Clean up after these archives
;------------------------------
(delete "ram:ish.lzh")
(delete "ram:fv.lzh")
(delete "ram:imi.lzh")

; Install DCTV.Library
; --------------------
(run ("ram:extract >con:0/50/640/100/extract -m e ram:dc ram:"))
(copylib (source "ram:dctv.library") (dest "libs:"))
(delete "ram:dc.lzh")
(delete "ram:dctv.library")

; Set variables pointing to the disk with the correct IM R/t archive
;-------------------------------------------------------------------
(if (= float_install 0)
    ( ; Then...
        (set imp_src d3)
        (set imv_src v3)
        (set proc_file "imb.lzh.parta")
        (run ("rename ram:imb.lzh.partb ram:iii.lzh"))
    )
    ( ; Else...
        (set imp_src d2)
        (set imv_src v2)
        (set proc_file "ima.lzh.parta")
        (run ("rename ram:ima.lzh.partb ram:iii.lzh"))
    )
)

; Ask for the proper diskette
;----------------------------
(askdisk
    (prompt ("Please insert the %s diskette " imv_src))
    (help " This diskette is absolutely required to complete this "
          "installation! It contains the version of Imagemaster R/t "
          "You requested (floating point, or non floating point).")
    (dest imv_src)
)

; This gets the needed archive from the proper disk
;--------------------------------------------------
(copyfiles (source imp_src)
           (dest "ram:")
           (pattern proc_file)
           (files)
)

; Cojoin the fragments of the R/t archive and toss the sources
;-------------------------------------------------------------
(run ("ram:join ram:%s ram:iii.lzh TO ram:ixi.lzh" proc_file))
(delete ("ram:%s" proc_file))
(delete "ram:iii.lzh")

; Here, we extract the image processor, copying it at the same time
;------------------------------------------------------------------
(run ("ram:extract >con:0/50/640/100/extract -m e ram:ixi.lzh TMPTGT:"))

; Delete the joined image processor archive
;------------------------------------------
(delete ("ram:ixi.lzh"))

; If user wants the developer stuff, install it
;----------------------------------------------
(if (= dev_install 1)
    ( ; Then...
        (if (not (exists dev_dir))
            ( ; Then...
                (makedir dev_dir (infos))
            )
        )
        (run ("ram:extract >con:0/50/640/100/extract -m e ram:dd %s/" dev_dir))
        (delete "ram:dd.lzh")
    )
)

; Install the ApAssist documentation
; ----------------------------------
(askdisk
    (prompt ("Please insert the %s diskette " v4))
    (help " This diskette is required to complete the "
          "installation. It contains part of the documentation "
          "for the Imagemaster R/t software!")
    (dest v4)
)
(copyfiles (source d4)
           (dest "ram:")
           (pattern "apa.lzh.parta")
           (files)
)
; Install the ApAssist documentation
; ----------------------------------
(askdisk
    (prompt ("Please insert the %s diskette " v5))
    (help " This diskette is required to complete the "
          "installation. It contains part of the documentation "
          "for the Imagemaster R/t software!")
    (dest v5)
)
(copyfiles (source d5)
           (dest "ram:")
           (pattern "apa.lzh.partb")
           (files)
)

; Cojoin the fragments of the doc archive and toss the sources
;-------------------------------------------------------------
(run "ram:join ram:apa.lzh.parta ram:apa.lzh.partb TO ram:apa.lzh")
(delete "ram:apa.lzh.parta")
(delete "ram:apa.lzh.partb")

;Extract the complete archive
;----------------------------
(run ("ram:extract >con:0/50/640/100/extract -m e ram:apa %s/" imdoc_dir))
(delete "ram:apa.lzh")
(copyfiles (source imdoc_dir)
           (dest "TMPTGT:")
           (pattern "IMRT_Manual")
           (files)
           (infos)
)
(delete (tackon imdoc_dir "IMRT_Manual"))
(delete (tackon imdoc_dir "IMRT_Manual.info"))

; Get the PI Module archive chunks....
;-------------------------------------
(makedir "ram:gbzyx")
(askdisk
    (prompt ("Please insert the %s diskette " v6))
    (help " This diskette is required to install "
          "the PI Modules")
    (dest v6)
)
(copyfiles (source d6)
           (dest "ram:")
           (pattern "piarc.lzh.parta")
           (files)
)

; Get part B of the piarc.lzh file
;----------------------------------------------------------
(askdisk
    (prompt ("Please insert the %s diskette " v7))
    (help " This diskette is required to install "
          "the PI Modules.")
    (dest v7)
)
(copyfiles (source d7)
           (dest "ram:")
           (pattern "piarc.lzh.partb")
           (files)
)

; Now, enjoin the two lzh fragments back into a usable archive:
; -------------------------------------------------------------
(run ("ram:join ram:piarc.lzh.parta ram:piarc.lzh.partb TO ram:piarc.lzh"))

; Get rid of fragments
; --------------------
(run ("ram:delete ram:piarc.lzh.part? QUIET"))

; Now to get the PI modules installed
; Begin by backing up old macro file, if it exists
;-------------------------------------------------
(if (exists "s:Default.immcr.old")
    (delete "s:Default.immcr.old"))
(if (exists "s:Default.immcr")
    (rename "s:Default.immcr" "s:Default.immcr.old"))
;---------------

; Old macros are backed up, ready for main PI install
; Extract the PI Modules
;----------------------------------------------------
(run ("ram:extract >con:0/50/640/100/extract -m e ram:piarc ram:gbzyx/"))
(delete "ram:piarc.lzh")

; Archive is unpacked and ready to copy
; first, backup list.list if available
;--------------------------------------
(if (exists "cmpi:list.list")
    ( ; Then...
        (if (exists "cmpi:list.list.old")
            ( ; Then...
                (delete "cmpi:list.list.old")
            )
        )
        (rename "cmpi:list.list" "cmpi:list.list.old")
        (message "Please note that during installation, your previous "
                 "\"list.list\" file was located and renamed to "
                 "\"list.list.old\". All of your aftermarket PI "
                 "modules (if any) are still intact, but will not "
                 "show up on PI lists untill the new list.list file "
                 "has been appropriately modified."
         (help   " This has been done so that you may refer to it if "
                 "you had aftermarket PI modules declared in it. "
                 "A new list.list file has been created as part of "
                 "this install procedure - you should use this new "
                 "list.list file instead of the old one (that will "
                 "happen automatically) but if you DID have any "
                 "aftermarket PI modules, such as Metadigm's ES300c "
                 "scanner driver, you'll need to add the control "
                 "line(s) for it (them) into the new list.list file. "
                 "You would then use the old list.list file as a template "
                 "to accomplish this.")
         )
    )
)

; move the "odd" files (not PI rexx or PI cmds)
;----------------------------------------------
(copyfiles (source "ram:gbzyx") (dest "rexx:")
           (pattern "(picmdpath|launch.rexx|imtf.rexx)") (files))
(copyfiles (source "ram:gbzyx") (dest "s:")
           (pattern "(default.??mcr)") (files))
(copyfiles (source "ram:gbzyx") (dest "cmpi:")
           (pattern "list.list") (files))
(copyfiles (source "ram:gbzyx") (dest "rxpi:wipes")
           (pattern "#?.rxwp") (files))
(copyfiles (source "ram:") (dest "TMPTGT:")
           (pattern "ReadMeFirst#?") (files))
(copyfiles (source "ram:") (dest "TMPTGT:")
           (pattern "makedata.diag") (files))
(delete "ram:makedata.diag")
(delete "ram:ReadMeFirst")
(delete "ram:ReadMeFirst.info")
(delete "ram:gbzyx/picmdpath")
(delete "ram:gbzyx/list.list")
(delete "ram:gbzyx/launch.rexx")
(delete "ram:gbzyx/imtf.rexx")
(run "ram:delete ram:gbzyx/Default.??mcr QUIET")
(run "ram:delete ram:gbzyx/#?.rxwp QUIET")

; Next, copy all the PI ARexx scripts
;------------------------------------
(copyfiles (source "ram:gbzyx") (dest "rxpi:")
           (pattern "#?.rexx") (files))
(run "ram:delete ram:gbzyx/#?.rexx QUIET")

; Next, copy all the PI Commands
;-------------------------------
(copyfiles (source "ram:gbzyx") (dest "cmpi:")
           (pattern "#?") (files))

; Now, we have to decide if we can install the FPU PI modules
;------------------------------------------------------------
(if (exists "CMPI:rdjpg") (delete "CMPI:rdjpg"))
(if (exists "CMPI:wrjpg") (delete "CMPI:wrjpg"))
(if (= float_install 0)
    ( ; Then...
        (rename "CMPI:x_JPR030" "CMPI:rdjpg")
        (rename "CMPI:x_JPW030" "CMPI:wrjpg")
    )
    ( ; Else...
        (rename "CMPI:x_JPR000" "CMPI:rdjpg")
        (rename "CMPI:x_JPW000" "CMPI:wrjpg")
    )
)

; clean up
;---------
(run "ram:delete CMPI:x_#? QUIET")
(run "ram:delete ram:gbzyx/#? QUIET")
(delete "ram:gbzyx")
(delete "ram:extract")
(delete "ram:delete")
(delete "ram:join")

; Check to see if there is a "user-startup" file in the user's s:
; directory. If not, put one there (with comments to show we did it)
;-------------------------------------------------------------------
(if (not (exists "s:user-startup"))
    ( ; then...
        (run "c:copy ram:bss s:user-startup")
    )
)

; Add assignment to user's "user-startup" directory for new boot ops
; IF they were not already correctly done - otherwise skip this part
;-------------------------------------------------------------------
(if (= as_made 0)
    ( ; Then...
        (startup "Imagemaster"
            (help " This operation adds lines to your user-startup file "
                  "which are harmless assignment statements to drawers "
                  "within the Imagemaster drawer, called \"IMIMIM:\", "
                  "\"RXPI:\", \"IMDOC:\", \"IMCAT:\" and \"CMPI:\". Each "
                  "time you boot your Amiga, these assignments are used to "
                  "let Imagemaster's Public Interface \(PI\) drivers know "
                  "where its data files reside. Unless you know that you "
                  "have another assignment with one of these names, it is "
                  "extremely unlikely that there would be any reason to "
                  "NOT let this happen.")
            (prompt "Is it o.k. to add five SAFE lines to your User-Startup "
                    "file?")
            (command ("assign RXPI: \"%s\"\n" vrxpi_dir))
            (command ("assign CMPI: \"%s\"\n" vcmpi_dir))
            (command ("assign IMDOC: \"%s\"\n" vimdoc_dir))
            (command ("assign IMCAT: \"%s\"\n" vimcat_dir))
            (command ("assign IMIMIM: \"%s\"\n" im_dest))
        )
    )
)

(set shellstart
    (askoptions
        (prompt "As part of the usual install procedure, we "
        "normally add a statement to your shell-startup file "
        "which essentially teaches your Amiga how to find "
        "Imagemaster R/t and its help manager from any shell "
        "prompt - no matter what directory you are currently "
        "\"cd'd\" to. We strongly suggest that you leave this "
        "option checked, unless you are an expert with paths "
        "and already have other plans in force that will "
        "handle the path issues. Imagemaster R/t MUST have a "
        "path to IMIMIM: if it is to be operated from the "
        "shell at any time.")
        (help @askoptions-help " This operation uses a custom "
        "command written at Black Belt Systems which is able "
        "to modify your shell-startup file. The changes are "
        "made in such a way as to be clear to you, should you "
        "even have the need to edit your shell-startup file "
        "in the future. Allowing it to occur will cause no "
        "ill-effects, even if at some later date you remove "
        "the Imagemaster R/t drawer. Note that if you have "
        "a shell open NOW, the path will not be available "
        "there unless you add it manually. This is because "
        "each shell has it's own path. The statement in the "
        "shell-startup file added by this operation will "
        "cause the path to be added each time a new shell "
        "is opened. Since your current shell, if any, was "
        "opened using the shell-startup file before we added "
        "the new PATH statement, it does not have the path "
        "required to launch Imagemaster R/t properly.")
        (choices "Add PATH statement to your shell-startup?")
        (default 1)
    )
)

(if (= shellstart 1)
    (if (exists "s:shell-startup")
        ( ; then...
            (run "ram:smod s:shell-startup ram:imblock Imagemaster")
        )
        ( ; Else...
            (run "c:copy ram:imblock s:shell-startup")
        )
    )
)

(delete "ram:smod")
(delete "ram:bss")
(delete "ram:imblock")

(run "assign TMPTGT:")
(set @default-dest im_dest)
(exit)
