;
; Check whether the Imagine Assign is set. If it is use it as default base
; directory else use Work:
;
(if (= (exists "Imagine:" (noreq)) 2)
    (set @default-dest "Imagine:")
    (set @default-dest "Work:")
)
(set @user-level 1)
(set MagicWB (exists "ENV:MagicWB"))
(set Source_dir (pathonly @icon))

; Texts

(set #Intro-Text
(cat "\nThis script installs the Imagine Object Path Editor on your Hard Disk. "
     "Please ensure that you have at least 69K of free disk space."))
(set #Path-Text
(cat "Select the target directory. A directory IOPEditor will be created there."))
(set #Path-Help
(cat "\nThis section lets you choose the target directory to install IOPEditor."
     "A directory IOPEditor will be created there if it does not already exist."
     "\nThe default is @default-dest\n\n"
     @askdir-help))
(set #FileExists
(cat "File IOPEditor already exists in this directory. You should either delete "
     "the file and then re-install or re-install into a different directory."))
(set #MagicWB-Help
"Installs 8 Colour MagicWB Icons instead of Standard 4 colour ones.")

; Main 

(complete 0)

(message #Intro-Text)
(set target 
(askdir (prompt #Path-Text) (help #Path-Help) (default @default-dest) (newpath)))

(if (= MagicWB 0)
    (set MagicWB 
         (askbool (prompt "\n\nDo you want to use the MagicWB Icons ? ")
                  (help #MagicWB-Help)
                  (default 1))))

; Set up Destination Directory. Check that it does not already exist

(set @default-dest (tackon target "IOPEditor"))
(if (= (exists @default-dest (noreq)) 1) 
    (Abort #FileExists)
)
(if (= (exists @default-dest (noreq)) 0) 
    (makedir @default-dest (infos))
)

(copyfiles
     (prompt "\nInstalling Program & Doc Files")
     (source Source_Dir)
     (choices "IOPEditor" "IOPEditor.Guide" "IOPEditor.txt")
     (dest @default-dest))

(complete 50)

(if (= MagicWB 0)
    (Set Icon_Source_Dir Source_Dir)
    (Set Icon_Source_Dir (tackon Source_Dir "MagicWB"))
)

(copyfiles
     (prompt "\nInstalling Icon Files")
     (source Icon_Source_Dir)
     (choices "IOPEditor.Info" "IOPEditor.Guide.info" "IOPEditor.txt.info")
     (dest @default-dest))

(complete 100)