(set thisver 1)
(set thisrev 1)

(procedure setlanguage
(

; english strings
;
(if (= @language "english")
(

(set #CheckInst
(cat "Checking Installationfiles"
))

(set #NoTE
(cat "The TimeEvent executeable can't be found. "
     "A installation without the program makes no sense. "
     "Try to get the original archive of TimeEvent %ld.%ld"
))

(set #MissingFiles
(cat "There are missing files in the archive.\n"
     "This are the files that couldn't be found:\n\n" 
))

(set #AskContinue
(cat "\nContinue with installation?"
))

(set #AskOldTE
(cat "There is another copy of TimeEvent in this directory.\n\n"
))

(set #ThisVer
(cat "This Version : %ld.%ld\n"
))

(set #OtherVer
(cat "Version in %s : %ld.%ld\n\n"
))

(set #AskOverwrite
(cat "Overwrite version in %s?"
))

(set #CopyTE
(cat "Copy TimeEvent"
))

(set #AskDocDir
(cat "Where should I install the Documentation?"
))

(set #CopyDoc
(cat "Copy Document"
))

(set #AskLocaleDir
(cat "Where should I install the english catalog file?"
))

(set #CopyCatalog
(cat "Copy language catalog"
))

(set #AskEnvCp
(cat ("With version %ld.%ld" thisver thisrev) " of TimeEvent the TimeEvent.prefs file moved from "
     "ENVARC:Sys (ENV:Sys) to ENVARC: (ENV:). Should I move your old TimeEvent.prefs file "
     "to the new location?"
))

(set #CopyEnv
(cat "Moving old TimeEvent.prefs"
))
   
(set #AskSCp
(cat "There exists a crontab in S:. Should I use its contents for TimeEvent?"
))

(set #CopyS
(cat "Moving crontab"
)) 

(set #AskDelS
(cat "Remove S:crontab?"
))

(set #AskCC
(cat "Do you use the program CyberCron?"
))

(set #AskModify
(cat "Should I add the tooltype\n\n"
     "CRONTAB=ENV:TimeEvents.prefs\n\n"
     "in the CyberCron icon?"
))

(set #AskCCfile
(cat "Please select the CyberCron executeable"
))

(set #NoCC
(cat "You have to setup your Cron program, so that it uses the file\n\n"
     "ENV:TimeEvent.prefs\n\n"
     "as the CronTab. Read the manual to your Cron program to see how this "
     "can be achieved. Refer also to the chapter in the TimeEvent "
     "documentation, which regards to that topic."
))

(set #NoToolType
(cat "If you execute CyberCron from the User-Startup script, you have to "
     "add\n\n"
     "CRONTAB=ENV:TimeEvent.prefs\n\n"
     "to the call. You can find more details about the possible cli options "
     'in the CyberCron documentation (chapter "Starting CyberCron"). '
     "Read also the specific chapter in the TimeEvent documentation."
))

)) ; end english strings

; deutsche strings
;
(if (= @language "deutsch")
(

(set #CheckInst 
(cat "Überprüfe Installationsdateien"
))

(set #NoTE
(cat "Das Programm TimeEvent kann nicht gefunden werden. "
     "Ohne dieses macht eine Installation wohl wenig Sinn, oder? "
     "Versuchen Sie das Originalarchiv von TimeEvent %ld.%ld zu bekommen."
))

(set #MissingFiles
(cat "Das Installationsarchiv ist unvollständig.\n"
     "Die folgenden Dateien konnten nicht gefunden werden:\n\n" 
))

(set #AskContinue
(cat "\nWeitermachen mit der Installation?"
))

(set #AskTEDir
(cat "In welchem Verzeichnis soll TimeEvent installiert werden?"
))

(set #AskOldTE
(cat "In diesem Verzeichnis existiert schon eine Kopie von TimeEvent.\n\n"
))

(set #ThisVer
(cat "Diese Version : %ld.%ld\n"
))

(set #OtherVer
(cat "Version in %s : %ld.%ld\n\n"
))

(set #AskOverwrite
(cat "Version in %s überschreiben?"
))

(set #CopyTE
(cat "Kopiere TimeEvent"
))

(set #AskDocDir
(cat "In welches Verzeichnis soll die Dokumentation kopiert werden?"
))

(set #CopyDoc
(cat "Kopiere Dokumentation"
))

(set #AskLocaleDir
(cat "In welches Verzeichnis soll die deutsche Sprachdatei kopiert werden?"
))

(set #CopyCatalog
(cat "Kopiere Sprachdatei"
))

(set #AskEnvCp
(cat ("Ab der Version %ld.%ld" thisver thisrev) " liegt die Datei TimeEvent.prefs in "
     "ENVARC: (ENV:) anstatt in ENVARC:Sys (ENV:Sys). Soll die alte TimeEvent.prefs "
     "Datei in diese Verzeichnisse geschoben werden?"
))

(set #CopyEnv
(cat "Verschiebe alte TimeEvent.prefs Datei"
))
   
(set #AskSCp
(cat "Es existiert eine Datei S:crontab. Soll deren Inhalt für TimeEvent übernommen "
     "werden?"
))

(set #CopyS
(cat "Verschibe crontab"
)) 

(set #AskDelS
(cat "S:crontab löschen?"
))

(set #AskCC
(cat "Benutzen Sie das Programm CyberCron?"
))

(set #AskModify
(cat "Soll im CyberCron Pictogramm das Merkmal\n\n"
     "CRONTAB=ENV:TimeEvents.prefs\n\n"
     "eingetragen werden?"
))

(set #AskCCfile
(cat "Bitte wählen Sie das CyberCron Program aus"
))

(set #NoCC
(cat "Sie müssen ihr Cron Programm so aufrufen, daß dieses die Datei\n\n"
     "ENV:TimeEvent.prefs\n\n"
     "als CronTab verwendet. In der Dokumentation zu diesem Programm "
     "sollte ersichtlich sein, wie dies zu erreichen ist. Lesen dazu auch "
     "das ensprechende Kapitel in der Dokumentation zu TimeEvent."
))

(set #NoToolType
(cat "Falls Sie CyberCron aus dem User-Startup Skript starten, müssen "
     "Sie den Parameter\n\n"
     "CRONTAB=ENV:TimeEvent.prefs\n\n"
     "beim Aufruf ergänzen. Weitere Einzelheiten zu den möglichen "
     "Aufrufparametern erfahren Sie in der Dokumentation zu CyberCron "
     '(Kapitel "Starting CyberCron"). '
     "Lesen Sie dazu auch das ensprechende Kapitel in der Dokumentation "
     "zu TimeEvent."
))

)) ; ende deutsche strings

)) ; end of proc

