;$VER:AmiSearch installation script

(complete 0)
(set @default-dest "Work:")

; Texts

(set #Warning-Txt
(cat "Warning !\n\n\n"
"AmiSearch II.2 needs MUI 3.8+ to work.\n\n"
"Without MUI AmiSearch II.2 won't work...\n\n"
))
(set #Path-Txt
(cat "Please choose target directory."
"An AmiSearchII drawer will be created there."
))
(set #Path-Help
(cat "This part allows you to choose the directory where AmiSearch II.2 will be copied.\n\n"
"If you're upgrading from version II or II.1 no drawer will be created.\n\n"
"An AmiSearch II drawer is created there, in order to allow a better index handling.\n\n"
"The default one is Work:\n\n\n"
))
(set #UpdateTxt
(cat "If you are updating from AmiSearch II or II.1 to AmiSearch II.2 you should select\n"
"the directory which contains AmiSearch II's directory when prompted for a \n"
"destination drawer. Files needing an update will be updated automatically.\n\n"
"Warning ! Copy your prolog files if you modified them\n"
"otherwise they will be overwritten !\n\n"
))

; Main

(message #Warning-Txt)
(message #UpdateTxt)
(set target
(askdir (prompt #Path-Txt) (help #Path-Help) (default @default-dest) (newpath)
))
(set @default-dest (tackon target "AmiSearchII"))
(if (= (exists (tackon target "AmiSearchII")) 0)
(
(makedir (tackon target "AmiSearchII")(infos))
(makedir (tackon target "AmiSearchII/Docs") (infos))
(makedir (tackon target "AmiSearchII/Gfx"))
(makedir (tackon target "AmiSearchII/ArchiveScripts"))
(makedir (tackon target "AmiSearchII/BaseScripts"))
(makedir (tackon target "AmiSearchII/Databases"))
(makedir (tackon target "AmiSearchII/Prologs"))
))
(copyfiles
(prompt "Copying software")
(help @copy-files-help)
(source "AmiSearchII")
(dest (tackon target "AmiSearchII"))
(infos))

(if (= (exists (tackon target "AmiSearchII/AmiSearch2")) 1)
(
(delete (tackon target "AmiSearchII/AmiSearch2") force)
(delete (tackon target "AmiSearchII/AmiSearch2.info") force)
))

(if (= (exists (tackon target "AmiSearchII/ArchiveScripts/AS2H")) 1)
(
(rename (tackon target "AmiSearchII/ArchiveScripts/AS2H") (tackon target "AmiSearchII/ArchiveScripts/AS2H.bak"))
))
(copyfiles
(prompt "Copying archive handling script (AS2H)")
(help @copy-files-help)
(source "ArchiveScripts/AS2H")
(dest (tackon target "AmiSearchII/ArchiveScripts"))
(infos))

(if (= (exists (tackon target "AmiSearchII/ArchiveScripts/AS2Audio")) 1)
(
(rename (tackon target "AmiSearchII/ArchiveScripts/AS2Audio") (tackon target "AmiSearchII/ArchiveScripts/AS2Audio.bak"))
))
(copyfiles
(prompt "Copying module handling script (AS2Audio)")
(help @copy-files-help)
(source "ArchiveScripts/AS2Audio")
(dest (tackon target "AmiSearchII/ArchiveScripts"))
(infos))

(copyfiles
(prompt "Copying DMS archive handling script (DMS2Disk)")
(help @copy-files-help)
(source "ArchiveScripts/DMS2Disk")
(dest (tackon target "AmiSearchII/ArchiveScripts"))
(infos))

(copyfiles
(prompt "Copying pictures")
(help @copy-files-help)
(source "Gfx")
(dest (tackon target "AmiSearchII/Gfx"))
(pattern "#?")
(infos))

(complete 30)

(copyfiles
(prompt "Copying automatic creation scripts")
(help @copy-files-help)
(source "BaseScripts")
(dest (tackon target "AmiSearchII/BaseScripts"))
(pattern "#?")
(infos))

(copyfiles
(prompt "Copying prologs")
(help @copy-files-help)
(source "Prologs")
(dest (tackon target "AmiSearchII/Prologs"))
(pattern "#?")
(infos))

(if (= (exists "ENVARC:AmiSearch2.config") 1)
(
(copyfiles (prompt "Copying default config file to AS2:") (source "ENVARC/AmiSearch2.config") (dest (tackon target "AmiSearchII")))
)
(
(copyfiles (prompt "Copying default config file to ENVARC:") (source "ENVARC/AmiSearch2.config") (dest "ENVARC:"))
(copyfiles (prompt "Copying default config file to ENV:") (source "ENVARC/AmiSearch2.config") (dest "ENV:"))
))

(complete 40)
(copyfiles (prompt "Copying localisation") (source "Locale/AmiSearch2.cd") (dest "LOCALE:"))
(if (= (exists "MUI:Libs/MUI/NList.mcc") 0)
(
(copyfiles (prompt "Copying MUI Custom Class\n\nNList.mcc\n\n(c) Gilles Masson") (source "Libs/NList.mcc") (dest "MUI:Libs/MUI"))
)
(
(set #nlistvo (getversion "MUI:Libs/MUI/NList.mcc"))
(set #nlistvn (getversion "Libs/NList.mcc"))
(if (< #nlistvo #nlistvn)
(
(copyfiles (prompt "Updating MUI Custom Class\n\nNList.mcc\n\n(c) Gilles Masson") (source "Libs/NList.mcc") (dest "MUI:Libs/MUI"))
))
))
(if (= (exists "MUI:Libs/MUI/NListview.mcc") 0)
(
(copyfiles (prompt "Copying MUI Custom Class\n\nNListview.mcc\n\n(c) Gilles Masson") (source "Libs/NListview.mcc") (dest "MUI:Libs/MUI"))
)
(
(set #nlistvo (getversion "MUI:Libs/MUI/NListview.mcc"))
(set #nlistvn (getversion "Libs/NListview.mcc"))
(if (< #nlistvo #nlistvn)
(
(copyfiles (prompt "Updating MUI Custom Class\n\nNListview.mcc\n\n(c) Gilles Masson") (source "Libs/NListview.mcc") (dest "MUI:Libs/MUI"))
))
))
(if (= (exists "MUI:Libs/MUI/NListviews.mcp") 0)
(
(copyfiles (prompt "Copying MUI Custom Class\n\nNListviews.mcp\n\n(c) Gilles Masson") (source "Libs/NListviews.mcp") (dest "MUI:Libs/MUI"))
)
(
(set #nlistvo (getversion "MUI:Libs/MUI/NListviews.mcp"))
(set #nlistvn (getversion "Libs/NListviews.mcp"))
(if (< #nlistvo #nlistvn)
(
(copyfiles (prompt "Updating MUI Custom Class\n\nNListviews.mcp\n\n(c) Gilles Masson") (source "Libs/NListviews.mcp") (dest "MUI:Libs/MUI"))
))
))


(complete 50)
(copyfiles
(prompt "Copying manual")
(help @copy-files-help)
(source "Docs/English_Manual.guide")
(dest (tackon target "AmiSearchII/Docs"))
(newname "AmiSearchII.guide")
(infos))

(complete 75)

(copyfiles
(prompt "Copying ReadMe.mui")
(help @copy-files-help)
(source "Docs/ReadMe.mui")
(dest (tackon target "AmiSearchII/Docs"))
(infos))

(set myassign
(cat "ASSIGN AS2: \"" (tackon (expandpath target) "AmiSearchII\" DEFER")
)
)

(startup "AmiSearch II"
(command myassign)
(prompt "Adding assign to S:user-startup")
(help @startup-help)
)
(run myassign)

(complete 100)
