/* Video Toolkit For OS/2 Uninstallation Script.        */
/* Copyright (c) Abbotsbury Software Ltd. (UK), 1995-98 */
echo off

say 'WARNING - WARNING - WARNING - This utility deletes all files in the'
say 'current directory and its sub-directories.'
say 'If in doubt type CTRL-C To stop this script deleting these directories'
pause

/* Load the REXX utility */
Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call SysLoadFuncs

rc = RXFUNCADD('mciRxInit','MCIAPI','mciRxInit')
InitRC = mciRxInit()

                                /* query number of celebrities, prisms, etc */
m = 2
celebs = 0
prisms = 0
highqs = 0
stubs = 0
wcasts = 0
DO FOREVER
        cmd = 'info digitalvideo0'm 'product wait'
        rc = SendString(cmd, ret_str)
        if rc <> 0 then leave
        if ret_str = "Hauppauge Celebrity" then
            celebs = celebs + 1
        if ret_str = "Hauppauge Prism" then
            prisms = prisms + 1
        if ret_str = "Hauppauge HighQ" then
            highqs = highqs + 1
        if ret_str = "Hauppauge WinCast TV" then
            wcasts = wcasts + 1
        m = m + 1
END

DEL 'BIN\*.*'
DEL 'BOOK\*.*'
DEL 'DLL\*.*'
DEL 'HELP\*.*'
DEL 'H\*.*'
DEL 'LIB\*.*'
DEL 'SAMPLES\DIAG\*.*'
DEL 'SAMPLES\EX1\*.*'
DEL 'SAMPLES\EX2\*.*'
DEL 'SAMPLES\EX3\*.*'
DEL 'SAMPLES\EX4\*.*'
Call SysRmDir 'BOOK'
Call SysRmDir 'DLL'
Call SysRmDir 'H'
Call SysRmDir 'HELP'
Call SysRmDir 'BIN'
Call SysRmDir 'LIB'
Call SysRmDir 'SAMPLES\DIAG'
Call SysRmDir 'SAMPLES\EX1'
Call SysRmDir 'SAMPLES\EX2'
Call SysRmDir 'SAMPLES\EX3'
Call SysRmDir 'SAMPLES\EX4'
if wcasts > 0 then do
    DEL 'SAMPLES\DIVE\*.*'
    Call SysRmDir 'SAMPLES\DIVE'
end
Call SysRmDir 'SAMPLES'

n = 1
if celebs > 0 then
do
do until n = celebs + 1
    if SysDestroyObject( '<ABBPMTV2CEL'n'>')
    then
        say 'PMTV/2 Celeb 'n' destroyed successfully'
    else
        say 'Error destroying PMTV/2 Celeb 'n

    if SysDestroyObject( '<ABBCONFIGCEL'n'>')
    then
        say 'Celeb 'n' Config destroyed successfully'
    else
        say 'Error destroying Celeb 'n' Config'

    if SysDestroyObject( '<ABBROCKETCEL'n'>')
    then
        say 'Rocket Remote Celeb 'n' destroyed successfully'
    else
        say 'Error destroying Rocket Remote Celeb 'n

    if SysDestroyObject( '<ABBDIAGCEL'n'>')
    then
        say 'Diagnostics Celeb 'n' destroyed successfully'
    else
        say 'Error destroying Diagnostics Celeb 'n
    n = n + 1
end
end

n = 1
if prisms > 0 then
do
do until n = prisms + 1
    if SysDestroyObject( '<ABBPMTV2PRM'n'>')
    then
        say 'PMTV/2 Prism 'n' destroyed successfully'
    else
        say 'Error destroying PMTV/2 Prism 'n

    if SysDestroyObject( '<ABBCONFIGPRM'n'>')
    then
        say 'Prism 'n' Config destroyed successfully'
    else
        say 'Error destroying Prism 'n' Config'

    if SysDestroyObject( '<ABBROCKETPRM'n'>')
    then
        say 'Rocket Remote Prism 'n' destroyed successfully'
    else
        say 'Error destroying Rocket Remote Prism 'n

    if SysDestroyObject( '<ABBDIAGPRM'n'>')
    then
        say 'Diagnostics Prism 'n' destroyed successfully'
    else
        say 'Error destroying Diagnostics Prism 'n
    n = n + 1
end
end

