Program arrprog;
Uses crt;
const
 max=20;
 add='Add Student File';
 edit='Edit Student File';
 del='Delete Student File';
 vi='View All Student File';
Type
 Tdata = record
         id:string;
         nm:string;
         jr:string;
         sm:string;
         End;
Var
data:array [1..max] of Tdata;
i,ls:integer;
Pil:char;

Procedure menu;
Begin
Writeln('Student Data');
Writeln('----------------');
Writeln;
Writeln('1. ',add);
Writeln('2. ',edit);
Writeln('3. ',del);
Writeln('4. ',vi);
Writeln('5. Exit');
Writeln;
End;

Procedure view(last:integer);
Var
awal:integer;
Begin
Writeln(vi);
Writeln('-------------');
Writeln;
For awal:=1 to last do
 Begin
  With data[awal] do
   Begin
   Writeln;
   Writeln('Mahasiswa Ke-',awal,' :');
   Writeln;
   Writeln('Id       : ',id);
   Writeln;
   Writeln('Nama     : ',nm);
   Writeln;
   Writeln('Fakultas : ',jr);
   Writeln;
   Writeln('Semester : ',sm);
   Writeln;
   End;
  End;
End;

Begin
i:=0;
repeat
clrscr;
menu;
Write('Choice : ');Readln(pil);
Writeln;
Case pil of
'1' : Begin
      inc(i);
      Writeln(add);
      Writeln('----------------');
      Writeln;
       with data[i] do
         Begin
         Write('Id       : ');Readln(id);
         write('Name     : ');Readln(nm);
         write('Faculty  : ');Readln(jr);
         write('Semester : ');Readln(sm);
         End;
      Writeln;
      Writeln('Program telah disimpan pada Indeks ke-',i);
      delay(2000);
      ls:=i;
      End;
'2' : Begin
      //Confused
      End;
'3' : Begin
      //Need help for array delete
      End;
'4' : Begin
      view(ls);
      End;
'5' : Begin
      writeln('Sedang Menutup program . . . ');
      Delay(2000);
      exit;
      End;
Else
   Begin
   Writeln('Pilihan tidak sesuai !');
   Delay(2000);
   End;
End;
until pil='4';
Readln;
End.

Need help for edit and delete code :)

What do you need help with ?

What do you need help with ?

need help

edit and delete program code

That was obvious. Do we need to guess what you are supposed to do ?

I made this function that deletes an array item, and another that edits an array, enjoy :)

procedure DeleteArrayItem(var ar: array of TData; const Index: Integer);
begin
   if (Index < High(ar)) and (Index > Low(ar)) then begin
   if (Index = High(ar) then begin
   SetLength(ar, Length(ar) -1);
   Exit;
   end;
   end;
   Finilize[ar[Index]);
   System.Move(ar[Index+1], ar[Index], (Length(ar)-Index-1) * SizeOf( 
   if Index < Low(X) then Exit;
   if Index = High(X) then
   begin
     SetLength(X, Length(X) - 1) ;
     Exit;
   end;
   Finalize(X[Index]) ;
   System.Move(X[Index +1], X[Index],(Length(X) - Index -1) * SizeOf(TData) + 1) ;
   SetLength(ar, Length(ar) - 1) ;
end;
procedure EditArray(var ar: array of TData;const id:string;nm:string;jr:string;sm:string index : integer);
begin
ar[index].id := id;
ar[index].nm := nm;
ar[index].jr := jr;
ar[index].sm := sm;
end;
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.