/* Custom mainline for macro */

    call RXFuncAdd "VRLoadFuncs", "VROBJ", "VRLoadFuncs"
    call VRLoadFuncs

    _VREVersion = SubWord( VRVersion( "VRObj" ), 1, 1 )
    if( _VREVersion < 2.10 )then do
        call VRMessage "", "This program requires VX-REXX version 2.1 to run.", "Error!"
        return 32000
    end

    signal on SYNTAX name _VRESyntax
    signal _VREMain

_VRESyntax:
    parse source . . _VRESourceSpec
    call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL":" ErrorText(rc), "Error!"
    call VRFini
    exit 32000

_VREMain:
/*:VRX         Main
*/
/*  Main
*/
Main:
/*  Process the arguments.
    Get the parent window.
*/
    parse source . calledAs .
    parent = ""
    argCount = arg()
    argOff = 0
    if( calledAs \= "COMMAND" )then do
        if argCount >= 1 then do
            parent = arg(1)
            argCount = argCount - 1
            argOff = 1
        end
    end
    InitArgs.0 = argCount
    if( argCount > 0 )then do i = 1 to argCount
        InitArgs.i = arg( i + argOff )
    end
    drop calledAs argCount argOff

/*  Load the windows
*/
    call VRInit
    parse source . . spec
    _VREPrimaryWindowPath = ,
        VRParseFileName( spec, "dpn" ) || ".VRW"
    _VREPrimaryWindow = ,
        VRLoad( parent, _VREPrimaryWindowPath )
    drop parent spec
    if( _VREPrimaryWindow == "" )then do
        call VRMessage "", "Cannot load window:" VRError(), ,
            "Error!"
        _VREReturnValue = 32000
        signal _VRELeaveMain
    end

/*  Process events
*/
    call Init
    signal on halt
    do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
        _VREEvent = VREvent()
        interpret _VREEvent
    end
_VREHalt:
    _VREReturnValue = Fini()
    call VRDestroy _VREPrimaryWindow
_VRELeaveMain:
    call VRFini
exit _VREReturnValue

VRLoadSecondary: procedure
    name = arg( 1 )

    window = VRLoad( VRWindow(), VRWindowPath(), name )
    call VRMethod window, "CenterWindow"
    call VRSet window, "Visible", 1
    call VRMethod window, "Activate"
return window

/*:VRX         Fini
*/
Fini:
    window = VRWindow()
    call VRSet window, "Visible", 0
    drop window
return 0

/*:VRX         Halt
*/
Halt:
    signal _VREHalt
return

/*:VRX         Init
*/
Init:
    call VRMethod 'Application', 'GetVar', 'args.'
    AcctDir = args.1
    srcRec = args.2
    window = VRWindow()
    call VRMethod window, "CenterWindow"
    call VRSet window, "Visible", 1
    call VRMethod window, "Activate"
    drop window
return

/*:VRX         PBDailyHelp_Click
*/
PBDailyHelp_Click:
address cmd 'view e-teller Editing Fixed Transactions'
return

/*:VRX         PBDailyRefresh_Click
*/
PBDailyRefresh_Click:
call VRSet 'PBDailyRefresh', 'Enabled', 0
call VRSet 'MLEDaily', 'Value', ''
call SWDaily_Create
call VRSet 'Window1', 'Pointer', '<default>'
return

/*:VRX         PBDailySave_Click
*/
PBDailySave_Click:
value = VRGet( 'MLEDaily', 'Value' )
if value = dailyBuff then do
    call VRMessage '', 'Contents have not changed.  '||'0a'x||'No need to save.  ', 'Information'
    return
end
ok = VRDeleteFile( AcctDir||'\et_fix.dat' )
if ok = 0 then do
    call VRMessage 'Screen', VRError(), 'Error'
    return
end
call charout AcctDir||'\et_fix.dat', value
call stream AcctDir||'\et_fix.dat', 'c', 'close'
dailyBuff = value
drop value
return

/*:VRX         PBFixedRegen_Click
*/
PBFixedRegen_Click:
if( \VRFileExists( 'et_month.exe' ) )then do
    call VRMessage '', 'Unable to locate et_month.exe.  ', 'Error'
    call VRSet 'PBFixedRegen', 'Enabled', 0
    return
end
call VRLoadSecondary 'SWMsg'
'et_month.exe ETELLER REGENERATE'
call VRDestroy 'SWMsg'
call VRSet 'PBFixedRegen', 'Enabled', 0
call VRSet 'PBDailyRefresh', 'Enabled', 1
return