(procedure checkfiles 
   (
      (working #CheckInst)
      (if (NOT (exists "/Prefs/TimeEvent"))
         (abort (#NoTE thisver thisrev))
      )
      (set n 0)
      (while (set thisfile (select n "/Prefs/TimeEvent.info"
                                     (cat "/Doc/" @language ".guide")
                                     (cat "/Doc/" @language ".guide.info")
                                     "/README"
                                     "/README.info"
                                     ""))
         (
            (set n (+ n 1))
            (if (NOT (exists thisfile))
               (set missing (cat missing thisfile "\n"))
            )
         )
      )
      
      (if (<> missing <NIL>)
         (if 
            (askbool
               (prompt #MissingFiles missing #AskContinue)
               (help @askbool-help)
               (default 0)
            )
            (set n 0)
            (exit (quiet))
         )
      )
   )
)

(user 2)
(setlanguage)
(checkfiles)
(user 1)
(welcome)

(set destdir
   (askdir 
      (prompt #AskTEDir)
      (help @askdir-help)
      (default "Workbench:Prefs")
   )
)

(set @default-dest destdir)

(if 
   (exists (cat @default-dest "/TimeEvent") (noreq))
   (
      (set vernum (getversion (cat @default-dest "/TimeEvent")))
      (set ver (/ vernum 65536))
      (set rev (- vernum (* ver 65536)))
         (if
            (askbool 
               (prompt #AskOldTE (#ThisVer thisver thisrev) (#OtherVer @default-dest ver rev)
                       (#AskOverwrite @default-dest))
               (help @askbool-help)
               (default 0)
            )
            (set n 0)
            (exit (quiet))
         )
   )
)

(copyfiles
   (prompt #CopyTE)
   (help @copyfiles-help)
   (source "/Prefs/TimeEvent")
   (dest @default-dest)
   (infos)
   (optional force askuser)
)

(set docdir
   (askdir 
      (prompt #AskDocDir)
      (help @askdir-help)
      (default "Workbench:Prefs")
   )
)

(copyfiles
   (prompt #CopyDoc)
   (help @copyfiles-help)
   (source (cat "/Doc/" @language ".guide"))
   (newname "TimeEvent.guide")
   (dest docdir)
   (infos)
   (optional force askuser)
)

(if 
   (NOT (= @language "english"))
   (
      (set localedir
         (askdir 
            (prompt #AskLocaleDir)
            (help @askdir-help)
            (default (cat "LOCALE:Catalogs/" @language))
         )
      )
      (copyfiles
         (prompt #CopyCatalog)
         (help @copyfiles-help)
         (source (cat "/Catalogs/" @language "/TimeEvent.catalog"))
         (dest localedir)
         (infos)
         (optional force askuser)
      )
   )
)

(if
   (exists ("ENVARC:Sys/TimeEvent.prefs") (noreq))
      (if
         (askbool
            (prompt #AskEnvCp)
            (help @askbool-help)
            (default 1)
         )
         (
            (copyfiles
               (prompt #CopyEnv)
               (help @copyfiles-help)
               (infos)
               (optional force askuser)
               (source "ENVARC:Sys/TimeEvent.prefs")
               (dest "ENVARC:")
               (optional nofail force askuser)
            )
            (copyfiles
               (prompt #CopyEnv)
               (help @copyfiles-help)
               (infos)
               (optional nofail force askuser)
               (source "ENV:Sys/TimeEvent.prefs")
               (dest "ENV:")
            )
            (delete "ENVARC:Sys/TimeEvent.prefs" (optional force askuser))
            (delete "ENV:Sys/TimeEvent.prefs" (optional force askuser))
         )
      )
      (if
         (exists ("S:crontab") (noreq))
         (if
            (askbool
            (prompt #AskSCp)
            (help @askbool-help)
            (default 1)
         )
         (
            (copyfiles
               (prompt #CopyS)
               (help @copyfiles-help)
               (infos)
               (optional force askuser)
               (source "S:crontab")
               (dest "ENVARC:")
               (newname "TimeEvent.prefs")
            )
            (copyfiles
               (prompt #CopyS)
               (help @copyfiles-help)
               (infos)
               (optional force askuser)
               (source "S:crontab")
               (dest "ENV:")
               (newname "TimeEvent.prefs")
            )
            (delete "S:crontab" (confirm) (prompt #AskDelS) (help @delete-help))
         )
      )
   ) 
)



(if 
   (askbool
      (prompt #AskCC)
      (help @askbool-help)
      (default 1)
   )
   (if
      (askbool
         (prompt #AskModify)
         (help @askbool-help)
         (default 0)
      )
      (
         (set CCfile
            (askfile
               (prompt #AskCCfile)
               (help @askfile-help)
               (default "Workbench:WBStartup")
            )
         )
         (tooltype
            (dest CCfile)
            (settooltype "CRONTAB" "ENV:TimeEvent.prefs")
         )
      )
      (message #NoToolType)
   )
   (message #NoCC)
)