/^end:/ { ... ; next }
Select end of record line (line starting with 'end:'), execute '...' code and read next line.
if (! (Record in Records)) { ... }
If the record definition have not been memorized in the Records array, execute '...' code.
The code print the full record (label, definition, end
and memorize the record definition.
Records[Record];
Create an element in the array Records. The index of this element is the record definition.
print RecordLabel ":"; print Record; print $0;
Print the full record : Label, definition and end.
Record = "";
Reset the Record definition.
$1 ~ /^.*:/ { ... ; next}
Select start of record (line with field 1 ending with ':'), execute '...' code and read next line.
sub(/:.*/, "", $1);
RecordLabel = $1;
The record label is memorized in the RecordLabel variable.
It is equal to all characters before ':' in field 1.
{ ... }
Select record definition line, execute '...' code.
Record = (Record ? Record "\n" : "") $0;
Append line read $0 to the variable Record where previous lines are memorized.
A line separator is added before if a line have already been memorized.
Jean-Pierre.