SED - Source Control
SED includes a mechanism that may be used to implement a source control system or other special processing when updated records are written to disk.
Whenever a write is attempted using the save record or write record functions, SED checks for a catalogued subroutine named SOURCE.CONTROL. If this is present, it is called to validate whether data may be written to the file. The subroutine is defined as:
SUBROUTINE SOURCE.CONTROL(dict.flag, file.name,
record.name, rec, caller,
The source control subroutine may be used in any way you wish. Typical uses are simple validation of whether the record may be written or addition of edit history information prior to writing the data. In the latter case, where changes are made to the data passed via the rec argument, the updated flag should be set True so that SED rebuilds its working copy of the data on return.
The following simple example appends a history entry to the end of any record edited in BP or a file with a name ending .BP but ignores dictionaries.
SUBROUTINE SOURCE.CONTROL(DICT.FLAG, FILE.NAME,
IF LEN(DICT.FLAG) THEN RETURN ;* No interest in dictionary
IF FILE.NAME # 'BP' AND FILE.NAME # '.BP' THEN RETURN
DISPLAY SPACE(27) : "SOURCE CONTROL INFORMATION" : @(-4)
DISPLAY "Change description:"
HDR = ""
TAG = OCONV(DATE(), "D2EL")
DISPLAY @(67) : "<" : @(0) :
INPUT S, 66_
HDR<-1> = "* " : TAG : " " : S[1, 66]
TAG = SPACE(9)
REC<-1> = HDR
UPDATED = @TRUE