118 lines
3.6 KiB
Plaintext
118 lines
3.6 KiB
Plaintext
function mods_add_new()
|
|
|
|
$insert logical
|
|
$insert rlist_equates
|
|
$insert msg_equates
|
|
declare function utility, msg, set_property, get.reccount, mods_load_control
|
|
declare subroutine record_lock, clear_table
|
|
|
|
|
|
open 'MODS' to ModsTable else
|
|
Void = msg( '', 'Unable to open MODS...' )
|
|
return 0
|
|
end
|
|
*
|
|
open 'BACKREPOS' to BReposTable else
|
|
msg( '', 'Unable to open BACKREPOS' )
|
|
return 0
|
|
end
|
|
open 'SYSREPOS' to SysReposTable else
|
|
msg( '', 'Unable to open SYSREPOS' )
|
|
return 0
|
|
end
|
|
|
|
*
|
|
Stmt = 'SELECT SYSREPOS'
|
|
Stat = utility( 'CURSOR', 'H' )
|
|
|
|
rlist( Stmt, target_activelist$, '', '', '' )
|
|
|
|
* IF WE HAVE A ROW THAT IS IN SYSREPOS BUT NOT IN BACKREPOS THEN
|
|
* CREATE A WR FOR THAT SYSREPOS ( MEANING WE HAVE A DELETION )
|
|
if @reccount then
|
|
Eof = false$
|
|
loop
|
|
readnext Id else Eof = true$
|
|
until eof
|
|
if len( xlate( 'BACKREPOS', Id, '', 'X' ) ) then
|
|
* it exists in backrepos do not modify
|
|
end else
|
|
ModId = field( Id, '*', 1 ):'`'
|
|
ModId:= 'SYSREPOS':'`'
|
|
ModId:= Id:'`'
|
|
ModId:= date():'`'
|
|
ModId:= time():'`'
|
|
ModId:= 'WR'
|
|
SysReposRec = xlate( 'SYSREPOS', Id, '', 'X' )
|
|
record_lock( ModsTable, 'MODS', ModId )
|
|
write SysReposRec on ModsTable, ModId else
|
|
Void = msg( '', 'Unable to write ':ModId:' on MODS...' )
|
|
return 0
|
|
end
|
|
unlock ModsTable, ModId else
|
|
Void = msg( '', 'Unable to unlock ':ModId:' in MODS...' )
|
|
return 0
|
|
end
|
|
* NOW WRITE TO BACKREPOS SO IT IS IS RUN AGAIN WE DON'T CREATE DUPLICATES
|
|
record_lock( BReposTable, 'BACKREPOS', Id )
|
|
write SysReposRec on BReposTable, Id else
|
|
Void = msg( '', 'Unable to write ':Id:' on BACKREPOS...' )
|
|
return 0
|
|
end
|
|
unlock BReposTable, Id else
|
|
Void = msg( '', 'Unable to unlock ':Id:' in BACKREPOS...' )
|
|
return 0
|
|
end
|
|
end
|
|
repeat
|
|
end
|
|
*
|
|
Stmt = 'SELECT BACKREPOS'
|
|
Stat = utility( 'CURSOR', 'H' )
|
|
|
|
rlist( Stmt, target_activelist$, '', '', '' )
|
|
|
|
* IF WE HAVE A ROW THAT IS IN BACKREPOS BUT NOT IN SYSREPOS THEN
|
|
* CREATE A DR FOR THAT SYSREPOS ( MEANING WE HAVE A DELETION )
|
|
if @reccount then
|
|
Eof = false$
|
|
loop
|
|
readnext Id else Eof = true$
|
|
until eof
|
|
if len( xlate( 'SYSREPOS', Id, '', 'X' ) ) then
|
|
* it exists in SYSREPOS do not modify
|
|
end else
|
|
ModId = field( Id, '*', 1 ):'`'
|
|
ModId:= 'SYSREPOS':'`'
|
|
ModId:= Id:'`'
|
|
ModId:= date():'`'
|
|
ModId:= time():'`'
|
|
ModId:= 'DR'
|
|
record_lock( ModsTable, 'MODS', ModId )
|
|
write '' on ModsTable, ModId else ;* WRITE NULL ON DR THE RECORD IS ALWAYS NULL
|
|
Void = msg( '', 'Unable to write ':ModId:' on MODS...' )
|
|
return 0
|
|
end
|
|
unlock ModsTable, ModId else
|
|
Void = msg( '', 'Unable to unlock ':ModId:' in MODS...' )
|
|
return 0
|
|
end
|
|
* NOW DELETE FROM BACKREPOS SO IF IT IS RUN AGAIN WE DON'T CREATE DUPLICATES
|
|
record_lock( BReposTable, 'BACKREPOS', Id )
|
|
delete BReposTable, Id else
|
|
Void = msg( '', 'Unable to delete ':Id:' on BACKREPOS...' )
|
|
return 0
|
|
end
|
|
unlock BReposTable, Id else
|
|
Void = msg( '', 'Unable to unlock ':Id:' in BACKREPOS...' )
|
|
return 0
|
|
end
|
|
end
|
|
repeat
|
|
end
|
|
Void = mods_load_control()
|
|
Stat = utility( 'CURSOR', 'A' )
|
|
return 0
|
|
|
|
|