GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Jul-2005, 09:37
shakoush2001 shakoush2001 is offline
New Member
 
Join Date: Jul 2005
Posts: 10
shakoush2001 is on a distinguished road

Array question


Hi
Iam using Borland Builder 5, and Ive got 10 TImages called Image1, Image2....Image10. I want to add these images to an array of type TImage can I do that in a for loop or do i have to add each Image by itself.

CPP / C++ / C Code:
//this is the method Iam using
TImage ImageArray[10];
ImageArray[0] = Image1;
ImageArray[1] = Image2;
ImageArray[9] = Image10;

//this is the method I want to use
for( int i = 0; i <10; i++)
{
 ImageArray[i] = XXX //what should replace the XXX if this is possible
}
Last edited by LuciWiz : 06-Jul-2005 at 04:54. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #2  
Old 05-Jul-2005, 11:02
maprich maprich is offline
Member
 
Join Date: May 2005
Posts: 163
maprich has a spectacular aura aboutmaprich has a spectacular aura about
I assume that you load the image information to Image1,Image2,..,Image10 from an imagefile (e.g. png, jpg..or whatever you use) earlier in your code.

In that case you could do like following:
CPP / C++ / C Code:
TBitmap *myBM;

for( int i = 0; i <10; i++)
{
    myBM = new Graphics::TBitmap;
    myBM->LoadFromFile( filename );
    ImageArray[i]->Picture->Graphic( myBM );
}
As you see simple idea. Instead of many Image1...10 variables just load directly the data to the array. plz keep in mind that the above code is not tested, just wrote from what I remember from 2 years ago using borland but it is just to show you the general idea.

btw you cannot "variabelize" the name of a variable itself as it seems you were after this kind of idea. And there is no need to for such complication; arrays are quite sufficient.
 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick, Insertion, and Partition silicon C++ Forum 0 18-May-2005 20:49
Help with an array using pointers glulu76 C++ Forum 1 01-May-2005 11:21
Noob question on c arrays and functions brett C Programming Language 1 20-Apr-2005 03:59
template comiling problems - need expert debugger! crq C++ Forum 1 01-Feb-2005 21:26

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:18.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.