global-variables

Create temp dir that is globally known and that gets automagically removed (C++)?

In C++, I have a few functions that need to write to a temp directory. Ideally, only one temp directory gets created that they all write to (to minimize I/O overhead). That directory should be automagically removed when the program exits. However, I don't want to deal with creation and removal of the temp directory in the main function ...

Are global variables bad?

In C/C++, are global variables as bad as my professor thinks they are? ...

Convert Oracle stored procedure using REF_CURSOR and package global variable to Postgresql or MySQL.

This package uses two unique features of Oracle, REF_CURSOR and a package global variable. I would like to port the functionality from Oracle to Postgresql or MySQL. PACKAGE tox IS /*=======================*/ g_spool_key spool.key%TYPE := NULL; TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE; /*=======================...

Confusion about global variables in python

Hi, I'm new to python, so please excuse what is probably a pretty dumb question. Basically, I have a single global variable, called _debug, which is used to determine whether or not the script should output debugging information. My problem is, I can't set it in a different python script than the one that uses it. I have two scripts:...

Global variable (or alternative) best practise in .NET

What's the best practise for storing global variables in a VB.NET WinForms app. For example when a user logs into an app you may want to store a CurrentUser object which can be accessed throughout the app. You could store this as an object in a module or create a class which contains members for all the required globals, you would still ...

How can I return a value from GM_xmlhttprequest?

I have this code here: var infiltrationResult; while(thisOption) { var trNode = document.createElement('tr'); var tdNode = document.createElement('td'); var hrefNode = document.createElement('a'); infPlanetID = thisOption.getAttribute('value'); var myURL = "http://www.hyperiums.com/servlet/Planetinf?securitylevel=90...

global variable V.S. file variable in C++

Hi, everyone, what is the difference between global variable and file variable in C++? Thanks! ...

Global variables and scope - C++

I am having small problem in making a global variable works. I am using Visual Studio 2008 and standard C++. I have two projects, one is a static library and second one is a test program which uses this library. I have a global variable in global.h like #ifndef GLOBAL_H #define GLOBAL_H #include <string> extern std::string globalWo...

How do I edit a global variable in a JQuery $.each function?

Ok, so that title probably doesn't explain my question well. Hopefully this makes sense. This is also my first application with jQuery, so forgive me if I'm doing something dumb. I have the following function: function getRandomImages(limit) { imagesArray = new Array(); $.getJSON('createImageArray.php', {limit: limit}, function...

Isn't the Factory pattern the same thing as global state?

Let's say I have a class like this: class MonkeyFish { MonkeyFish( GlobalObjectA private: GlobalObjectA GlobalObjectB GlobalObjectC } Without a factory, I need to do the following in order to instantiated a MonkeyFish. GlobalObjectA a; GlobalObjectB b; GlobalObjectC c; int main() { MonkeyFish * monkey_f...

How can I access a shadowed global variable in C?

How can I access a shadowed global variable in C? In C++ I can use :: for the global namespace. ...

Avoiding Global State

Currently I'm writing an app. If I want to avoid Singletons, do I have to simply pass references of everything around? For example, I have a "main" class. Class: Main +---- Screen +---- Camera +---- Terrain +---- Vehicle +---- PhysicsWorld It contains my Camera, Terrain, and Vehicle,etc classes. Now, I have issues when I'm creating...

How does one avoid accidentally redeclaring global constants in C++?

I have a template matrix class class defined in a header called "Matrix.h". Certain matrices are used repeatedly in my program. I thought that I would define these in the "Matrix.h" header file, like so: const Matrix<GLfloat> B_SPLINE_TO_BEZIER_MATRIX(4, 4, values); When I do this g++ complains that I redefined the constant in questi...

Python game programming: is my IO object a legitimate candidate for being a global variable?

Hello Stackoverflow, I'm programming a game in Python, where all IO activities are done by an IO object (in the hope that it will be easy to swap that object out for another which implements a different user interface). Nearly all the other objects in the game need to access the IO system at some point (e.g. printing a message, updating...

Android: How to declare global variables?

Hi, I am creating an application which requires login. I created the main and the login activity. In the main activity onCreate method I added the following condition: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ... loadSettings(); if(strSes...

Pass JSON obj out from parse function? | noob javascript question

I'm trying to pass an object out of a function. Here's my code: <script type="text/javascript"> // finds the head element; creates a script with passed url; appends it to the head function loadJSON(url) { var headID = document.getElementsByTagName("head")[0]; var newScript = document.createElement('script'); newScrip...

Refactoring classes that use global variables.

I'm working on some classes that get part of their configuration from global variables, e.g. class MyClass { public void MyClass(Hashtable<String, String> params) { this.foo = GlobalClass.GLOBALVAR.get("foo"); this.bar = GlobalClass.GLOBALVAR.get("bar"); this.params = params; } } This is bad for a coupl...

How to keep global variable value unchanged in ATL project?

Hello, I need help on global variable usage in an ActiveX(ATL) project. Basically the ActiveX component function is to navigae to a specified URL in composite control(webbrowser embedded). The URL string is initialize in the beginning and saved in a global variable. here is my source code file of ActiveX project. (Do not be concerne...

Should I be using global variables or passing the variables in java?

Hi all I'm creating a 2d tile based sim game. I have a 2d array of gridSquares, which are accessed and changed from many different classes and methods. Should I pass the 2d array of gridSquares each time, or make it a global? Which is best practice? I was thinking, would it be an option to create a class which just contains a set of va...

C++ static global objects workarounds?

I have a C++ program that crashed due to a bug. It would not even get to main as a NULL pointer was accessed in one of its static global object's contructor functions. To make matters worse the pointer was NULL but should have been set by another global static variable. I think I can wrap those globals in a function that sets global p...