Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using 'loopcounter' as variable name 1

Status
Not open for further replies.

RtWee

Technical User
Dec 16, 2002
19
NL
Hi

I got 10 variable of the type Tbitmap; named bitmap1, bitmap2 .. .. bitmap10;
For initiating i want to apply the same procedure 10 times, rather than repeating myself 10 times I would like to have it in some sort of loop
e.g.


for ii:=1 to 10 do begin
(bitmap ii).free
end;

this of course doesn't work, but what will ?

 
i've solved my problem sofar by making arrays

but i still would like to know if there is the possibillity
to use a loopcounter to address a variable
 
I've already answered this for you when you posed the question in the thread.
"Determining field in record type"

Here is the answer again:

There is a useful function in Delphi called FindComponent and it is ideal for your requirement.
Code:
var
  ii: integer;
  bmp: TBitMap;
for ii := 1 to 10 do begin
  bmp := FindComponent('BitMap'+IntToStr(ii)) as TBitMap;
  bmp.Free;
end;

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top