Jump to content
Aloahe

How to edit my own array of types?

Recommended Posts

Hi there..

 

here the problem

type testtype = record Pic,Tol:integer; Name:string; end;

var typearr: Array of testtype;

 

at now I only can write fill my types with:

 

typearr[0].Pic:=bmp;

typearr[0].Tol:=30;

typearr[0].name:='testpic';

 

typearr[1].Pic:=bmp1;

typearr[1].Tol:=301;

typearr[1].name:='testpic1';

 

 

the array shows me [(bmp,30,'testpic),(bmp1,301,'testpic1');

 

if I write an Array of Integers I can do it with

 

Integerarray:=[1,2,3,4,5,-...]

 

but it wont work wih array of others (my own types)

 

any Ideas how I can fill the arrays of my types in the easiert way?

 

greetings

 

 

 

Link to comment
Share on other sites

program New;

type TMyType = record AVar: Integer; ABool: Boolean; end;

var mytypearr: array of Tmytype;

 

function NewType(AVar: Integer; ABool: Boolean): TMyType;

begin

result.AVar := Avar;

result.ABool := ABool;

 

//Result.Int := AVar;

//Result.Bool := ABool;

end;

 

 

begin

MyTypeArr := [NewType(1, false), NewType(2, true)];

 

writeln('wait');

 

 

end.

 

 

thats the right ... but thx for helping

Link to comment
Share on other sites

program New;

type TMyType = record AVar: Integer; ABool: Boolean; end;

var mytypearr: array of Tmytype;

 

function NewType(AVar: Integer; ABool: Boolean): TMyType;

begin

result.AVar := Avar;

result.ABool := ABool;

 

//Result.Int := AVar;

//Result.Bool := ABool;

end;

 

 

begin

MyTypeArr := [NewType(1, false), NewType(2, true)];

 

writeln('wait');

 

 

end.

 

 

thats the right ... but thx for helping

 

I was assuming you already knew how to create the type and then add your own variables to my "shell".

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...