;  
;  MagnifiCAD Installation Script.
; 
;  v1.2, (C)1995-96 Anders Granli.
;  
;  01.12.96


(set @user-level 1)
(welcome "\nWelcome to the installation\nof MagnifiCAD (v1.2)")


(message ("\nWelcome to the installation of MagnifiCAD!\n\nYou need about 650KB of free space on your\n hard drive for this installation.") )

; **
; ** Check kickstart version
; **

(set version (/ (getversion) 65536))

(if(< version 37)
(Exit "\nYou need at least Workbench 2.0\nto run MagnifiCAD.\n" ) 
)

(if (< version 39)
   (set cont 
      (askbool 
         (prompt (cat "\nYou have kickstart 2.0.\n\n "
            "MagnifiCAD will work under 2.0,\n "
            "but may have some slight problems.\n "
            "Proceed to Install?\n " ))
         (help (cat "\nIf you don't have Kickstart 3.0 or\n"
                    "higher, some things just won't work." ))
      )
   )
)

; ** 
; ** Check processor
; ** 

(
   (set proc (database "cpu"))
)


; **
; ** Unpack to RAM:
; ** 

(run "lha e MagnifiCAD.lha RAM:temp/")

; ** 
; ** Ask where to install the program
; **

(set @default-dest "Work:")

(set Destination
   (askdir
      (prompt (cat "\nSelect the drawer where you would like\n"
              "the drawer containing\nMagnifiCAD to be installed.\n") )
      (help   (cat "\nA drawer named MagnifiCAD will be created in the\n"
              "drawer you select, and the program and all the files\n"
              "will be copied into this new drawer.") ) 
      (default @default-dest)
   )
)

;(if(<>(exists Destination) 2)
;   (makedir Destination (infos)))

(set @default-dest Destination)

(complete 10)

(set @default-dest 
   (tackon Destination "MagnifiCAD")
)

(makedir @default-dest
   (prompt "Creating MagnifiCAD drawer.")
   (infos)
)

(complete 20)

; ** 
; ** Assign
; **
    
(makeassign "MagnifiCAD" @default-dest)
(complete 30)

; **
; ** Fonts
; **

(if(exists "fonts:newtopaz.font")
   (
      (set installfont 0)
   )
   ; else
   (set installfont
      (askbool 
         (prompt (cat "\nMagnifiCAD needs the newtopaz.font\n\n "
            "Shall I install the font in your FONTS: drawer?" ))
         (help (cat "This copies the font to FONTS:."
               "The newtopaz.font is needed for\nMagnifiCAD to work."))
      )
   )
)

(if installfont 
   (copyfiles
      (prompt "Copying newtopaz.font to Fonts: directory")
      (help @copyfiles-help)
      (source "ram:temp/Fonts")
      (all)
      (dest "Fonts:")
      (fonts)
   )
)
(complete 40)

; **
; ** Libs
; **

(if(exists "libs:easyrexx.library")
   (
      if(<= (getversion "ram:temp/easyrexx.library")
            (getversion "libs:easyrexx.library"))
      (
         ;(prompt ("newtopaz.font is already\ninstalled in your system"))
         (set installib 0)
      )
   )
   ; else
   (set installib
      (askbool 
         (prompt (cat "\nMagnifiCAD needs the 'easyrexx.library'\n\n "
            "Shall I install the library in your LIBS: drawer?" ))
         (help (cat "This copies the 'easyrexx.library' to LIBS:"
                    "EasyRexx.library is used for ARexx handling"
                    "in MagnifiCAD"))
      )
   )
)

(if installib 
   (copyfiles
      (prompt "Copying 'easyrexx.library' to LIBS: directory")
      (help @copyfiles-help)
      (source "ram:temp/easyrexx.library")
      (dest "LIBS:")
   )
)


(complete 50)      

; **
; **  Install program
; **


(if (< proc 68020)
   (copyfiles
     (prompt "Copying MagnifiCAD program...\n\n(68000 version)")
      (source "ram:temp/MagnifiCAD.000")
      (dest "MagnifiCAD:")
      (newname "MagnifiCAD")
      (infos)
      (help @copyfiles-help)
   )
   (copyfiles
      (prompt "Copying MagnifiCAD program...\n\n(68020 version)")
      (source "ram:temp/MagnifiCAD")
      (dest "MagnifiCAD:")
      (infos)
      (help @copyfiles-help)
   )
)
(complete 60)

(copyfiles
   (prompt "Copying MagnifiCAD files to DEST:")
   (help @copyfiles-help)
   (choices "ReadMe.guide"
            "ram:temp/Drawings"
            "ram:temp/Symbols"
            "ram:temp/Prefs"
            "ram:temp/Docs"
            "ram:temp/ARexx"
   )
   (infos)
   (source "")
   (dest "MagnifiCAD:")
)
(complete 70)

(copyfiles
   (choices "ram:temp/Icons")
   (source "")
   (dest "MagnifiCAD:")
)

(copyfiles 
   (prompt "Copying Drawings & Symbols")
   (source "ram:temp/Drawings/")
   (pattern "#?")
   (dest "MagnifiCAD:Drawings/")
   (infos)
)

(copyfiles 
   (source "ram:temp/Symbols/") 
   (all)
   (dest "MagnifiCAD:Symbols/") 
   (infos)
)
(complete 80)

(copyfiles 
   (source "ram:temp/Prefs/") 
   (pattern "#?")
   (dest "MagnifiCAD:Prefs") 
   (infos)
)

(copyfiles 
   (source "ram:temp/Docs/") 
   (pattern "#?")
   (dest "MagnifiCAD:Docs") 
   (infos)
)

(copyfiles 
   (source "ram:temp/Icons/") 
   (pattern "#?")
   (dest "MagnifiCAD:Icons") 
)
(complete 90)

; AREXX
;(set rexxdir
;   (askdir
;      (prompt "Where shall I put the ARexx scripts?")
;      (default "MagnifiCAD:ARexx/")
;      (newpath "MagnifiCAD:ARexx/")
;      (help "Select a directory to put the MagnifiCAD\nARexx scripts in.")
;   )
;)

(copyfiles
   (prompt "Copying ARexx scripts...")
   (pattern "#?")
   (source "ram:temp/ARexx/")
   (dest "MagnifiCAD:ARexx")
   (infos)
)

(complete 95)


(if(exists "magnificad.keyfile")
  (copyfiles 
    (prompt (cat "This is the registered version of MagnifiCAD.\n\n"
                 "Now about to copy your personal keyfile\n"
                 "to the MagnifiCAD drawer."))
    (source "magnificad.keyfile")
    (dest "MagnifiCAD:")
    (confirm)
  )
)

(run "delete ram:temp all")

(complete 100)
(message "\n\nMagnifiCAD is now installed and set up for use.\n\nRemember that this is a ShareWare release ;-)")

