constants

How can I define constants in a separate file in Perl?

I have a bunch of Perl files which take in some filename constants. I would like to define these in a separate file - something like a header file in C. What's the best/most standard way of doing this in Perl? ...

How to obtain a list of constants in a class and their values

I have a class in VB with some constants that represent the string name of my security roles. I need to be able to call a function to return to me a string array(or collection, or whatever) of the values of each of these constants. I will be using it to make sure that my databases Roles table has the same roles as coded into the applic...

PHP - define constants versus using config.ini

Performance wise, I was wondering which method of defining constants/settings is better? Using a config.ini file through a class like Zend_Config_Ini or just defining a series of php constants? ...

PHP Magic Constants

I am trying to get the filename of the script that is running (But not the include it is calling). echo basename(__FILE__); # will always output include.php echo basename($_SERVER['SCRIPT_FILENAME']); # This will do what I want (echo myscript.php), but I was wondering if there was # a better way to grab it, as I have had problems with ...

How is π calculated within sas?

just curious! but I spotted that the value of π held by SAS is in fact incorrect. for instance: data _null_; x= constant('pi') * 1000000000000000000000000000; put x= 32.; run; gives a π value of (3.)141592653589792961327005696 however - π is of course (3.)1415926535897932384626433832795 ( http://www.joyofpi.com/pi.html ) - to 31 d...

c++ global constants issue

We have these set of "utility" constants defined in a series of file. The problem arises from the fact that TOO MANY files include these global constant files, that, if we add a constant to one of those files and try to build, it builds the whole entire library, which takes up more than an hour. Could anyone suggest a better way for thi...

Using constants for message keys and database table names and column names

Recently there was a big debate during a code reveiw session on the use of constants. The developers had used constants for the following purposes: Each and every message key used in the i18N application was declared as a constant. The application contained around 3000 message keys and hence the same number of constants. Each and every...

Does Perl have something similar to PHP's constant()?

I have done some digging through perldoc and the O'Reilly books but haven't found any way to do this. Am I relegated to using something like Readonly? UPDATE: I have nothing against Readonly. I just wanted to be able to do something like PHP's constant(). Example if Perl had constant(): use constant { FIELD_EXAMPLE_O => 345, ...

Java - Eclipse: Externalize Strings ?

It looks like the "Externalize Strings" feature takes everything, makes a Messages class, and a .txt file in which to store the Strings themselves. This is interesting, but I've got another way to store constants: public final class Constants { //for parsing commands public static final String REGEX_COMMAND = "(\\w*) *= *\"(.*)\...

quoting constants in php: "this is a MY_CONSTANT"

I want to use a constant in php, but i also want to put it inside double quotes like a variable. Is this at all possible? define("TESTER", "World!"); echo "Hello, TESTER"; obviously outputs "Hello, TESTER", but what I really want is something like: $tester = "World!"; echo "Hello, $tester"; ouputs "Hello, World!". ...

Where are constant variables stored in C?

I wonder where constant variables are stored. In the same memory area as global variables? Or on the stack? ...

Android RadioButton return a constant?

I am trying to perform a rating system, where with the choices to select from returns a constant number so I can insert a value into a database. My intentions are to have 3 choices, 'Great', 'Mediocre' and 'Bad'. I would like Great to be a constant for '3', Mediocre to have a constant '2' and Bad to have a constant for '1'. I would like ...

PHP security question: store connection details in constants or private properties?

The title should say it all really - I was wondering if it's better to store connection variables as constants (because they can't be changed) or as private properties (because they can't be viewed). My apologies to all those who reel in horror at my lack of security nous... ...

Single file/class to store constants in ASP.NET

I have a ASP.NET web application which has more than 100 pages. Each page is using some common values ( ex : current USDoller rate) .This can be changed at any time. Now I want to maintain this value in a single file so that i can change only her at any time to get it reflected throughtout the project.I dont want to store it in web confi...

Constant strings address

I have several identical string constants in my program: const char* Ok() { return "Ok"; } int main() { const char* ok = "Ok"; } Is there guarantee that they are have the same address, i.e. could I write the following code? I heard that GNU C++ optimize strings so they have the same address, could I use that feature in my progr...

How to share constants between Interface Builder and the code ?

I wonder if there is a way to use constants in Interface Builder, in order to avoid manually setting the same color at different places for example (it could be a very tedious job sometimes...) Currently I set the color in the code and use #define to setup the color, but obviously IB can't use #define... ...

How to declare a static const char* in your header file?

I'd like to define a constant char* in my header file for my .cpp file to use. So I've tried this: private: static const char *SOMETHING = "sommething"; Which brings me with the following compiler error: error C2864: 'SomeClass::SOMETHING' : only static const integral data members can be initialized within a class I'm...

How do I use member functions of constant arrays in C++?

Here is a simplified version of what I have (not working): prog.h: ... const string c_strExample1 = "ex1"; const string c_strExample2 = "ex2"; const string c_astrExamples[] = {c_strExample1, c_strExample2}; ... prog.cpp: ... int main() { int nLength = c_astrExamples.length(); for (int i = 0; i < nLength; i++) cout << c_...

Does .Net have any built in constants for common numbers like million, billion etc?

Does .Net have any built in constants for common numbers like million, billion etc? EDIT: As has been suggested this was for readability reasons, rather than writing 1000000 or 1000000000. I know I can create my own just wanted to check that they didnt already exist before I did so. ...

"static const" vs "#define" in c

Which one is better to use among the below statements in c: static const int var=5; or #define var 5 ...