/*:VRX         PBFixedSave_Click
*/
PBFixedSave_Click:
value = VRGet( 'MLEFixed', 'Value' )
if value = FixedBuff then do
    call VRMessage '', 'Contents have not changed.  '||'0a'x||'No need to save.  ', 'Information'
    return
end
ok = VRDeleteFile( AcctDir||'\et_fixed.dat' )
if ok = 0 then do
    call VRMessage 'Screen', VRError(), 'Error'
    return
end
call VRSet 'PBFixedRegen', 'Enabled', 1
call charout AcctDir||'\et_fixed.dat', value
call stream AcctDir||'\et_fixed.dat', 'c', 'close'
FixedBuff = value
drop value
return

/*:VRX         PFFixedHelp_Click
*/
PFFixedHelp_Click:
address cmd 'view e-teller Editing Fixed Transactions'
return

/*:VRX         Quit
*/
Quit:
    rc = srcRec
    call VRMethod 'Application', 'PutVar', 'rc'
    call VRMethod 'Application', 'PostQueue', 0, 1, 'call end_FixFileEdit'
    window = VRWindow()
    call VRSet window, "Shutdown", 1
    drop window rc args. AcctDir DailyBuff FixedBuff value srcRec
return

/*:VRX         SWDaily_Close
*/
SWDaily_Close:
    window = VRInfo( "Object" )
    call VRDestroy window
    drop window
return
/*:VRX         SWDaily_Create
*/
SWDaily_Create:
if( \VRFileExists( AcctDir||'\et_fix.dat' ) )then
    return
call VRSet 'Window1', 'Pointer', 'Wait'
call VRSet 'MLEDaily', 'Painting', 0
call stream AcctDir||'\et_fix.dat', 'c', 'open'
call stream AcctDir||'\et_fix.dat', 'c', 'seek =1'
dailyBuff = CharIn(AcctDir||'\et_fix.dat',1,Chars(AcctDir||'\et_fix.dat'))
call VRSet 'MLEDaily', 'Value', dailyBuff
call stream AcctDir||'\et_fix.dat', 'c', 'close'
call VRMethod 'Application', 'SendKeyString', 'MLEDaily', '{Ctrl}{Home}'
call VRSet 'Window1', 'Pointer', '<default>'
call VRSet 'MLEDaily', 'Painting', 1
return

/*:VRX         SWFixed_Close
*/
SWFixed_Close:
    window = VRInfo( "Object" )
    call VRDestroy window
    drop window
return
/*:VRX         SWFixed_Create
*/
SWFixed_Create:
if( \VRFileExists( AcctDir||'\et_fixed.dat' ) )then
    return
call VRSet 'Window1', 'Pointer', 'Wait'
call VRSet 'MLEFixed', 'Painting', 0
call stream AcctDir||'\et_fixed.dat', 'c', 'open'
call stream AcctDir||'\et_fixed.dat', 'c', 'seek =1'
FixedBuff = CharIn(AcctDir||'\et_fixed.dat',1,Chars(AcctDir||'\et_fixed.dat'))
call VRSet 'MLEFixed', 'Value', FixedBuff
call stream AcctDir||'\et_fixed.dat', 'c', 'close'
call VRMethod 'Application', 'SendKeyString', 'MLEFixed', '{Ctrl}{Home}'
call VRSet 'MLEFixed', 'Painting', 1
call VRSet 'Window1', 'Pointer', '<default>'
return

/*:VRX         SWMsg_Close
*/
SWMsg_Close:
    window = VRInfo( "Object" )
    call VRDestroy window
    drop window
return
/*:VRX         Window1_Close
*/
Window1_Close:
    call Quit
return

/*:VRX         Window1_Create
*/
Window1_Create:
if( \VRFileExists( AcctDir||'\et_fix.dat' ) )then
    call VRMethod "NBFixedFiles", "DeletePage", "1" 
else
    call VRMethod "NBFixedFiles", "SetStatusText", "1", "Filename:  et_fix.dat"
if( \VRFileExists( AcctDir||'\et_fixed.dat' ) )then
    call VRMethod "NBFixedFiles", "DeletePage", "2"
else
    call VRMethod "NBFixedFiles", "SetStatusText", "2", "Filename:  et_fixed.dat"
return

/*:VRX         Window1_Help
*/
Window1_Help: 
address cmd 'view e-teller Editing Fixed Transactions'
return

