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, write.allowed, updated)
where
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, RECORD.NAME, REC, FULL.SCREEN, WRITE.ALLOWED, UPDATED)
IF LEN(DICT.FLAG) THEN RETURN ;* No interest in dictionary IF FILE.NAME # 'BP' AND FILE.NAME[3] # '.BP' THEN RETURN
DISPLAY @(-1): DISPLAY SPACE(27) : "SOURCE CONTROL INFORMATION" : @(-4) DISPLAY "Change description:" PROMPT "" HDR = "" TAG = OCONV(DATE(), "D2EL") LOOP DISPLAY @(67) : "<" : @(0) : INPUT S, 66_ WHILE LEN(S) HDR<-1> = "* " : TAG : " " : S[1, 66] TAG = SPACE(9) REPEAT
REC<-1> = HDR UPDATED = @TRUE RETURN END
|