Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
MikeyV is currently offline  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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Scribble examples compiling and other errors
Next Topic: Using dual-screen
Goto Forum:
  


Current Time: Fri Apr 26 23:11:50 CEST 2024

Total time taken to generate the page: 0.04520 seconds