; $VER: Digita Wordworth 7 (English)
; Copyright (C) Digita International Ltd.
; Installer by Mark Jackson


; ### STRING DEFINITIONS

(set #ProgName "Wordworth 7")
(set #DrawerName "Wordworth7")

(set #Install1Disk "Ww7Install-1")
(set #Install2Disk "Ww7Install-2")
(set #Install3Disk "Ww7Install-3")
(set #Install4Disk "Ww7Install-4")

(set #InstallCD "Wordworth7")

(set #Yes "Yes")
(set #No "No")

(set #WorkingMsg (cat "\n\nPlease wait...\n\n" #ProgName " is being installed to your hard disk."))

(set #WorkingPrinterMsg "\n\nPlease wait... Installing printer.")

(set #InstallingFontsMsg "\n\nPlease wait... Installing fonts.")

(set #CheckStartup "\n\nPlease wait...\n\nThe installer is checking your system.")

(set #InsertDiskMsg "\nPlease insert the disk labelled\n\n%s")

(set #DiskHelp
   (cat "\nIf you know that the correct disk is in the drive, but you still cannot proceed, "
      "the name of the disk is incorrect.\nEnsure that the disk name is not preceded by "
      "'copy_of_' and there are no blank spaces before or after the disk name.\n\n" @askdisk-help
   )
)

(set #UnpackMsg "Unarchiving %s to %s\n\nPlease wait...")

(set #ArchiveAbortMsg
   (cat "There was a problem when trying to dearchive '%s'.\n\nPlease try installing to a "
   "different drawer or partition, or contact Digita Technical Support."
   )
)

(set #InstallBOPrompt
   (cat "\nDo you wish to install your Workbench Compugraphic fonts for use with " #ProgName "?"
   )
)

(set #InstallBOPrompt-Help
   (cat "\nYou may have Compugraphic fonts in the '_bullet_outlines' drawer in the 'Fonts' "
      "drawer of your Workbench partition.\n\nIf you click '" #Yes "' then " #ProgName " will "
      "allow you to use any fonts you have in this drawer.\nClick '" #No "' if you do not want "
      "to install these fonts."
   )
)

(set #DestChoiceMsg (cat "Where do you want to create the\n\"" #ProgName "\" drawer?"))

(set #DestChoiceHelp
   (cat "Select where on your hard disk you want to install " #ProgName " then click "
   "\"Proceed\". A new drawer called \"" #DrawerName "\" will be created and will contain the "
   #ProgName " program and files."
   )
)

(set #DriveStartsWithHyphenMsg
   (cat "It is not possible to install " #ProgName " to a partition whose name starts with a "
  "'-'.\n\nEither rename this partition, or choose a different destination."
   )
)

(set #NoDiskSpaceMsg
   (cat "\nThere is insufficient free space on your hard disk partition to install " #ProgName
   ". You will need a minimum of 3.5MB of free disk space.\n\nEither click \"Abort Install\" "
   "to exit this installation and delete some files from your hard disk, or click \"Proceed\" "
  "and try a different partition."
   )
)

(set #AskEnvStartup
   (cat "\nYour system user startup sequence did not contain an assign for ENV: Do you wish "
   "to add this assign to your \"S:User-Startup\" file?"
   )
)

(set #AskEnvStartupHelp
   (cat "\nSelect '" #Yes "' to add an assign to the user-startup file.\n\n" @startup-help
   )
)

(set #DriverUsedMsg
   (cat "\n\nThe standard Workbench printer driver for the printer you chose, '%s', has been "
   "installed."
   )
)

(set #InstallPicassoMsg "\nDo you have a Picasso or similar graphics card?")
(set #InstallPicassoHelp
   (cat "\n" #ProgName " has improved compatibility with third party graphics cards, like the "
   "Picasso or Retina.\n\nTo inform Wordworth that you are using a graphics card, a tooltype "
   "has to be added to the Wordworth program icon.\n\nIf you have a graphics card then click '"
   #Yes "' to add a 'PICASSO' tooltype to the program icon.\nClick '" #No "' to not add this "
   "tooltype.\n\nIf you are using CyberGraphX software and you experience problems running "
   "Wordworth then try removing the 'PICASSO' tooltype on the Wordworth program icon."
   )
)

(set #TurboCalcMsg "\nDo you have TurboCalc installed on your hard-disk?")
(set #TurboCalcHelp
   (cat "\n" #ProgName " can import TurboCalc spreadsheets directly into a table.\n\nThe "
   "installer needs to know where you save your TurboCalc spreadsheets on your hard-disk so "
   "Wordworth can look in this drawer when you choose 'Place Table' (Object menu)."
   )
)

(set #TurboCalcDestChoiceMsg
   "Please select the drawer on your hard-disk where you save your TurboCalc spreadsheets."
)

(set #TurboCalcDestChoiceHelp
   (cat "Select the drawer on your hard-disk where you save your TurboCalc spreadsheets, "
   "the installer will set a tooltype on the Wordworth program icon 'TABLES' which will point "
   "to this drawer.\n\nThis can be changed if you prefer another default drawer."
   )
)

(set #UpgradeWordworthMsg
   (cat "\nDo you want to upgrade the copy of Wordworth in %s to " #ProgName "?")
)

(set #UpgradeWordworthYes "Upgrade")
(set #UpgradeWordworthNo "Choose new destination")

(set #UpgradeWordworthHelp
   (cat "The installer has detected an existing copy of Wordworth on the hard-disk which can "
   "be upgraded to " #ProgName ".\n\nClick '" #UpgradeWordworthYes "' to upgrade this copy of "
   "Wordworth to " #ProgName ".\nClick '" #UpgradeWordworthNo "' to choose a new destination "
   "to install " #ProgName "."
   )
)

(set #UpgradeWordworthHelpNovice
   (cat "The installer has detected an existing copy of Wordworth on the hard-disk which can "
   "be upgraded to " #ProgName ".\n\nClick '" #Yes "' to upgrade this copy of Wordworth to "
   #ProgName ".\nClick '" #No "' to install " #ProgName " in the default location."
   )
)


;### INSTALLER PROCEDURE DEFINITIONS

;** Procedure to decompress file '#UnpackFile' to '#UnpackDest'
(procedure @UnpackFiles
   (
      (working (#UnpackMsg #UnpackFile #UnpackDest))

      (set #ArchiveError 0)
      (set #RunLha (cat "WwTemp:Lhx -I -m e \"" #UnpackFile "\" \"" #UnpackDest "\""))

      (set #ArchiveError (run #RunLha))

      (if (> #ArchiveError 0)
         (
            (abort (#ArchiveAbortMsg #UnpackFile))
         )
      )
   )
)

;** Procedute to get disk specified in '#FileSourceDisk'
(procedure @GetDisk
   (
      (askdisk
         (prompt (#InsertDiskMsg #FileSourceDisk))
         (help #DiskHelp)
         (dest #FileSourceDisk)
      )
   )
)

;** Procedure to clean up our temporary files
(procedure @CleanUp
   (
      (delete "WwTemp:#?" (all))
      (makeassign "WwTemp")
      (delete "Ram:WwTemp")
   )
)


;### BEGINNING OF MAIN ROUTINE

(if (not (exists "Ram:WwTemp"))
   (
      (makedir "Ram:WwTemp")
   )
)

(makeassign "WwTemp" "Ram:WwTemp")

(onerror (@CleanUp))

(complete 0)

(welcome)

(complete 20)

(working #CheckStartup)

(set #FileSourceDisk #InstallCD)
(@GetDisk)

(copyfiles
   (source "Utilities/Lhx")
   (dest "WwTemp:")
   (nogauge)
)

(copyfiles
   (source "Utilities/WritePrefs3")
   (dest "WwTemp:")
   (nogauge)
)

(copyfiles
   (source "Utilities/Select")
   (dest "WwTemp:")
   (nogauge)
)

(copyfiles
   (source "Utilities/WwPrinterList")
   (dest "WwTemp:")
   (nogauge)
)

(complete 40)

(set #ChosenDriver "Generic")

(set #DriverSource "PrinterDrivers")
(set #FontSource "PrinterFonts")

(working #WorkingPrinterMsg)

(run "WwTemp:Select WwTemp:WwPrinterList")

(complete 60)

(set #ChosenDriver (getenv "WwDriver"))
(set #TopBord (getenv "WwTop"))
(set #BotBord (getenv "WwBottom"))
(set #LeftBord (getenv "WwLeft"))
(set #RightBord (getenv "WwRight"))

(set #FileSourceDisk #InstallCD)
(@GetDisk)

(set #UnpackFile (cat #Driversource "/" #ChosenDriver))
(set #UnpackDest "WwTemp:")
(@UnpackFiles)

(complete 80)

(set #DriverName (substr #ChosenDriver 0 (- (strlen #ChosenDriver) 4)))

(copyfiles
   (source (cat "WwTemp:" #DriverName))
   (dest "DEVS:Printers")
   (optional "force")
)

(if (exists "Ram:Script")
   (
      (makedir "WwTemp:WwFonts")

      (set #FileSourceDisk #InstallCD)
      (@GetDisk)

      (execute "Ram:Script")

      (foreach "WwTemp:WwFonts" "#?.lha"
         (
            (set #UnpackFile (tackon "WwTemp:WwFonts" @each-name))
            (set #UnpackDest "FONTS:")
            (@UnpackFiles)
         )
      )

      (delete "Ram:Script")
   )
)

(@CleanUp)

(complete 100)

(message #InstallationCompleteMsg (#DriverUsedMsg #DriverName))
(exit (quiet))
