;$VER: Miami Control Installer 1.9 (10.10.98) Copyright © Thomas Hurst 1998

Ask "Are you sure you wish to Install Miami Control?*nNo Files will be overwritten. Y/N"
If warn
        Echo "*nChecking for installation..."
        If Not exists S:miamicontrol.rexx
                Echo "Not found, installing..."
                Echo "*nChecking for required files... " NOLINE
                set probs 0
                If exists Miami:Miami
                        Version >NIL: Miami:Miami VERSION 3
                        If warn
                                Ask "Miami other than version 3 detected!*nMiamiControl may not function correctly. Continue? Y/N"
                                If not warn
                                        Echo "Quitting.  No changes to your system have been made"
                                        Wait 3
                                        Quit 0
                                Endif
                        Endif
                Else
                        Ask "WARNING!*NMiami not detected! Continue anyway? Y/N"
                        If not warn
                                Echo "Quitting. No changes to your system have been made"
                                Wait 3
                                Quit 0
                        Endif
                Endif
                If not exists c:requeststring
                        Echo "*nRequestString not found in path! Installing..." NOLINE
                        Copy files/RequestString c:
                        Echo "Done!"
                Else
                    Echo "RequestString detected!*nChecking version...*n"
                    Echo "Your version:        `Version c:requeststring`"
                    Echo "Recommended version: `Version files/RequestString`"
                    Echo " "
                    Echo "If the above lines differ you may need to install the included version of RequestString.*n*nSetCosts may not function correctly without it!"
                    Ask "Install recommended version (Old one will be backed up)? y/n"
                    If warn
                        rename c:RequestString C:RequestString.bak
                        Copy files/RequestString c:
                    Endif
                Endif

                if not exists libs:rexxsupport.library
                    Echo "Library missing!*nInstalling rexxsupport.library..."
                    copy libs/rexxsupport.library libs:
                endif
                if not exists libs:rexxreqtools.library
                    set probs 1
                    Echo "Library missing!*nInstalling rexxreqtools.library..."
                    copy libs/rexxreqtools.library libs:
                endif

                if $probs eq 0
                    Echo "All files found!*n"
                else
                    Echo "Not all files found!*n"
                endif
                Echo "Checking ARexx port... " NOLINE
                Set RC 0
                Rx rexxtest.rexx >NIL:
                If $RC EQ 5
                        Set probs 1
                        Ask "Not found!*nARexx does not appear to be operating!*nMiami Control absolutely needs ARexx to function.*nContinue? Y/N"
                        If NOT Warn
                                Echo "Quitting..."
                                Wait 3
                                Quit 0
                        Endif
                Else
                        Echo "Port is active!"
                Endif

                If $probs EQ 1
                        Echo "*nSome problems have been detected. Miami Control may not function properly."
                Else
                        Echo "*nSystem requirements have been passed!"
                Endif
                Echo "*nInstalling...*n"
                Echo "Copying miamicontrol.rexx to S:miamicontrol.rexx"
                Copy files/miamicontrol.rexx S:miamicontrol.rexx

                if exists s:phonelog.log
                    Echo "*e[7mWarning! Logfile detected!*nIf you are upgrading from a previous version of Miami Control, you MUST rename it!*e[0m"
                    Ask "Are you upgrading from a previous version of Miami Control? (Y/N)"
                    if warn
                        If not exists S:Phonelog.log.old
                            Echo "Backing up s:Phonelog.log to s:Phonelog.log.old..." NOLINE
                            rename s:Phonelog.log s:Phonelog.log.old >NIL
                            if not warn
                                Echo "Done!"
                            else
                                Echo "Error!*Please rename it manually!!!!!"
                            endif
                        endif
                    endif
                 endif

                Echo "*n*nMiami Control has been installed."
                Echo "Running this script again will remove it."

                Echo "*n*e[7mYou should now run SetCosts and set your call charges.*e[0m"

                Echo "*nThis window will self destruct in 5 seconds..."
                Wait 5
                Quit 0
        Else
                Ask "Previous installation detected. Uninstall Miami Control? Y/N"
                If Warn
                        Delete S:miamicontrol.rexx
                        Echo "Uninstall complete!"
                        Quit 0
                Else
                        Echo "Quitting"
                        Wait 1
                        Quit 0
                Endif
        Endif
Else
        Echo "Quitting..."
Endif
