(complete 0)

(set VAR_LANGUAGE (getenv "Language"))

; English strings, used as standard

(set TXT_INTRO         "\nChoowin will now be installed.\n\nIf you do not like this program, just remove Choowin and Choowin.guide to deinstall.\n")
(set TXT_WRONGOS       "Sorry, this program needs OS 3.5 because it uses the reaction GUI.\n")
(set TXT_PATH          "Into which directory shall the program be copied?")
(set TXT_PATH_HELP     "\nThere will NO directory be created.\nUse 'sys:wbstartup' to start Choowin automatically.\n")
(set TXT_PREFFILE      "Do you wish to keep your old preferences ?")
(set TXT_PREFFILE_HELP "\nChoowin stores its preferences in its icon.\nIf you decide to keep your old preferences, the icon will not be copied.")
(set TXT_GUIDE         "Where shall I place the manual ?")
(set TXT_GUIDE_HELP    "\nThe manual should not becopied to sys:wbstartup, simply choose the directory where all the other manuals reside.")
(set TXT_MAIN          "Copying Program files ...")
(set TXT_MAIN_HELP     "\nAll the files that are needed are copied.\n")

; Supported languages

(
 if (= VAR_LANGUAGE "deutsch") (
  (set TXT_INTRO        "\nChoowin wird nun installiert.\n\nWenn Ihnen dieses Programm nicht gefällt, löschen sie zur Deinstallation einfach die Dateien Choowin und Choowin.guide.\n")
  (set TXT_WRONGOS      "Leider benötigt dieses Programm OS 3.5, da es das Reaction GUI nutzt.\n")
  (set TXT_PATH         "In welches Verzeichnis soll das Programm kopiert werden?")
  (set TXT_PATH_HELP    "\nEs wird KEIN eigenes Verzeichnis.\nWählen Sie 'sys:wbstartup', um Choowin automatisch zu starten.")
  (set TXT_PREFFILE      "Wollen Sie ihre alten Einstellungen beibehalten?")
  (set TXT_PREFFILE_HELP "\nChoowin speichert Einstellungen in seinem Icon.\nWenn Sie sich entscheiden, Ihre alten Einstellungen zu behalten, wird das Icon nicht kopiert.")
  (set TXT_GUIDE         "Wohin soll die Anleitung kopiert werden ?")
  (set TXT_GUIDE_HELP    "\nDie Anleitung sollte nicht in sys:wbstartup gespeichert werden, wählen Sie einfach das Verzeichnis, indem sich alle anderen Anleitungen befinde.")
  (set TXT_MAIN         "Kopiere Programmdateien ...")
  (set TXT_MAIN_HELP    "\nAlle nötigen Dateien werden kopiert.\n")
 )
)

; Get the OS-version to see if it is at least OS 3.5

(set VAR_OS (/ (getversion) 65536))
(if (< VAR_OS 40) (message TXT_WRONGOS))

(complete 10)

(message TXT_INTRO)

; Get the directory to install to

(complete 20)

(
 set VAR_PROGRAM(
   askdir (prompt  TXT_PATH)
          (help    TXT_PATH_HELP)
          (default "SYS:WbStartup")
  )
)
(set @default-dest VAR_PROGRAM)

(
 if( exists (tackon VAR_PROGRAM "Choowin"))(
  set VAR_KEEPPREFS(
   askbool (prompt TXT_PREFFILE)
           (help TXT_PREFFILE_HELP)
  )
 )(
  set VAR_KEEPPREFS 1
 )
)

(
 set VAR_MANUAL(
   askdir (prompt  TXT_GUIDE)
          (help    TXT_GUIDE_HELP)
          (default "HELP:")
  )
)


(complete 40)

; And now copy all the files

(
 copyfiles (prompt TXT_MAIN)
           (source (tackon @execute-dir "Choowin"))
           (dest   VAR_PROGRAM)
)

(
 if( = VAR_KEEPPREFS 0 )(
  copyfiles (prompt TXT_MAIN) (source (tackon @execute-dir "Choowin.info")) (dest VAR_PROGRAM)
 )
)

(complete 70)

(
 copyfiles (prompt TXT_MAIN)
           (source (tackon @execute-dir "Choowin.guide"))
           (dest   VAR_MANUAL)
           (infos)
)

(complete 100)
