constants

How to make a ConstantList Class in Objective C

How to make a ConstantList class in Objective C of an application which could be accessible to all the classes who are using constants. like in Actionscript we do: public class ConstantList { public static const EVENT_CHANGE:String = "event_change"; } Or what is the best approach to handle application constant. Regards Ranjan ...

Use lower-case constants for false, true, null in NetBeans

There is any way to set them in auto completion code in lowercase? Automatically they appear in UPPERCASE, I know that constants are defined in UPPERCASE but I prefer lowercase for them. ...

What is the value of HSHELL_FLASH?

What is the value of HSHELL_FLASH ...

Choosing values for constants

One thing I've never really understood is why in many libraries, constants are defined like this: public static final int DM_FILL_BACKGROUND = 0x2; public static final int DM_FILL_PREVIOUS = 0x3; public static final int TRANSPARENCY_MASK = 1 << 1; public static final int TRANSPARENCY_PIXEL = 1 << 2; What's up with the 0x and << stuff?...

Sharing constants across languages

I have a long list of constants that I need access to in several projects which are in different languages(Verilog, C, C++ and C#). Rather than repeating them in each language, is there a good way to share these? The only thing I could think of would be a text file and a preprocessing script? Is this the best solution or is there somet...

How to initialize an array constant specifying desired indexes

Hello StackOverflowers, What I just want is to initialize a string[] array constant by specifying not only the values, but the indexes they will be attached to. For example, on: private static readonly string[] Pets = new string[] {"Bulldog", "GreyHound"}; I would like to state that BullDog corresponds to index 29 and GreyHound to 5 ...

Uninitialized Tag constant in Rails 3 with Acts_As_Taggable_On

This controller action worked perfectly in Rails 2.3.x: def show @title = Tag.find(params[:id]).name @tag = Tag.find(params[:id]) @messages = Post.paginate(Post.find_tagged_with(@tag), :page => params[:page], :per_page => 10, :order => "updated_at DESC") @related_tags = @related_entries.collect{|x|x.tags}.flatten....

How does O=Deparse work, and does Perl have and fold constant arrays?

I'm wondering, does -MO=Deparse show you all of the Perl optimizations, and why doesn't this get folded in Perl 5.10? $ perl -MO=Deparse -e'[qw/foo bar baz/]->[0]' ['foo', 'bar', 'baz']->[0]; -e syntax OK Some on IRC thought that O=Deparse might not be showing it all, but it certainly shows some constant folding. $ perl -MO=Deparse -...

Javascript condition based on Rails variable

I want to set a global constant (in Rails) and then depending on that I want to put a condition in a JavaScript file (which is included in every page of my app). I also have some Rails dependent code based on this variable. What is the best way to do this ? ...

Objective-C/C++ constants

Hi, EDIT: My example might have created some confusion. I have changed the example below to reflect what I want to achieve. Hope this is more clear. I am trying to define a constant in my objective-c code. I am using the standard #define to do this. Eg: #define bluh "a" I would like to define another constant like this #define...

Objective C - Iphone: Image constant?

Is it possible to have an image as a constant in Objective C for iPhone development? ...

Internationalization for constants-hashes in rails 3

Could you tell me whats the best practice for storing constants with internationalization in rails3? f.e. i want to have a constant-hash for haircolours for my user model: # btw: how can I store such hashes in the locales.yml-files? # en.yml HAIR_COLOURS = { "brown" => 0, "white" => 1, "red" => 2, "dark-brown" => 3...} # de.yml HAIR_C...

Is there any benefit to decalre a constant in a local scope in C#?

Hi, Is there any benefit to declare a local variable as "const" if I know that I won't be chaning its value? Thanks, ...

How to deal with screen position constants in iPhone code?

I have a requirement to fill cells with varying length wraparound text. My current routine is handling this satisfactorily, however, I am concerned about the use of a couple of constants being used. The values 10 and 260 below represent the margin and cell width expected, but they are only accurate for standard definition resolution in...

variable that can't be modified

Does C# allow a variable that can't be modified? It's like a `const`, but instead of having to assign it a value at declaration, the variable does not have any default value, but can only be assigned a value once at runtime (EDIT: and possibly not from constructor). or is this not possible?...

how do i define a constant in a string in PHP?

Hi, I am using a constant NEWS_POST_NUMBER and i am getting confused on how to attach it to a string to query it to database. i tried many things and it is giving errors. here is the string i tried. $query = " SELECT news.id, news.timestamp, news.title FROM news ORDER BY id DESC LIMIT $from, NEWS_POST_NUMBER"; please note NEWS_PO...

static string constants in class vs namespace for constants [c++]

I want to declare string constants that will be used across various classes in the project. I am considering two alternatives Option 1: #header file class constants{ static const string const1; }; #cpp file const string constants::const1="blah"; Option 2: #header file namespace constants{ static const string const1="bla...

tidy way to manage constants

I have a series of movieclips, all with sets of constants to manage width, height, color, etc: public class MyMovieClip extends MovieClip { public static const MY_WIDTH:Number = 200; public static const MY_HEIGHT:Number = 200; public static const MY_COLOUR:uint = 0x000000; public function MyMovieClip() { // etc } Anyhow, this...

Use of undefined constant ADMIN - assumed 'ADMIN'

I'm getting the error Use of undefined constant NORMAL - assumed 'NORMAL' when running my code, I can't find anything wrong with th code var $type; const NORMAL=1; const ADMIN=2; public function getTypeOptions(){ return array( self::NORMAL=>'Normal', self::ADMIN=>'Administrator', ); ...

Coding : Using Struct as a DataUtility/Library for Harcode values (Constants)

Is it OK to use Structs as Data library for harcoded values? Sometimes we can't avoid harcoding somethin althought its better to put it on something like xml file or a database table, but sometimes it's not possible for some reasons.. public struct BatchStatus { public const string Submitted = "0901XX"; public const string Act...