; This is test of many of the features of the Installer

(set #ZipDev "scsi.device")

(set #ZipReturn
  (run "c/FindZip >env:ZipUnit scsi.device"
    (prompt "Looking for Zip drive....")
  )
)

(if (= #ZipReturn 10)
  (
    (set #zdprompt "Unable to find a Zip drive on scsi.device.\n")
    (set #zdprompt (cat #zdprompt "Please enter the name of the device controlling your Zip drive.\n"))
    (set #zdprompt (cat #zdprompt "(N.B. Device names are case-sensitive - scsi.device\ncannot be referred to as Scsi.Device!)"))
    (set #ZipDev
      (askstring
        (prompt #zdprompt)
        (help @askstring-help)
        (default "scsi.device")
      )
    )
    (set #ZipReturn
      (run ("c/FindZip >env:ZipUnit %s" #ZipDev)
        (prompt "Looking for Zip drive....")
      )
    )
  )
)

(if (= #ZipReturn 10)
  (
    (run ("c/ListDevices >env:unitvolumes %s 0" #ZIPDEV))
    (set #zuchoice0
      (getenv "unitvolumes")
    )
    (run ("c/ListDevices >env:unitvolumes %s 1" #ZIPDEV))
    (set #zuchoice1
      (getenv "unitvolumes")
    )
    (run ("c/ListDevices >env:unitvolumes %s 2" #ZIPDEV))
    (set #zuchoice2
      (getenv "unitvolumes")
    )
    (run ("c/ListDevices >env:unitvolumes %s 3" #ZIPDEV))
    (set #zuchoice3
      (getenv "unitvolumes")
    )
    (run ("c/ListDevices >env:unitvolumes %s 4" #ZIPDEV))
    (set #zuchoice4
      (getenv "unitvolumes")
    )
    (run ("c/ListDevices >env:unitvolumes %s 5" #ZIPDEV))
    (set #zuchoice5
      (getenv "unitvolumes")
    )
    (run ("c/ListDevices >env:unitvolumes %s 6" #ZIPDEV))
    (set #zuchoice6
      (getenv "unitvolumes")
    )

    (set #zuprompt "I still can't find your Zip drive, so you'll have to configure it manually!\n\n")
    (set #zuprompt (cat #zuprompt "Please enter here the unit number of your Zip drive,\nand proceed with EXTREME Caution!"))
    (set #ZipUnit
      (askchoice
        (prompt #zuprompt)
        (help @askchoice-help)
        (choices
          ("Unit 0 (%s)" #zuchoice0)
          ("Unit 1 (%s)" #zuchoice1)
          ("Unit 2 (%s)" #zuchoice2)
          ("Unit 3 (%s)" #zuchoice3)
          ("Unit 4 (%s)" #zuchoice4)
          ("Unit 5 (%s)" #zuchoice5)
          ("Unit 6 (%s)" #zuchoice6)
          ("Other")
        )
        (default 0)
      )
    )
    (if (= #ZipUnit "7")
      (set #ZipUnit
        (asknumber
          (prompt "Ok, what was the unit number?")
          (help @asknumber-help)
        )
      )
    )
    (textfile
      (dest "env:ZipUnit")
      (safe)
      (append #ZipUnit)
    )
  )
)

(
  (set #ZipUnit (getenv "ZipUnit"))
  (textfile
    (dest "env:ZipDev")
    (safe)
    (append #ZipDev)
  )
)

(message ("The Zip utilities have been set up to use a\nZip drive on %s, unit %s." #ZipDev #ZipUnit))

(if (= @user-level 2)
  (set #EZLocation
    (askdir
      (Prompt "Where would you like the ZipWatch utility installed?")
      (help "ZipWatch is a utility which allows you to change zip disks without rebooting.  Placing it in your WBStartup drawer means it will always be available.")
      (Default "SYS:Utilities")
    )
  )
  (set #EZLocation "SYS:Utilities")
)

(if (= @user-level 2)
  (set #APLocation
    (askdir
      (Prompt "Where would you like the ATAPatch utility installed?")
      (help "ATAPatch is a tiny utility which might be needed with certain CD-ROM drivers.")
      (Default "C:")
    )
  )
  (set #APLocation "C:")
)

(set #DocLocation
  (askdir
    (Prompt "Where would you like the documentation installed?\n(No new directory will be created.)")
    (help "There are documents detailing the use of the ZipWatch programs.")
    (Default "sys:Zip_Prep_Tools")
  )
)

(copyfiles
  (prompt "Installing ZipWatch.")
  (source "ZipWatch")
  (dest #EZLocation)
)

(copyfiles
  (prompt "Installing ZipWatch.")
  (source "ZipWatch.info")
  (dest #EZLocation)
)

(copyfiles
  (prompt "Intalling ATAPatch.")
  (source "c/ATAPatch")
  (dest #APLocation)
)

(copyfiles
  (prompt "Installing the documentation.")
  (source "ZipWatch.guide")
  (dest #DocLocation)
)

(copyfiles
  (prompt "Installing the documentation.")
  (source "Zip Instructions")
  (dest #DocLocation)
)

(copyfiles
  (prompt "Installing the documentation.")
  (source "Zip Instructions.info")
  (dest #DocLocation)
)

(copyfiles
  (prompt "Installing the documentation.")
  (source "muchmore")
  (dest #DocLocation)
)

(copyfiles
  (prompt "Copying environment variables to ENVARC:")
  (source "Env:ZipDev")
  (dest "EnvArc:")
)

(copyfiles
  (prompt "Copying environment variables to ENVARC:")
  (source "Env:ZipUnit")
  (dest "EnvArc:")
)

(message "You have just installed ZipWatch, which is a small part of the IDEZipTools package.   For information about ordering the complete package, please refer to the documentation.")

