The SetLength should not be in the loop, but after it. Other than that it looks fine to me.
BTW. You should be able to replace lines 27..29 with just
records[j] := records[j+1];
Don't know why you are using all-caps keywords, but it sure is anachronistic (a hold-over from brain-damaged BASIC users). I've not changed the functionality of your code here. Just structured it a little better...
PROCEDURE delete(VAR records: employeeRecords);
VAR
n, j: Integer;
nameDel: String;
BEGIN
Write('Name: ');
Readln(nameDel);
n := 0;
WHILE (records[n].name <> nameDel) AND (n < High(records)) DO
Inc(n);
IF records[n].name = nameDel
THEN BEGIN
FOR j := n TO High(records)-1 DO
records[j] := records[j+1];
SetLength(records, High(records))
END
ELSE BEGIN
Writeln('That employee could not be found!');
Writeln
END
END;
Hope this helps.
Reputation Points: 1140
Solved Threads: 229
Postaholic
Offline 2,039 posts
since Oct 2007