Page 1 of 1

so much constants...what's efficient???

Posted: October 27th, 2002, 6:03 pm
by JBxll
Dear all,I've created a xll file which is called from excel, for each function used in excel, the xll file is called and some constants are needed. But the total of these constants which my xll file has to pick a few from is a lot (+10,000).What's the most efficient way to deal with these constants? Defining a tabel and declaring them one by one? Using a external file? HSHGR JBso much constants...what's efficient???

so much constants...what's efficient???

Posted: October 27th, 2002, 6:11 pm
by jens
Hi,do you need to have the constants available on the worksheet (as some kind of symbolic value)?And what about storing these in an external database?Jens.

so much constants...what's efficient???

Posted: October 27th, 2002, 6:47 pm
by JBxll
I need to have the constants read from a pre defined database or embedded in my xll, but I am not familiar with the efficiency of data structures

so much constants...what's efficient???

Posted: October 27th, 2002, 10:53 pm
by jens
Maybe I don't see your problem here, but why not dump (name, value) tuples from the database into #define MYAPP_CONST_<name> <value>lines and #include this file into your project. I can't tell you how many defines the preprocessor can handle, but be sure to use precompiled headers if compilation time is a concern. Alternatively you could either output const int myapp_const_<name> = <value>;lines or generate an .IDL file, which means that all constants will be available in Visual Basic, too.Jens.

so much constants...what's efficient???

Posted: October 28th, 2002, 10:48 am
by DominicConnor
If performance is your core objective, but you want database driven updates then you might considermachine written code.you can write code of the form:char *varname[N] ={"VolSmirk","thing", "other thing"};double val;fp = fopen("Parameters.h","w");for (i=0 ; i != N; i++){ GetDBVar (varname, & var); fprintf ("#define %s (%g)\n", varname,var);}fclose(fp);This means your code will be very fast on loading, requiring no database neogitiation, or indeed noconnection to the parameter table.The brackets in the fprintf are just my defensive programming.You might equally write fprintf ("const double %s (%g)\n", varname,var);If all your params are of know type. The #define has the "advantage" of not caring about types.The classy way to write this (bad pun) is to declare a Param class, and have an extra field in your database that knows about types.