SRL Archive - OSR Help

Class Type error.


mrpickle

2010-05-23 21:45:11

I posted this on Cohn's Tut thread… but I'm kinda rushy for an answer. xD


I'm messing around with Types. Wondering, how do I use a type as an integer?


Type
SRecord = record
MoveCoordinateX : array [1..4]of Integer;
MoveCoordinateY : array [1..4]of Integer;
end;

Movement:Array of SRecord;

Procedure Example (x,y:integer)
begin
DoSomething(x,y,blah,blah,blah);
end;

begin
With Movement[0] do
begin
MoveCoordinateX[0] := 1 ;
MoveCoordinateY[0] := 3 ;
end;
///
Example(SRecord.MoveCoordinateX[0],SRecord.MoveCoordinateX[0]); // How to make this part work?
/// I get class type error.
end.

MylesMadness

2010-05-23 21:50:59

Change the SRecord on that line to Movement

mrpickle

2010-05-23 23:26:11

I should've seen that. xD… worked 3h straight and got tired lol. Thanks Myles.

Edit: Now I have a "semi colon expected" error at that same last line after changing SRecord to Movement. I just can't see where a semi colon would go.

Sex

2010-05-24 00:03:10

type
SRecord = record
MoveCoordinateX : array [1..4] of Integer;
MoveCoordinateY : array [1..4] of Integer;
end;
TSRecordArray = array of SRecord;

var
Movement : TSRecordArray;

procedure Example(x,y : integer);
begin
Writeln(Format('%d, %d', [x, y]));
end;

begin
SetArrayLength(Movement, 1);
with Movement[0] do
begin
MoveCoordinateX[1] := 1;
MoveCoordinateY[1] := 3;
Example(MoveCoordinateX[1], MoveCoordinateY[1]);
end;
end.
Take a look at that? Show exactly what you have though.

Dgby714

2010-05-24 01:18:06

From: Sex
type
SRecord = record
MoveCoordinateX : array [1..4] of Integer;
MoveCoordinateY : array [1..4] of Integer;
end;
TSRecordArray = array of SRecord;

var
Movement : TSRecordArray;

procedure Example(x,y : integer);
begin
Writeln(Format('%d, %d', [x, y]));
end;

begin
SetArrayLength(Movement, 1);
with Movement[0] do
begin
MoveCoordinateX[1] := 1;
MoveCoordinateY[1] := 3;
Example(MoveCoordinateX[1], MoveCoordinateY[1]);
end;
end.
Take a look at that? Show exactly what you have though.


Example() needs to be taken out of the With.

Sex

2010-05-24 01:23:08

From: Dgby714
Example() needs to be taken out of the With.

Um, no it does not. I know what I am doing..I put it there so that I do not require Movement. in front of all the MoveCoordinateX and such..

mrpickle

2010-05-24 10:04:49

I guess with…do instead of the SRecord.Movement[x]. Not entirely sure why, but it compies. Thanks Sex.

Sex

2010-05-24 17:26:22

From: mrpickle
I guess with…do instead of the SRecord.Movement[x]. Not entirely sure why, but it compies. Thanks Sex.

No you can use that just put Movement instead of SRecord. SRecord is the type while Movement is the variable.