;
; $VER: Install InterSpread Pro V33.1 13.04.93)
;

;
; Reset complete %
;
(complete 0)

;
; Set our path variables.
;
(set sourcepath  (cat @app-name ":"))
(set sourcepath2 (cat @app-name "_2:"))
(set @default-dest "SYS:")

;
; Variables to check for boot-device.
;
(set sys-space (getdiskspace "SYS:"))
(set appname-space (getdiskspace (cat @app-name ":")))

;
; English Strings
;
(if (= @language "english")
(
(set default_lang 4)

(set #askdestdir
(cat "In which drawer would you like to install " @app-name " ?"
))

(set #askdesthelp
(cat "You must choose the drawer where you will install " @app-name "."
     " A drawer by the name of " @app-name " will automatically be "
     "created below the drawer you choose here.\n\n" @askdir-help
))

(set #installaborted
(cat "Installation of " @app-name " aborted."
))

(set #destdirexists
(cat "\n\n\n\n" @app-name " already exists. Should I abort the "
     "installation ?"
))

(set #destdirexistshelp
(cat "The " @app-name " drawer does already exist. You must choose if "
     "you want to install over the old version, or abort now, delete "
     "the old version, and then re-install " @app-name ". The "
     "recommended way is to delete the old version and then re-install."
))

(set #spreadsheetdrawername
(cat "SpreadSheets"
))

(set #nowcopying1
(cat "Now copying " @app-name " and related files..."
))

(set #nowcopying1help
(cat "This will copy " @app-name " and related files to the selected destination "
     "drawer.\n\n" @copyfiles-help
))

(set #nowcopying2
(cat "Now copying printer drivers..."
))

(set #nowcopying2help
(cat "This will copy printer drivers. These files are printer drivers "
     "that support different printer types. This enables you to use different "
     "printers with " @app-name ".\n\n" @copyfiles-help
))

(set #nowcopying3
(cat "Now copying demo " #spreadsheetdrawername "..."
))

(set #nowcopying3help
(cat "This will copy demo " #spreadsheetdrawername ". These " #spreadsheetdrawername
     " demonstrate some basic features of " @app-name " from which you can learn.\n\n"
     @copyfiles-help
))

(set #nowcopying4
(cat "About to copy amigaguide.library..."
))

(set #nowcopying4help
(cat "This will copy amigaguide.library to your LIBS: drawer. " @app-name
     " requires this library in order to display amigaguide on-line help "
     "documents.\n\n" @copylib-help
))

(set #nowcopying5
(cat "About to copy ARexx examples..."
))

(set #nowcopying5help
(cat "This will copy ARexx examples scripts to the destination drawer."
))

(set #nowcopying6
(cat "About to copy req.library..."
))

(set #nowcopying6help
(cat "This will copy req.library to your LIBS: drawer. The Printer Manager "
     "\"ISC\" requires this library in order to let you choose files to manage.\n\n"
     @copylib-help
))

(set #startupdest
(cat "Where may I insert an " @app-name ": assignment? Use HELP if in "
     "doubt."
))

(set #startupdesthelp
(cat @app-name " needs a logic assignment by the name of " @app-name ":"
     ". This assign is important, since it enables " @app-name " to find "
     "it's configuration and related files. In order to make this "
     "assignment automatically on every startup, you need to tell "
     "me which file I can insert this assign statement in.\n\n" @askfile-help
))

(set #installfinished
(cat "\n! WARNING ! WARNING ! WARNING ! WARNING !\n\n"
     "Installation finished! As soon as you leave this program, "
     "your machine will be >REBOOTED<. While this happens you should eject "
     "the " @app-name " disk, and wait for your machine to finish booting "
     "on your harddrive. As soon as your machine is ready, you can start "
     "using " @app-name " from your Workbench.\n\nIf you want to >AVOID< "
     "rebooting, then hit\n>Abort Install<."
))

(set #mustbootfromhd
(cat "\n\n\nError: You must boot from your harddrive to install " @app-name "."
))

(set #isprefsname
(cat "ISprefs_1.01"
))

(set #copyarexx
(cat "\n\n\nDo you want to install example ARexx scripts?"
))

(set #copyarexxhelp
(cat "You must choose if you want to install examples ARexx scripts to your "
     "harddrive. These examples shows you how to use ARexx with " @app-name "."
))

(set #installchoicehelp
(cat "You must choose whether you want to install InterSpread Professional "
     "to your Hard Drive or floppy disk."
))

(set #insertdisk
(cat "\n\n\n\nPlease insert disk "
))

(set #insertdiskhelp
(cat "\n\n\n\nYou must now insert the disk named "
))

))

;============================================================================

;
; Say HI!
;
;(welcome)

;
; Recognize OS version.
;
(set osver (/ (getversion) 65535))

