; Installer Script for AmiBroker 1.90
; Revision 5.
; October 27th, 1996  Tomasz Janeczko, TJ Productions.
; $VER: Install-AmiBroker 5 (27 Oct 1996)
;

; ********* English strings (default)

(set #badkick "I'm sorry, but AmiBroker requires OS 2.04 or better")
(set #welcome (cat "\nAmiBroker 1.90\nHard Disk Install Script Rev 5.\n"
                   "Copyright (C)1995-96 by Tomasz Janeczko\n\n"
                   "This is SHAREWARE product, so if you use it you should register\n\n\n"
                   "ReqTools (C)1991-95 Nico Franois\n"
                   "SAS/C (C)1988-93 SAS Institute Inc.\n"
                   "Installer (C)1991-93 Commodore-Amiga, Inc.") )

(set #destination "Where do you want to install AmiBroker? ( 'AmiBroker' drawer will be created there )" )
(set #programver  "Which version of AmiBroker do you want to install" )
(set #progverhelp (cat "\nAmiBroker - this version is for 68000+ processors and will work on all Amigas.\n\n"
                       "AmiBroker.FPU - this version is for 68020+ and 68882 floating point coprocessor "
                       "or 68040/060. Will work only on accelerated Amigas" ))

(set #olddataexist (cat "You have stock database already installed in your 'data' directory\n"
                        "Please select desired action:" ))

(set #dataexisthelp (cat "\nOption:'replace old data' will erase all existing stock data and replace them with a new database"
                         "\n\nOption: 'backup old data and install new' will move your old data to separate directory. Then, new data will be installed."
                         "\n\nOption 'leave untouched' won't change anything in your database (no new data will be installed)" ))

