C++ (Borland Builder) question


 
Thread Tools Search this Thread
Top Forums Programming C++ (Borland Builder) question
# 1  
Old 11-01-2006
C++ (Borland Builder) question

If anyone uses this can you help please;

I want to use a for loop to update several Objects without having to write them all into the script, e.g.,

If I have CheckBox1, CheckBox2, CheckBox3 etc I want loop round something like

for (int i=1;i<10;i++)
CheckBox(i)->State = 1;

Where CheckBox(i) would equal CheckBox1, CheckBox2 ...

How do I get the code to recognise that CheckBox(i) is in fact CheckBox1 etc

Any help or pointers would be appreciated
# 2  
Old 11-01-2006
Note that Borland Builder is a Windows product, and this is a UNIX forum. We can answer language questions, but you're not likely to find answers for API specific things.

Also note that it's a very poor idea to declare variables inside a for loop like that. That does wildly different things on different compilers; sometimes it works, sometimes it causes compiler errors, sometimes it breaks things silently. Don't do it.

I'd make an array:
Code:
int i;
Object *checklist[]={checkbox1, checkbox2, checkbox3, checkbox4, NULL};

for(i=0; checklist[i] != NULL; i++)
  checklist[i]->State=1;

Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Programming

C++/g++ builder for LINUX???

Hello everybody there, I wanted to know, if any builder(RAD) existed for programming in gcc(g++)/c++ in Linux. I am using scientific Linux. I need it urgently if it exists. --rohit (1 Reply)
Discussion started by: RohitThakkar
1 Replies
Login or Register to Ask a Question