Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A refactored FileManager.EqualBuffer
FileManager.EqualBuffer PROCEDURE(*USHORT Id)
! Why *USHORT, Id is never altered, so why not pass by value ?
RetAreEqual BYTE(TRUE)
CODE
IF SELF.UseFile()<>Level:Benign ! Is this needed? Should a buffer compare require an open file?
OR SELF.BlobChanged ! A blob has changed so the buffers are unequal
THEN
RetAreEqual = FALSE
ELSIF SELF.FindBuffer( Id ) <> NoError
? ASSERT(FALSE,'Restore handle is invalid')
RetAreEqual = FALSE ! note: this is a change from SV's shipping version of this method where the answer might be true or false
ELSIF SELF.Buffer <> SELF.Buffers.Buffer
RetAreEqual = FALSE
ELSE
DO EqualBuffer:CheckMemos
END
RETURN RetAreEqual
EqualBuffer:CheckMemos ROUTINE
DATA
I SHORT,AUTO
CODE
LOOP I = 1 TO SELF.File{PROP:Memos}
IF SELF.FindBuffer( Id + I ) <> NoError
? ASSERT(FALSE,'Restore handle is invalid (memo does not appear to have been stored)')
RetAreEqual = FALSE ! note: this is a change from SV's shipping version of this method where the answer might be true or false
ELSIF SELF.File{PROP:Value,-I} <> SELF.Buffers.Buffer
RetAreEqual = FALSE
BREAK
END
END
FileManager.FindBuffer PROCEDURE(LONG xID)!,LONG ! returns ErrorCode
CODE
SELF.Buffers.ID = xID
GET(SELF.Buffers, SELF.Buffers.ID)
RETURN ErrorCode()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.