;   -----------------------------
;       Install BancaBase
;   -----------------------------
;   Description:
;
;   Commodore Installer Script for BancaBase 1.3
;   $VER: 1.01 (c) 1997 by Stefano Dardari

; some useful variables
	(set 
		newline 		"\n"
		#bbprogname 	"BancaBase13.lha"
        #bb3-path       "BancaBase/"
		#patternsname 	"Patterns.lha"
        #soundsname     "Sounds.lha"
        #BBdocname      "BBase_doc.lha"
        #bb3-dest       "SYS:"
        #bb3-key        "BBase.key"
        #bb3-prefs      "BancaBase.prefs"
        #bb3-icon-MWB   "Icons/MagicWB/"
        #bb3-icon-NI    "Icons/NewIcon/"
        #bb3-icon-STD   "Icons/Standard/"
        #STDTYPE        0
        #NITYPE         1
        #MWBTYPE        2
        #iconpattern    "#?.info"
	)

; some strings
(set #omp (cat "One moment please..." newline))

(set #installtext (cat "Welcome to the BancaBase installation script.\n\nBancaBase3 V 1.3 (C) 1996 by Stefano Dardari\n\nAll rights reserved"))
(set #BB3dest-prompt "Please select the directory where you want the BancaBase drawer installed.\n(See help for details)")
(set #BB3dest-help (cat "Select the desidered disk/directory were install the program.\nA drawer named BancaBase will be created."))
(set #BB3patt-prompt "\n\n\nDo you want to install some pretty patterns to use with the GUI ?\nNOTE: you can use it, only with an WorkBench 3.0 or better.")
(set #BB3patt-help (cat "The backdrop patterns are to be considere as add-on.\nBancaBase work well also without them, but are very nice if used with the program's GUI.\n\nNote that program uses the Datatypes to load picture files\nso if you don't have an V39 (or better) kickstart ... chose the NO gadget."))
(set #BB3end (cat "Installation complete. Read the readme file before start."))
(set #BB3icon-prompt "\nSelect from available the ICON set to install :")
(set #BB3icon-help "Select desired type of icon-set to install for BancaBase and all the tools.\nIf for example your WorkBench use the MagicWB icons, you must select MagicWB.\nSame thing for the other types.")
(set #copyng-icon-prompt "Please wait ... icon installation running.")
(set #eng_doc_early "\n\nNOTE : English documentation will be early available on Aminet.")

(welcome #installtext)

(procedure set_icon
   (set #def-icon
      (askchoice
         (prompt #BB3icon-prompt)
         (help   #bb3icon-help)
         (choices "Standard Icon" "NewIcon Icon" "MagicWB Icon")
         (default 0)
      )
   )
)

(procedure set_dir
   (set #bb3-dest
      (askdir
         (prompt #BB3dest-prompt)
         (help #BB3dest-help)
         (default #bb3-dest)
         (newpath)
      )
   )
)

(set_dir)
(set #dest-path (tackon #bb3-dest #bb3-path))
(set @default-dest #dest-path)


(if (exists #dest-path (noreq))
   (
      (set #file-exist (cat "Sorry but directory " #dest-path " already exist.\nPlease select a different destination .\n"))
      (message #file-exist)
      (set_dir)
      (set #dest-path (tackon #bb3-dest #bb3-path))
      (set @default-dest #dest-path)
   )
)

(makedir #dest-path (infos))

(working #omp "UnPacking and coping files.")

(run "lha -x x "#bbprogname" "#dest-path)

(complete 50)

( if (exists #BBdocname (noreq))
   (
      (working #omp "UnPacking and coping documentation.")
      (run "lha -x x "#BBdocname" "#dest-path )
      (message #eng_doc_early)
   )
)

(complete 60)

(if (exists #patternsname (noreq))
   (
      (if (askbool (prompt #BB3patt-prompt) (help #BB3patt-help) (default 1))
             (
                (working #omp "UnPacking and coping files.")
                (run "lha -x x "#patternsname" "#dest-path )
             )
      )
   )
)

(complete 70)

(set_icon)
(if (= #def-icon #STDTYPE)
    (set #src-icon #bb3-icon-STD)
    )
(if (= #def-icon #NITYPE)
    (set #src-icon #bb3-icon-NI)
    )
(if (= #def-icon #MWBTYPE)
    (set #src-icon #bb3-icon-MWB)
    )

(copyfiles
   (prompt #copyng-icon-prompt)
   (source #src-icon)
   (dest  #dest-path)
   (pattern #iconpattern)
   (noposition)
)

(set #src-path (tackon #src-icon "Docs"))
(set #dst-path (tackon #dest-path "Docs"))

(copyfiles
   (prompt #copyng-icon-prompt)
   (source #src-path)
   (dest  #dst-path)
   (all)
   (noposition)
)

(set #src-path (tackon #src-icon "Register"))
(set #dst-path (tackon #dest-path "Register"))

(copyfiles
   (prompt #copyng-icon-prompt)
   (source #src-path)
   (dest  #dst-path)
   (all)
   (noposition)
)

(complete 80)

(if (exists #soundsname (noreq))
       (
          (working #omp "UnPacking and coping files.")
          (run "lha -x x "#soundsname" "#dest-path )
       )
)


(complete 90)

(if (exists #bb3-prefs (noreq))
	(copyfiles
        (prompt #omp "Coping prefs file.")
		(source #bb3-prefs)
		(dest #dest-path)
        (files)
	)
)

(if (exists #bb3-key (noreq))
	(copyfiles
        (prompt #omp "Coping the KeyFile.")
		(source #bb3-key)
		(dest #dest-path)
        (files)
	)
)

(complete 100)


; The last message
	(set end_text (cat "Hope you like BancaBase!\n"
                   "Don't hesitate to send me comments, bugreports and suggestions."))

; the end
(set @default-dest #dest-path)
    (exit end_text)
;EOF
