; Installer Script for AmiBroker 1.60
; Dec 16th, 1995  Tomasz Janeczko, TJ Productions.

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


; check OS version

(if (< (/ (getversion) 65536) 37)
    (
        (message "I'm sorry but AmiBroker requires OS 2.04 or better")

        (exit (quiet))
    )
)

;just started
(complete 0)


(message "\nAmiBroker 1.6\nInstallation script\n"
         "Copyright (C)1995 by Tomasz Janeczko\n\n"
         "This is SHAREWARE product, so if you use it you should register\n\n\n"
         "ReqTools (C)1991-1995 Nico François\n"
         "Installer (C)1991-93 Commodore-Amiga, Inc."
         )

(welcome)

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


; get the dest dir for AmiBroker
(set AmiBroker_dest
        (tackon
                (askdir
                        (prompt "Where do you want to install AmiBroker? ('AmiBroker' drawer will be created for you)")
                        (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)

;copy program files from source to dest

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

(complete 10)

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

(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"))
)


(complete 40)
(makedir (tackon AmiBroker_dest "data") )

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

(complete 60)

(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)
    )
)

(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)
)

(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)