n = 1
if highqs > 0 then
do
do until n = highqs + 1
    if SysDestroyObject( '<ABBPMTV2HQ'n'>')
    then
        say 'PMTV/2 HighQ 'n' destroyed successfully'
    else
        say 'Error destroying PMTV/2 HighQ 'n

    if SysDestroyObject( '<ABBCONFIGHQ'n'>')
    then
        say 'HighQ 'n' Config destroyed successfully'
    else
        say 'Error destroying HighQ 'n' Config'

    if SysDestroyObject( '<ABBROCKETHQ'n'>')
    then
        say 'Rocket Remote HighQ 'n' destroyed successfully'
    else
        say 'Error destroying Rocket Remote HighQ 'n

    if SysDestroyObject( '<ABBDIAGHQ'n'>')
    then
        say 'Diagnostics HighQ 'n' destroyed successfully'
    else
        say 'Error destroying Diagnostics HighQ 'n
    n = n + 1
end
end

n = 1
if wcasts > 0 then
do
do until n = wcasts + 1
    if SysDestroyObject( '<ABBPMTV2WC'n'>')
    then
        say 'PMTV/2 Wincast 'n' destroyed successfully'
    else
        say 'Error destroying PMTV/2 Wincast 'n

    if SysDestroyObject( '<ABBCONFIGWC'n'>')
    then
        say 'Wincast 'n' Config destroyed successfully'
    else
        say 'Error destroying Wincast 'n' Config'

    if SysDestroyObject( '<ABBROCKETWC'n'>')
    then
        say 'Rocket Remote Wincast 'n' destroyed successfully'
    else
        say 'Error destroying Rocket Remote Wincast 'n

    if SysDestroyObject( '<ABBDIAGWC'n'>')
    then
        say 'Diagnostics Wincast 'n' destroyed successfully'
    else
        say 'Error destroying Diagnostics Wincast 'n
    n = n + 1
end
end

if SysDestroyObject( '<ABBPIP>')
then
    say 'Picture In Picture destroyed successfully'
else
    say 'Error destroying Picture In Picture'

if SysDestroyObject( '<ABBUTILFolder>')
then
    say 'Utilities Folder destroyed successfully'
else
    say 'Error destroying Utilities Folder'

    Instance = 1
    Video='CELEB'
    if celebs > 0 then
    do
    do until Instance = celebs + 1

        rc = UninstEx('DIAG')
        rc = UninstEx('EX1')
        rc = UninstEx('EX2')
        rc = UninstEx('EX3')
        rc = UninstEx('EX4')
        Instance = Instance + 1
    end
    end
    Instance = 1
    Video='PRISM'
    if prisms > 0 then
    do
    do until Instance = prisms + 1

        rc = UninstEx('DIAG')
        rc = UninstEx('EX1')
        rc = UninstEx('EX2')
        rc = UninstEx('EX3')
        rc = UninstEx('EX4')
        Instance = Instance + 1
    end
    end
    Instance = 1
    Video='HIGHQ'
    if highqs > 0 then
    do
    do until Instance = highqs + 1

        rc = UninstEx('DIAG')
        rc = UninstEx('EX1')
        rc = UninstEx('EX2')
        rc = UninstEx('EX3')
        rc = UninstEx('EX4')
        Instance = Instance + 1
    end
    end
    Instance = 1
    Video='WCAST'
    if wcasts > 0 then
    do
    do until Instance = wcasts + 1

        rc = UninstEx('DIAG')
        rc = UninstEx('EX1')
        rc = UninstEx('EX2')
        rc = UninstEx('EX3')
        rc = UninstEx('EX4')
        rc = UninstEx('DIVE')
        Instance = Instance + 1
    end
    end

if SysDestroyObject( '<ABBOS2>')
then
    say 'OS/2 Full Screen destroyed successfully'
else
    say 'Error destroying OS/2 Full Screen'

if SysDestroyObject( '<ABBSAMPFolder>')
then
    say 'Samples Folder destroyed successfully'
else
    say 'Error destroying Samples Folder'

if SysDestroyObject( '<ABBVIEWVIDTLKT>')
then
    say 'Technical Reference destroyed successfully'
else
    say 'Error destroying Technical Reference'

if SysDestroyObject( '<ABBINFFolder>')
then
    say 'Information Folder destroyed successfully'
else
    say 'Error destroying Information Folder'

if SysDestroyObject( '<ABBVIDFolder>')
then
    say 'Toolkit Folder destroyed successfully'
else
    say 'Error destroying Toolkit Folder'

DEL '*.*'

Exit 0

UninstEx:
    arg Ex

        name = 'Example' Ex 'using' Video''Instance
        path = drivedir'\SAMPLES\'Ex'\'Ex
        objid = 'ABB'Ex'PROG'Video''Instance

        if SysDestroyObject( '<'objid'>')
        then
            say name 'destroyed successfully'
        else
            say 'Error destroying' name

        return 0

/*   --- SendString --
** Call DLL function.  Pass the command to process and the
** name of a REXX variable that will receive textual return
** return code.
*/
SendString:
    arg CmndTxt
    arg ret_str

        MacRC = mciRxSendString(CmndTxt, 'ret_str', '0', '0')
        return MacRC
