PDA

View Full Version : Problems with records on delphi 7



Whitt
17-04-2008, 07:24 PM
System: Windows XP, P4 2 GHz
Compiler/IDE: Delphi 7 for Win32
API: Gl Scene
-----

Howdy back again, thought it would happen! I seem to have a problem getting record structure to work. As far as I can see the code is fine, but it keeps firing the record, object or class type required. But I have decarled the structure at the start. If you can the spot the error it will help me no end!

----
type
TDev1 = record
Sizeof : integer;
model :integer;
tlx :integer;
tly, blx, bly, trx, tryi, brx, bry :integer;
end;
TForm1 = class(TForm)
.
.
.

map: array [1..100,1..100] of TDev1;
.
.

for l1:=1 to sizea do // y
for l2:=2 to sizea do //x
begin

map.tlx[l2,l1] :=l2+a[l2-1,l1];
map.tly[l2,l1] :=l1+maxy ;

map.trx[l2,l1] :=l2+(a[l2,l1]+a[l2-1,l1]);
map.tryi[l2,l1] :=l1+maxy;

map.blx[l2,l1] :=l2+a[l2-1,l1];
map.bly[l2,l1] :=l1+maxy+a[l2,l1];

map.brx[l2,l1] :=trx[l2,l1];
map.bry[l2,l1] :=l1+maxy+a[l2,l1];

end;

-----

Far as I can see that should work as I have decared the structure and referenced it correctly...Seriously any help would be apreciated as it is extremely fustrating!

Thanks
Whitt

Brainer
17-04-2008, 07:28 PM
These aren't arrays:

tlx :integer;
tly, blx, bly, trx, tryi, brx, bry :integer;


Yet you try to make arrays out of them by this:

map.tlx[l2,l1] :=l2+a[l2-1,l1];

Whitt
17-04-2008, 07:51 PM
I see, do you have to decare these as arrays even if the record is a array in itself....

I just tried that but it didn't work gave me the same error.
James

EDIT: I'm a idiot, I put the square brackets in the wrong place......Duh... Thanks for the help anyway!!