Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Please help me make this better
Please help me make this better [message #8560] |
Sat, 17 March 2007 19:53 |
MikeyV
Messages: 20 Registered: February 2007
|
Promising Member |
|
|
Hi,
I have a rather cumbersome block of code that I would like to streamline.
void Sats3::DoDrops() {
// Populate the drop lists
SQL*Select(Code).From(Generation);
while(SQL.Fetch())
ist.dGen.Add(SQL[0]);
SQL*Select(Code).From(EdCode);
while(SQL.Fetch())
ist.dEdCode.Add(SQL[0]);
SQL*Select(Code).From(Sex);
while(SQL.Fetch())
ist.dSex.Add(SQL[0]);
SQL*Select(Code).From(Race);
while(SQL.Fetch())
ist.dRace.Add(SQL[0]);
SQL*Select(Code).From(Ethnic);
while(SQL.Fetch())
ist.dEthnic.Add(SQL[0]);
SQL*Select(Code).From(EnlType);
while(SQL.Fetch())
ist.dEnlType.Add(SQL[0]);
SQL*Select(Code).From(Area);
while(SQL.Fetch())
mis.txtOpsArea.Add(SQL[0]);
}
As you can see, it just does the same thing over and over. I was thinking something like this:
void SATS3::Populate (const char *field, const char *table, const char *tab, const char *control) {
SQL*Select(field).From(table);
while(SQL.Fetch())
tab.control.Add(SQL[0]);
}
And then call it like this:
Populate("Code", "Area", "ist", "dEnlType");
Any suggestions?
Mike
|
|
|
Goto Forum:
Current Time: Fri Apr 26 23:11:50 CEST 2024
Total time taken to generate the page: 0.04520 seconds
|