; Install-Script for DLG Pro Debugger
; Begin header segment

(user 2)
(welcome)

(set #dlg-version "2.1")
(set #Type 1)
(set #MinLibVer 6)

; Check installer version

(set ver @installer-version)
(set ver (/ ver 65536))

(if
   (< ver 43)
   (
      (abort
         (cat  "This installer script requires V43 of the Amiga Installer. You will need a copy of the V43 "
               "Installer in your command path (C: or Sys:) or change the icon of this installer to point to "
               "wherever you have your installer at. You may download Installer V43 from AmiNet, from the DLG "
               "web site ( http://www.ald.net/dlg ) or contact Digerati Dreams for a copy of the V43 installer."
         )
      )
   )
)


; check for workbench 2.x

(set ver (getversion))
(set ver (/ ver 65536))

(if (< ver 37)
   (Abort
      (cat  "DLG "
            #dlg-version
            " needs KickStart 2.04 (v37) or later. It seems not to be installed on your system."
      )
   )
)

; check for DLG library version

(set ver (getversion "dlg.library" (resident) ))
(set ver (/ ver 65536))

(if (< ver #MinLibVer)
   (Abort
      (cat  "The debug software needs dlg.library version V"
            #MinLibVer
            " or later. You should install the latest version of DLG to use this software"
      )
   )
)

; End Header segment

;;; Begin Type selection

(set #Type

   (AskChoice
      (prompt "Please choose what you want to do: ")
      (help (cat  "You can choose to install or uninstall the debug modules. Uninstalling is harmless, no "
                  "matter how many times you repeat it."
            )
      )
      (Choices "Install Debug Code" "Remove Debug Code")
      (Default 1)
   )
)


;;- End Type Selection

;;; Begin Copying files

(if
   (= #Type 1)
   (  ;  Uninstall debug modules
      (copyfiles
         (prompt "Copying ResMan (regular) to DLG:")
         (help @copyfiles-help)
         (source "DLG/ResMan")
         (dest "DLG:")
      )
      (copyfiles
         (prompt "Copying TPT-Handler (regular) to L:")
         (help @copyfiles-help)
         (source "L/TPT-Handler")
         (dest "L:")
      )

      (Delete "DLG:DLGDebug"
         (Prompt "DLGDebug is no longer needed. File will be deleted.")
         (Help "The program DLG:DLGDebug will be deleted if you agree. No harm is done by keeping it.")
         (Confirm)
      )

   )
   (  ;  Install debug modules
      (copyfiles
         (prompt "Copying DLGDebug to DLG:")
         (help @copyfiles-help)
         (source "DLG/DLGDebug")
         (dest "DLG:")
      )
      (copyfiles
         (prompt "Copying ResMan (debug) to DLG:")
         (help @copyfiles-help)
         (source "DLG/ResMan.debug")
         (dest "DLG:")
         (NewName "ResMan")
      )
      (copyfiles
         (prompt "Copying TPT-Handler (debug) to L:")
         (help @copyfiles-help)
         (source "L/TPT-Handler.debug")
         (dest "L:")
         (NewName "TPT-Handler")
      )
   )
)

;;- End copying

;;; Begin exit

(exit
   (Cat
      "Installation (or removal) is complete! You will need to edit your S:User-Startup file in order "
      "to use DLGDebug. If you were using it and have removed it, you will need to remove its entry from "
      "your startup file. Please read Debug.guide for more information!\n\n"
      "A FULL REBOOT IS REQUIRED to get everything working right."
   )
   (quiet)
)

;;;- End Exit

