; MiserPrint V1.16 Installation
; (c) 1993-95 Heinz-Guenter Boettger

(set #target-prompt
(cat "\n Where do you want to copy MiserPrint? \n"))

(set #target-help
(cat "                                                   \n"
     " Select the directory, where you want to copy the  \n"
     " main program and its icon.                        \n"
     "                                                   \n"
))
(set target (askdir 
    (prompt  #target-prompt)
    (help    #target-help)
    (default "Sys:Utilities")
))
(set @default-dest target)

(copyfiles
	(prompt "Copying MiserPrint...")
	(source "")
	(dest target)
	(pattern "MiserPrint")
	(files)
	(infos)
)

(set #prefs-prompt
(cat "\n Where do you want to copy the\n"
     " the directory 'MiserPrintPrefs'?\n"
))

(set #prefs-help
(cat "                                                   \n"
     " Select the directory, where you want to copy the  \n"
     " MiserPrint preferences.                           \n"
     "                                                   \n"
))

(set target (askdir 
    (prompt  #prefs-prompt)
    (help    #prefs-help)
    (default @default-dest)
))
(set MPPrefs (tackon target "MiserPrintPrefs") )

(copyfiles
    (prompt "Copying MiserPrint preferences...")
    (source "MiserPrintPrefs")
    (dest   MPPrefs)
    (all)
)

(textfile
    (dest   "env:MiserPrintPrefsPath")
    (append MPPrefs)
)

(textfile
    (dest "envarc:MiserPrintPrefsPath")
    (append MPPrefs)
)

(if (exists "envarc:MiserPrint") 
(
    (set #replace-prompt
    (cat "\n Copy your old preferences from 'envarc:MiserPrint' \n"
         " to the new directory and delete the old one?       \n"
         "                                                    \n"
    ))
    
    (set #replace-help
    (cat "                                                   \n"
         " Select 'Yes' to copy your old preferences files.  \n"
         "                                                   \n"
    ))

    (if (askbool 
            (prompt #replace-prompt)
            (help   #replace-help)
        )
        (
            (copyfiles
                (prompt "Copying old MiserPrint preferences...")
                (source "envarc:MiserPrint")
                (dest   MPPrefs)
                (all)
            )
    
            (foreach "envarc:MiserPrint" "#?" 
                (delete (tackon "envarc:MiserPrint" @each-name))
            )
            (delete "envarc:MiserPrint")
        )
    )
)
)