;
; User *HAS* to boot from his HD!
;
(if (= sys-space appname-space)
(
;-> User booted from disk. This is *NOT* allowed!
   (message #mustbootfromhd)
   (abort #installaborted)
))

;
; Ask for destination directory.
;
(set @default-dest
   (askdir (prompt #askdestdir)
           (help   #askdesthelp)
           (default @default-dest)
   )
)

;
; Check that directory @app-name doesn't exist already.
;
(set @default-dest (tackon @default-dest @app-name))
(if (exists @default-dest)
   (if (askbool (prompt #destdirexists)
                (help   #destdirexistshelp)
                (default 1)
       )
      (abort #installaborted)
   )
)

;
; Creating directories in destination drawer.
;
(makedir @default-dest (infos))
(set temp (tackon @default-dest "Printers"))
(makedir temp)
(set temp (tackon @default-dest #spreadsheetdrawername))
(makedir temp (infos))

;
; Copying @app-name and related files.
;
(copyfiles (prompt  #nowcopying1)
           (help    #nowcopying1help)
           (source  sourcepath)
           (dest    @default-dest)
           (choices @app-name (cat @app-name ".info") #isprefsname
                    "ISC")
           (confirm "expert")
)

(complete 10)

;
; Copy ISGprefs.
;
(copyfiles (prompt  #nowcopying1)
           (help    #nowcopying1help)
           (source  sourcepath)
           (dest    @default-dest)
           (choices "ISGprefs")
           (confirm "expert")
)

(complete 15)

;
; Copying Printers/*.
;
(set temp1 (tackon @default-dest "Printers"))
(set temp2 (tackon sourcepath "Printers"))
(copyfiles (prompt #nowcopying2)
           (help   #nowcopying2help)
           (source temp2)
           (dest temp1)
           (all)
           (confirm "expert")
)

(complete 25)

;
; Copy req.library.
;
(copylib (prompt #nowcopying6)
         (help   #nowcopying6help)
         (source (tackon sourcepath "Libs/req.library"))
         (dest   "LIBS:")
         (optional)
         (confirm "average")
)

(complete 35)

;
; Copy amigaguide.
;
(copyfiles (prompt  #nowcopying1)
           (help    #nowcopying1help)
           (source  sourcepath)
           (dest    @default-dest)
           (choices (cat @app-name ".guide"))
           (confirm "expert")
           (infos)
)

(complete 40)

;
; Ask for disk 2.
;
(askdisk (prompt (cat #insertdisk sourcepath2))
         (help   (cat #insertdiskhelp sourcepath2))
         (dest   "InterSpread_2")
)

;
; Copy arexx examples.
;
(if (askbool (prompt  #copyarexx)
             (help    #copyarexxhelp)
             (default 0)
    )
(
   (copyfiles (prompt  #nowcopying5)
              (help    #nowcopying5help)
              (source  (tackon sourcepath2 "ARexx"))
              (dest    (tackon @default-dest "ARexx"))
              (all)
              (confirm "expert")
   )
))

(complete 75)

;
; Copying SpreadSheets/*
;
(set temp1 (tackon @default-dest #spreadsheetdrawername))
(set temp2 (tackon sourcepath2 #spreadsheetdrawername))
(copyfiles (prompt #nowcopying3)
           (help   #nowcopying3help)
           (source temp2)
           (dest temp1)
           (all)
           (confirm "expert")
)

(complete 85)

;
; Ask for disk 1.
;
(askdisk (prompt (cat #insertdisk sourcepath))
         (help   (cat #insertdiskhelp sourcepath))
         (dest   @app-name)
)

;
; Copying amigaguide.library.
;
(copylib (prompt #nowcopying4)
         (help   #nowcopying4help)
         (source (tackon sourcepath "Libs/amigaguide.library"))
         (dest   "LIBS:")
         (optional)
         (confirm "average")
)

(complete 95)

;
; Figuring out which file to put assign in.
;
(set path (getassign "S"))
(if (< osver 36)
(
   (set suggestedfile (tackon path "StartupII"))
)
(
   (set suggestedfile (tackon path "User-Startup"))
))

;
; Check OS version and append @app-name:
;
(set startup-dest
   (askfile (prompt #startupdest)
            (help   #startupdesthelp)
            (default suggestedfile)
   )
)
(set startup-path (pathonly startup-dest))
(set startup-file (fileonly startup-dest))
(set ramname (tackon "RAM:" startup-file))

(textfile (dest ramname)
          (include startup-dest)
          (append "\n;BEGIN " @app-name "\n"
                     "Assign " @app-name ": " @default-dest "\n"
                    ";END " @app-name "\n")
)
(copyfiles (source "RAM:")
           (dest startup-path)
           (choices startup-file)
           (nogauge)
)
(delete ramname)

;
; Installation finished!
;
(message #installfinished)

(complete 100)

;
; Reboot!
;
(run (tackon sourcepath "C/Reboot"))

;
; If something goes wrong the onerror below is called to clean-up.
;
(onerror
   (delete @default-dest)
)