(set #replace "replace old data")
(set #backup "backup old data and install new")
(set #leave "leave untouched")

(set #backupinprogress (cat "Creating backup of your stock database...\n\n"
                            "You'll find it in directory:\n" ))

(set #unpacking    "Unpacking AmiBroker program to:\n")
(set #unpackingFPU "Unpacking AmiBroker.FPU program to:\n")
(set #dearchiving  "Dearchiving database and installing files to:\n")
(set #limiting     (cat "Because your Amiga is equiped with small amount of memory (less than 2MB) "
                        "I have to limit the number of quotation in database to 160"))


; ********* Polish strings

(if (= @language "polski") (

(set #badkick "Bardzo mi przykro ale program AmiBroker wymaga systemu w wersji 2.04 lub wyszej")
(set #welcome (cat "\nAmiBroker 1.90\nSkrypt instalacyjny HD (Rev 5)\n"
                   "Copyright (C)1995-96 by Tomasz Janeczko\n\n"
                   "Program ten to SHAREWARE, chcc wic go uywa powiniene zarejestrowa si jako legalny uytkownik\n\n\n"
                   "ReqTools (C)1991-95 Nico Franois\n"
                   "SAS/C (C)1988-93 SAS Institute Inc.\n"
                   "Installer (C)1991-93 Commodore-Amiga, Inc.") )

(set #destination "Wska dysk lub katalog gdzie chcesz umieci AmiBrokera? ( Zostanie tam utworzony katalog 'AmiBroker')" )
(set #programver  "Wybierz jak wersj AmiBrokera chcesz zainstalowa" )
(set #progverhelp (cat "\nAmiBroker - to wersja na zwyky procesor 68000.\n\n"
                       "AmiBroker.FPU - to wersja na 68020 z koprocesorem 68882 "
                       "lub te procesory 68040 i 68060" ))

(set #olddataexist (cat "Masz ju zainstalowane dane o spkach i notowaniach w katalogu 'data'\n"
                        "Zdecyduj co mam z nimi zrobi:" ))

(set #dataexisthelp (cat "\nOpcja 'zastp stare notowania nowymi' skasuje dotychczasowe dane i zainstaluje nowe w dotychczasowym podkatalogu 'data'"
                         "\n\nOpcja 'utwrz kopi starych i zainstaluj nowe' przeniesie stare notowania do katalogu 'data_old', a nowe dane zapisze w katalogu 'data'"
                         "\n\nOpcje 'pozostaw stare notowania' nie zainstaluje adnych nowych danych, pozostawiajc tym samym stare dane bez zmian" ))

(set #replace "zastp stare notowania nowymi")
(set #backup "utwrz kopi starych i zainstaluj nowe")
(set #leave "pozostaw stare notowania")

(set #backupinprogress (cat "Tworz kopie starych notowa...\n\n"
                            "Znajdziesz je w katalogu:\n" ))

(set #unpacking    "Rozpakowuj program AmiBroker do katalogu:\n")
(set #unpackingFPU "Rozpakowuj program AmiBroker.FPU do katalogu:\n")
(set #dearchiving  "Rozpakowuj archiwum i instaluj nowe notowania do katalogu:\n")
(set #limiting     (cat "Poniewa Twoja Amiga jest wyposaona w niewielk ilo pamici (mniej ni 2MB) "
                        "musz ograniczy ilo notowa w bazie danych do 160"))

))

; ******* main install part

; set up an error cleanup routine
(onerror
        (makeassign "AmiBrokerinstpgm" (safe))
)

; check OS version

(if (< (/ (getversion) 65536) 37)
    (
        (message #badkick)
        (exit (quiet))
    )
)

;just started
(complete 0)

(message #welcome)

(welcome)

;cancel the assign in case of installation restart
(makeassign "AmiBrokerinstpgm" (safe))


; get the dest dir for AmiBroker
(set AmiBroker_dest
        (tackon
                (askdir
                        (prompt #destination)
                        (help @askdir-help)
                        (default @default-dest)
                )
                "AmiBroker"
        )
)


(complete 10)


;We now have a valid destination, so tell Installer where AmiBroker will end up
;so the exit page will be correct.
(set @default-dest AmiBroker_dest)

;
; Ask which files one wants to have installed
;
;

(set progver 1)

(if (OR (exists "AmiBroker.FPU") (exists "AmiBroker.FPU.lha") )
   (set progver (askoptions
                 (prompt #programver )
                 (help  #progverhelp )
                  (choices
                    "AmiBroker"
                    "AmiBroker.FPU"
                  )
                 (default 3)
                )
   )
)

;copy program files from source to dest

(if (IN progver 0)
 (if (exists "AmiBroker")
   (copyfiles
     (source "AmiBroker")
     (dest AmiBroker_dest)
     (infos)
   )
   (;else
     (working #unpacking AmiBroker_dest )
     (run (cat "lha -qf x AmiBroker.lha " (tackon AmiBroker_dest "/") ) )
   )
 )
)

(complete 10)

(if (IN progver 1)
 (if (exists "AmiBroker.FPU")
   (copyfiles
     (source "AmiBroker.FPU")
     (dest AmiBroker_dest)
     (infos)
   )
   (;else
     (working #unpackingFPU AmiBroker_dest )
     (run (cat "lha -qf x AmiBroker.FPU.lha " (tackon AmiBroker_dest "/") ) )
   )
 )
)

(complete 20)

(copyfiles
  (source "AmiBroker.guide")
  (dest AmiBroker_dest)
  (infos)
)


(complete 30)

(copyfiles
  (source "AmiBroker.history")
  (dest AmiBroker_dest)
  (infos)
)

(copyfiles
  (source "ReadMe")
  (dest AmiBroker_dest)
  (infos)
)

; delete old data file if exists
(if (exists (tackon AmiBroker_dest "broker.data"))
    (delete (tackon AmiBroker_dest "broker.data"))
)


(if (exists (tackon AmiBroker_dest "data"))
    (set datmode (askchoice
                  (prompt #olddataexist)
                  (help #dataexisthelp )
                  (default 1)
                  (choices
                     #replace
                     #backup
                     #leave
                  )
                 )
    )
)


(if (= datmode 1) (
       (makedir (tackon AmiBroker_dest "data_old") )
       (working #backupinprogress (tackon AmiBroker_dest "data_old"))
       (copyfiles
               (source (tackon AmiBroker_dest "data") )
               (dest   (tackon AmiBroker_dest "data_old") )
               (all)
               (nogauge)
       )
))

(complete 40)

(makedir (tackon AmiBroker_dest "data") )

(if (< datmode 2)
        (if (exists "data")
            (copyfiles
                 (source "data")
                 (dest   (tackon AmiBroker_dest "data") )
                 (all)
            )
            (;else
                 (working #dearchiving (tackon AmiBroker_dest "data"))
                 (makeassign "AmiBrokerData" (tackon AmiBroker_dest "data") (safe))
                 (run "lha -qf x abdata.lha AmiBrokerData:" )
                 (makeassign "AmiBrokerData" (safe))
            )
        )

)


(complete 60)

(set #freemem (database "total-mem") )

(if (< (- #freemem 2000000) 0)
  (
     (working #limiting)
     (makeassign "AmiBrokerData" (tackon AmiBroker_dest "data") (safe))
     (run "ConvertData >NIL: AmiBrokerData: 160" )
     (makeassign "AmiBrokerData" (safe))
  )
)

(working)

(if (NOT (exists (tackon AmiBroker_dest "broker.portfolio") ) )
    (copyfiles
     (source "broker.portfolio")
     (dest AmiBroker_dest)
    )
)

; copy key-file if exists
(if (exists "broker.key")
    (copyfiles
     (source "broker.key")
     (dest AmiBroker_dest)
    )
)

; copy key-file if exists
(if (exists "broker.arexx")
    (copyfiles
     (source "broker.arexx")
     (dest AmiBroker_dest)
    )
)

(complete 70)

; delete old BrokerSymbol font (1.22 and earlier vers) if exists
(if (exists "FONTS:BrokerSym.font")
    (delete "FONTS:BrokerSym.font")
)

(if (exists "FONTS:BrokerSym/16")
    (delete "FONTS:BrokerSym/16")
)

(if (exists "FONTS:BrokerSym")
    (delete "FONTS:BrokerSym")
)

; copy fonts needed
(copyfiles
  (source "fonts")
  (dest "FONTS:")
  (fonts)
  (all)
)


(complete 80)

(copyfiles
  (source "ARexxDemo.abrx")
  (dest AmiBroker_dest)
  (infos)
)

(makedir (tackon AmiBroker_dest "Examples") )

(copyfiles
  (source "Examples")
  (dest (tackon AmiBroker_Dest "Examples" ) )
  (all)
)


(makedir (tackon AmiBroker_dest "Teletext") )

(copyfiles
  (source "Teletext")
  (dest (tackon AmiBroker_Dest "Teletext" ) )
  (all)
)


(makedir (tackon AmiBroker_dest "Rexx") )

(copyfiles
  (source "Rexx")
  (dest (tackon AmiBroker_Dest "Rexx" ) )
  (all)
)


(copyfiles
  (source "examples.info")
  (dest AmiBroker_Dest)
)

(complete 90)

;un-snapshot the AmiBroker drawer icon
(tooltype
        (dest AmiBroker_dest)
        (noposition)
)

;done with the install
(complete 100)

;cleanup
(makeassign "AmiBrokerinstpgm" (safe))

;and get out
(exit)
