global-variables

Why is Perl script asking for 'global declaration' when I declare something in for loop?

I am reading $digit from infile and want to print it to outfile. But the Perl script is giving an error saying 'Global symbol "$digit" requires explicit package name'. But, if I do declare it globally , $digit='', then the this value is printed to the outfile instead of the value extracted/read from infile. Any suggestions as to what sho...

Global variables in R

Hello all, I am a newbie in R programming. Though I am poking into the manuals, I also wanted to ask the community "How can we set global variables inside a function?" Any pointers will help. Question-2: Regarding plotting, I am using plotting multiple graphs in a single sheet, and to differentiate each one of them, I want to add tit...

How lazy can C++ global initialization be?

I'm used to thinking of all initialization of globals/static-class-members as happening before the first line of main(). But I recently read somewhere that the standard allows initialization to happen later to "assist with dynamic loading of modules." I could see this being true when dynamic linking: I wouldn't expect a global initialize...

Global objects of Managed types

Is there any way to declare/define global/static objects of managed types ? ...

Winforms: access class properties throughout application

Hi, I know this must be an age-old, tired question, but I cant seem to find anything thru my trusty friend (aka Google). I have a .net 3.5 c# winforms app, that presents a user with a login form on application startup. After a successful login, I want to run off to the DB, pull in some user-specific data and hold them (in properties) ...

C# : So if a static class is bad practice for storing global state info, what's a good alternative that offers the same convenience?

Hi, I've been noticing static classes getting a lot of bad rep on SO in regards to being used to store global information. (And global variables being scorned upon in general) I'd just like to know what a good alternative is for my example below... I'm developing a WPF app, and many views of the data retrieved from my db are filtered b...

Avoiding global variables in embedded programming

In the type of embedded programming I'm getting into, determinism and transparency of the running code are highly valued. What I mean by transparency is, for instance, being able to look at arbitrary sections of memory and know what variable is stored there. So, as I'm sure embedded programmers expect, new is to be avoided if at all pos...

Javascript Local vs Global

I thought I had this mess sorted out in my head but for some odd reason its not working. If you declare a variable outside of a function / scope and refer to it without the var inside a function then it changes the variable declared previously... right? however, the first alert returns the correct price, but the second (last) alert ret...

Error and warnings in Xcode when declaring Array of NSString* as a global extern

I am declaring an array of NSString* in a header file of a class. PolygonShape.h NSString* POLYGON_NAMES[] = {@"Invalid Polygon", @"Monogon", ...}; Now I am using this in PolyginShape.m as follows: - (NSString*) name { return (POLYGON_NAMES [self.numberOfSides]); } numberOfSides is an iVar which will indicate the index at which the...

How create an Global Variable for all the project type NSArray

Hello, I would like to know how can I create a global variable type NSArray that i can use (write in/read data) from any class from y app. At the moment i'm using NSUserDefaults, but I don't think this is the best option, because i'm saving one NSArray quite big. Thanks. ...

C# - Winforms - Global Variables

I want some variables to be global across the the project and accessible in every form. How can I do this? ...

PHP can I place a global variable inside a variable sample: $names = $_FILES ["dfile"];

Trying to build a admin panel for uploading text and images here is the html page. The Html page is working fine it's the php page that is broken the html is just here for reference. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <title>Administartor Panel</title> <head> <link rel="stylesheet" type="text/css" hre...

problems with global variables in shared library project (C++)

i have a problem with global variables in a c++ shared library project. my library has to be working as a standard g++ shared library (.so) as well as a dll. i did this by creating files libiup_dll.cpp and libiup_dll.h, where i have something like #ifdef BUILD_DLL // code for the dll: wrapper functions around the classes in my shared l...

Trying to Access Application Delegate Variables / Properties

I am using a variable/propery of my application delegate as a global. (I don't want to deal with a singleton class.) I am trying to write a #define statement in my Application Delegate class. If I type: [UIApplication sharedApplication] in my app delegate class, code hinting does not recognize sharedApplication. But if I type th...

How to make a globally accessible object

Hi i have a little collection of classes some of which should be globally accessible. I found something similar in Zend_Registry, but reading its code i cant understand how a call to a static function could return an initialized instance of a class... i need to do something like: <?php //index.php $obj = new myUsefulObject(); $obj->lo...

Global State and Singletons Dependency injection

this is a problem i face lot of times when i am designing a new app i'll use a sample problem to explain this think i am writing simple game.so i want to hold a list of players. i have few options.. 1.use a static field in some class private static ArrayList<Player> players = new ArrayList<Integer>(); public Player getPlayer(int...

Prevent loss of variables when browser reload button is pressed

Hi to everybody, Is it possible to keep my (global) variables when the page is reloaded? If yes, how? Thanks for any help. Best regards. ...

How to store user entered values across a website using C#?

I am currently working on a website that will have a high volume of traffic on it. The website has only 4-5 pages on it but I need to pass values selected on page 1 over to page 2 where more values are stored and so on until the user gets to page 5 where all values are passed to a third party system using XML. Currently I use a dictiona...

Can I you use __init__.py to define global variables?

I want to define a constant that should be available in all of the submodules of a package. I've thought that the best place would be in in the __init__.py file of the root package. But I don't know how to do this. Suppose I have a few subpackages and each with several modules. How can I access that variable from these modules? Of cours...

[C++] How to solve the problem of global access?

Hi, I'm building an app, and I need the wisdom of the SO community on a design issue. In my application, there needs to be EXACTLY one instance of the class UiConnectionList, UiReader and UiNotifier. Now, I have figured two ways to do this: Method 1: Each file has a global instance of that class in the header file itself. Method 2:...