SRL Archive - OSR Help

Class type expected


TomTuff

2010-12-30 02:46:21

I'm whipping up something for my dad for evony (a game he plays), and i decided to take a crack at learning types while i'm at it.

here's the portion of it that is giving me trouble:

program farm;

type
TCoord = record
Coordinats: array[0..1] of Integer;
end;
TTown = array[0..8] of TCoord;

var
Towns: array of Boolean;
Coords: array of TTown;

procedure SetVars;
begin
Towns := [False, False, False, False, False, False, False, False, False, False];
SetLength(Coords, 8);
with Coords[0] do
begin
Coords[0] := [0, 0];
Coords[1] := [0, 0];
Coords[2] := [0, 0];
Coords[3] := [0, 0];
Coords[4] := [0, 0];
Coords[5] := [0, 0];
Coords[6] := [0, 0];
Coords[7] := [0, 0];
Coords[8] := [0, 0];
end;

with Coords[1] do
begin
end;

with Coords[2] do
begin
end;

with Coords[3] do
begin
end;

with Coords[4] do
begin
end;

with Coords[5] do
begin
end;

with Coords[6] do
begin
end;

with Coords[7] do
begin
end

with Coords[8] do
begin
end;

with Coords[9] do
begin
end;

end;

begin
end.

And I get this error

[Error] (19:18): Class type expected at line 18
Compiling failed.

I don't understand :(

i luffs yeww

2010-12-30 02:58:11


with Coords[0] do
begin
Coords[0] := [0, 0];
Coords[1] := [0, 0];
Coords[2] := [0, 0];
Coords[3] := [0, 0];
Coords[4] := [0, 0];
Coords[5] := [0, 0];
Coords[6] := [0, 0];
Coords[7] := [0, 0];
Coords[8] := [0, 0];
end;

Should be Coordinates[0..8], I think.

More than that, but he solved it after msn I think.

TomTuff

2010-12-30 04:05:31

after a bit of facepalming, i did it this way instead, then used a series of with..do statements

type
TCoordinate = record
x: Integer;
y: Integer;
UseThis: Boolean;
end;
TTownList = record
Coordinates : array[0..8] of TCoordinate;
end;

TList = record
TheList : array[0..9] of TTownList;
end;


var
List: TList;