In the record structure definition, the type that requires the same value comparison is defined in a continuous range. It will be convenient for subsequent processing.
For example, format block version Definition
// 1 data version structure ‑ dataedition = ^ tdfdataedition; tdfdataedition = packed record size: integer; // structure size Ver: word; // version number Len: integer; // Data Length <--- this value changes with the length of the stored data block. Name: array [0 .. 5] of char; end;
In this case, it is annoying to compare whether the version types are the same. You need to cross the Len definition.
Result: = (v1.size = v2.size) and (v1.ver = v2.ver) and (v1.name [0] = v2.name [0]) and (v1.name [1] = v2.name [1]) and (v1.name [2] = v2.name [2]) and (v1.name [3] = v2.name [3]) and (v1.name [4] = v2.name [4]);
When values of the same type are defined together
// 1. The new data version structure is paidataedition = ^ tdfdataedition; tdfdataedition = packed record size: integer; // structure size Ver: word; // version number name: array [0 .. 5] of char; Len: integer; // Data Length <--- move the variable-length object to the end, which may be very different from the end;
Comparison functions are much simpler.
result: = comparemem (V1, V2, sizeof (tdfdataedition)-4 );