global-variables

PHP global keyword and $GLOBALS dont seem to work in version 5.3

Hi, I seem to have this problem after upgrading to PHP 5.3 from 5.2. The site runs off index.php which includes() various other utility functions then includes the correct page based on GET variable value. Now one thing I cannot understand is that in xdebug I dont see $GLOBALS. The other bit is - index.php: include_once('includes/glob...

Change the type of a global variable in a function initializing it

I have a __main__ function where I initialize a lot of variables that are to be used in my program, later on. I have a problem where a variable that I temporarely declare as None in the outer scope, is assigned an object of SomeClass, but due to scoping rules I cannot access it's content in the outer scope. Because the constructor of Som...

global variable implementation

When I write the following program: file 1: #include <stdio.h> int global; void print_global1() { printf("%p\n", &global); } file 2: #include <stdio.h> char global; void print_global2() { printf("%p\n", &global); } file 3: void print_global1(); void print_global2(); int main() { print_global1()...

How can I figure out in my module if the main program uses a specific variable?

I know this does not sound Pythonic, but bear with me for a second. I am writing a module that depends on some external closed-source module. That module needs to get instantiated to be used (using module.create()). My module attempts to figure out if my user already loaded that module (easy to do), but then needs to figure out if the ...

How do you get the initialized value of a global variable out of an object file?

If you have an object file, how do you get the initialized value of a global variable in that object file's data segment? For example, say I've done the following: # I'm interested in the variable foo inside bar.o in libbar.a: $ ar -x libbar.a bar.o $ nm --print-size bar.o | grep foo 00000048 00000004 D foo This tells me that foo is ...

Global Variable JavaScript (Changing Value)

Is it possible to change the value of a global variable in JavaScript? If so, is it possible to do it in a function called by an event listener such as "onreadyStateChange"? It's working for normal functions. but doesn't change when I call a function like this: <script.......> var dom1 = 3; function work() { ... ...

How can I prevent a name error error in python?

When I run my program core.py (http://pastebin.com/kbzbBUYd) it returns: File "core.py", line 47, in texto core.mail(numbersendlist, messagetext) NameError: global name 'core' is not defined Can anyone tell me what is going on and how I can stop this error? If it helps, the "import carrier" line in core.py refers to carrier.py (ht...

Cannot obtain shared variable value in separate threads

My program has a server thread and separate client threads that are individual connections to other servers. So how my program works is the client threads make individual requests, and when each of them so, I increment the shared variable iTimeStamp. However, I need to access this shared variable value through my Server thread, but when...

Windows Controls or .NET objects as Global Variable in Visual C++

Hi, I'm Writing a C++ Class. I want to keep a global variable in System::Windows::Form::Control type or a .NET managed objects. I want to process somethink on this global variable. But Visual C++ is not allowed this. Returning Error is: "global or static variable may not have managed type" May be this error interest Garbage Collector...

Jumi (Joomla plugin) breaking PHP global keyword

When I include a PHP script via Jumi, it seems to break the global keyword. Example: <?php $a = 5; function foo() { global $a; if (isset($a)) echo $a; else echo '$a is not set'; } foo(); ?> When I run this PHP script (named test.php) by itself, it correctly prints 5. When I...

jQuery global variable problem

var id = $(this).children().html(); // id is 5 $.ajax({ url: 'ajax.php?id=' + id, success: function(data) { id = data; // id is 1 } }); if(id == 1){ // id is again 5 ... } Why in the following example I can't reinitialize the id variable? What is wrong? Thanks. ...

In PHP xmlparser, why can't I store a global from my character_data_handler()?

(or Here are the code essentials: $host = ""; ... xml_set_character_data_handler($xmlparser, "tagContents"); ... function tagContents($parser, $data) { global $current; global $host; if ($current == "HOST") { $host = $data; // Trying to store a global here } if ($current == "PATH") { echo ...

asp.net declaring global variable/class in application scope 3 ways. Which one is best?

I am looking for differences between those 3 ways of using static class in asp.net application scope. Will all of these point to the same class? Which one is preferable >object< defined declaratively inside global.asax or static class ? examples: <object runat="server" scope="application" class="classname" ID="objID"></object> VS pu...

How do I get the upper and lower limits to the global data area in C?

I am making a garbage collector to develop an appreciation for how they work. I can process registers as well as heap and stack memory to find potential references to allocated blocks. But processing the global data memory has eluded me. Is there a way to get the upper and lower bounds of the global memory space in C (I'm using GCC on...

Why won't my global variables properly resolve?

here is my plugin activation code $classified_category_name = 'classified'; $credit_table_name = 'credits'; $credit_table_version = 0.1; register_activation_hook(__FILE__, 'LBH_Classifieds_Activate'); function LBH_Classifieds_Activate() { global $wpdb; global $classified_category_name; global $credit_table_name; global...

Why can't I create an array with size determined by a global variable?

Why does the array a not get initialized by global variable size? #include<stdio.h> int size=5; int main() { int a[size]={1,2,3,4,5}; printf("%d",a[0]); return 0; } The compilation error is shown as "variable-sized object may not be initialized". According to me the array should get initialized by size. and what would be...

global variables in c#.net

how can i set a global variable in a c# web application? what i want to do, is to set a variable on a page (master page maybe) and access this variable from any page. i neither want to use cache nor sessions. i think i have to use global.asax... any help? ...

how to run python scripts from other script and have thier root in my root

hello all i have a module "B", i want to run it from a script "C", and i want to call global variables in "B", as they wer in "C" root, another problem that is if i imported sys in "B" when i run "C" it doesnt see sys # NameError: global name 'sys' is not defined # what shall i do? ...

Ruby - Is there a way to overwrite the __FILE__ variable?

I'm doing some unit testing, and some of the code is checking to see if files exist based on the relative path of the currently-executing script by using the FILE variable. I'm doing something like this: if File.directory?(File.join(File.dirname(__FILE__),'..','..','directory')) blah blah blah ... else raise "Can't find directo...

Compile redeclaration error of global variable in C++, but not in C.

Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable; void a_f() { printf("int_variable: %d\n", int_variable) int_variable++; } b.h //b.h header #include <stdio.h> int int_variable; void b_f() { printf("int_variable: %d\n", int_variable) int_variable++; } main.c //main.c #inclu...