/*
**  Installation for RiBackup.Cmd script
**  Roos Instruments (c) 2002
*/

'@echo off'
/* trace '?I' */

if RxFuncQuery('SysLoadFuncs')\=0 then do
    call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
    call SysLoadFuncs
end /* do */

say
say 'What is the name of your RI System? (no spaces) '
parse pull SysName
if SysName='' then do
    say 'No system name provided, using default "RISystem" name...'
    SysName = 'RISystem'
end /* do */
say
say 'Now installing RiBackup tool...'
OldDir = Directory()
RiappsDir = Directory('D:\RiApps')
if Translate(RiappsDir)\='D:\RIAPPS' then do
    RiappsDir = Directory('C:\RiApps')
    if Translate(RiappsDir)\='C:\RIAPPS' then do
        say "Can't find existing RI System Software installation!"
        say "Exiting now..."
        exit(1)
    end /* do */
end /* do */
InstallDir = RiappsDir'\util'
TestDir = Directory(InstallDir)
if Translate(TestDir)\=Translate(InstallDir) then do
    'mkdir util'
    Call Directory InstallDir
end /* do */
'copy' OldDir'\RiBackup.Cmd' InstallDir'\RiBackup.Cmd' '>nul'
BackDir = Filespec('drive',RiappsDir)'\RiBackup'
TestDir = Directory(BackDir)
if Translate(TestDir)\=Translate(BackDir) then do
    'mkdir 'BackDir
    Call Directory InstallDir
end /* if */

Call CreateObjects

Call Directory OldDir
say
say "Installation done"
exit(0)

CreateObject: procedure
    Parse Arg Class, Title, Location, Setup, Collision
    Say 'Creating ['Title']'
    rc = SysCreateObject( Class, Title, Location, Setup, Collision )
    If rc <> 1 Then
        Say ' > failed to create ['Title' | 'Class'] at location ['Location']'
    return rc

CreateObjects:

rc = CreateObject('WPProgram',,
                'Full Backup^'RiappsDir,,
                '<WP_DESKTOP>',,
                'NOPRINT=YES;'||,
                        'ICONPOS=20,20;'||,
                        'EXENAME='InstallDir'\RiBackup.Cmd;'||,
                        'PARAMETERS='SysName' 'RiappsDir' 'BackDir';'||,
                        'PROGTYPE=WINDOWABLEVIO;'||,
                        'OBJECTID=<RI_FULLBACK>',,
                'R')

rc = CreateObject('WPProgram',,
                'Diff Backup^'RiappsDir,,
                '<WP_DESKTOP>',,
                'NOPRINT=YES;'||,
                        'ICONPOS=30,20;'||,
                        'EXENAME='InstallDir'\RiBackup.Cmd;'||,
                        'PARAMETERS='SysName' 'RiappsDir' 'BackDir' Diff;'||,
                        'PROGTYPE=WINDOWABLEVIO;'||,
                        'OBJECTID=<RI_DIFFBACK>',,
                'R')

return

