SED - Source control

SED  -  Source Control

Top  Previous  Next

 

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

 

dict.flagis "DICT" if attempting to write to a dictionary, a null string otherwise.

 

file.nameis the name of the file to be written.

 

record.nameis the name of the record to be written.

 

recis the record data.

 

calleris 1 to indicate a call from SED, 2 for a call from ED.

 

write.allowedshould be returned by the subroutine as True if the write may be performed, False if not. This argument is 1 on calling the subroutine.

 

updatedshould be set True if the subroutine has made any changes to the data in rec. This argument is 0 on calling the subroutine.

 

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