Hi, I'm a at a very beginner level in Pascal and am learning it for my A-levels

We're learning how to save, add, search records for a database console. I managed to do all of them, but I am having trouble with deleting records. In my procedure below, I'm trying to initialise the records to null. Is there a specific way to express that or is that a complicated process in Pascal. Also can you tell me a simpler way

 procedure Delete;
  var
    DeleteInput:string;
    Count:integer;
    Found: boolean;
  begin
    write('Enter the surname of the Pupil: ');
    readln(DeleteInput);
    Found:=false;
    for Count:=1 to LastRecord do
     begin
       if Pupils[Count].surname = DeleteInput then
         begin
          found:=true;
          Pupils[Count]. Surname ='' ;
          Pupils[Count]. Age ='' ;
          dec(LastRecord);
         end;
       end;
    if found= false then
      begin
       writeln('Record not found for that surname');
     end;
  end;

One option is to fill all bytes in the record with the value zero in one hit, rather than setting each individual field. Something like:

if Pupils[Count].surname = DeleteInput then
  FillChar(  Pupils[Count], sizeof(Pupils[Count]), 0);

The snippet isn't quite enough to provide an answer.

Are your records being added/deleted from an array/list/queue or some other collection object?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.