[fpc-pascal] Can someone help me to debug and correct this code?

Goksie goksie at gmail.com
Sun Jan 14 23:17:23 CET 2007


dear all,

const maxliststore=30;
strmaxlen=20;
type objecttype=string[strmaxlen];
list=record
object:array[1..maxliststore]of objecttype;
last:integer;
End;
var choice:char;
position,number:integer;
str:Objecttype;
1st:List;
procedure copyobject(var obj1,obj2:Objecttype);
begin obj1:=obj2;
end;
procedure displayobj(obj:Objjecttype);
begin
write('',obj,'');
end;
procedure initialise(var 1st:list);
begin 1st.Last:=0
end;

function insert(ob:Objjecttype;position:integer;var 1st:List):integer;
vari:integer;
begin
insert:=0;
if not((position<1)or(position>1st.Last+1)
                    or(position>maxliststore))then
begin
for i:=1st.last downto position do
               copyobject(1st.object[i+1],1st.object[i]);
copyobject(1st.object[position],obj);
1st.last:=1st.last+1;
insert:=1;
end
end;

function delete(position:integer;var 1st:List):integer;
var i:integer;
begin
if not((position<1)or(position>1st.last))then
for i:=position to 1st.last do
copyobject(1st.object[i],1st.object[i+1]);
1st.last:=1st.last-1;
delete:=1;
end
end;
procedure displaylist(var1st:List);
var i:integer;
begin
for i:=1 to 1t.last do
displayobj(1st.object[i];
end;

Goksie



More information about the fpc-pascal mailing list