; Remove AlphaSpell V

(transcript "Removing AlphaSpell V")
(welcome "This script will remove AlphaSpell V from your system.")

(set #prog "C:AlphaSpell")
(if (not (exists #prog (noreq)))
    (set #prog
        (askfile
            (prompt "Where is AlphaSpell V?")
            (help @askfile-help)
            (default "C:")
        )
    )
)
(delete #prog
    (prompt "Deleting AlphaSpell")
    (help @delete-help)
    (confirm)
)

(if (exists "ENV:DDIR")
    (
        (set #def (getenv "DDIR"))
        (delete "ENVARC:DDIR")
        (delete "ENV:DDIR")
        (delete "ENVARC:Dict")
        (delete "ENV:Dict")
        (delete "ENVARC:UDict")
        (delete "ENV:UDict")
    )
    (set #def "Work:AlphaSpell/Dictionaries")
)
(set #dir
    (askdir
        (prompt "Where are your dictionaries?")
        (help @askdir-help)
        (default #def)
    )
)
(foreach #dir "#?"
    (delete @each-name
        (prompt "Deleting " @each-name)
        (help @delete-help)
        (confirm)
    )
)

(set #doc "Data:Docs/AlphaSpell.guide")
(if (not (exists #doc (noreq)))
    (set #doc
        (askfile
            (prompt "Where is the documentation for AlphaSpell V?")
            (help @askfile-help)
            (default #doc)
        )
    )
)
(delete #doc
    (prompt "Deleting AlphaSpell V Documentation")
    (help @delete-help)
    (confirm)
)

(if (exists "ENV:ASpellGUI")
    (
        (delete
            (prompt "Deleting ASpell.gui")
            (help @delete-help)
            (getenv "ASpellGUI")
            (confirm)
        )

        (delete "ENVARC:ASpellGUI"
            (prompt "Deleting ENVARC:ASpellGUI")
            (help @delete-help)
            (confirm)
        )
        (delete "ENV:ASpellGUI"
            (prompt "Deleting ENV:ASpellGUI")
            (help @delete-help)
            (confirm)
        )
        (set #rexx
            (askdir
                (prompt "Where are your AlphaSpell GUI scripts?")
                (help @askdir-help)
                (default "REXX:")
            )
        )
        (foreach #rexx "ASpell.#?"
            (delete @each-name
                (prompt "Deleting " @each-name)
                (help @delete-help)
                (confirm)
            )
        )
        (set #doc "Data:Docs/ASpellGUI.guide")
        (if (not (exists #doc (noreq)))
            (set #doc
                (askfile
                    (prompt "Where is the documentation for the AlphaSpell GUI?")
                    (help @askfile-help)
                    (default #doc)
                )
            )
        )
        (delete #doc
            (prompt "Deleting AlphaSpell GUI Documentation")
            (help @delete-help)
            (confirm)
        )

    )
)

(message "The removal of AlphaSpell V is finished.")
(exit (quiet))
