Please assume the following contrived JavaScript:
function do_something() {
var x = 5;
function alert_x() {
alert(x);
}
alert_x();
}
do_something();
The variable x is local to the function do_something. It isn't a global variable because it's not available in every scope (i.e., outside of either of the functions, such...
Dear all,
I have two sql script file which are to be scheduled as windows tasks.
1.sql contains this at the begining:
column dat1 new_value DAY_NUMBER;
select 2 dat1 from dual;
While 2.sql contains this at the begining:
column dat1 new_value DAY_NUMBER;
select 1 dat1 from dual;
If I am going to combine this two scri...
Static members confuse me sometimes. I understand how to initialize a simple built in type such as int with something along the lines of int myClass::statVar = 10;, which you place in a .cpp file, but I have something of the following sort:
class myClass
{
public:
// Some methods...
protected:
static RandomGenerator itsGenerator;
}
...
I know that it's possible to share a global variable across modules in Python. However, I would like to know the extent to which this is possible and why. For example,
global_mod.py
x = None
mid_access_mod.py
from global_mod import *
class delta:
def __init__(self):
print x
bot_modif_mod.py
import mid_access_mod
imp...
I generally live by the rule that Global variables / functions are evil and that every piece of code should live in the class to which it pertains.
This is a very easy rule to follow, and I believe that I haven't ever run into an issue with this rule until now.
Today, however, I need to add a function to my assembly rather than to a sp...
Hi,
I declare a variable and some methods in the global nsobject class like
@interface classGlobal : NSObject {
NSString *myGuid;
}
@property(nonatomic,assign)NSString *myGuid;
and i synthesize in the .m class. but when i try to access the myGuid variable in the same class (classGlobal.m) then it shows the error "instance variab...
Hi,
I'm wondering what the best way is to set a global variable with Jquery / Javascript that can be used and updated by multiple functions.
I've a fairly over complex site that uses sliders(http://www.nwph.info/nwph/nwpho/) , I want to add a dynamic breadcrumb and thought that restructuring the code so that the various functions can...
Hello:
Imagine a system (Python) where the different parts constantly interact with one instance of a given object. What is the best way to provide a global access point to this instance?
So far I can only think of building the (Singleton) instance in __init__.py and import the module as needed:
# __init__.py
class Thing(object, Singl...
I have a snippet of code, to calculate the width of some child items and instead of declaring the parentWidth and other variables in EVERY function.. I am trying to create Global variables to be re-used.. but, its not working.
Here is a portion of my code:
$(document).ready(function(){
parentWidth = $(this).parent().width(); // pa...
Hello there,
I have an MFC application in which I have declared a Global Object say "obj" in a file called MiRec2PC.cpp now I want to use this object in a C file.
I have used an approach in which I include the header file in which the structure of that particular object is declared. I also use a keyword "extern" with that obj when I u...
On Linux I have some generated C++ code from a static library that defines a global variable. A single instance of this global variable is shared between two shared libraries that refer to its symbol.
When the process shuts down and the static termination phase is run, I see that the destructor on this shared instance is run twice! Pr...
I'm trying to use Beanshell in a java application to execute "addon" files supplied by a user. Since the "main" code of the addon is called in a repeating loop, some addons need to use global variables initialized outside the scope of this code in order to keep track of things that require more than one loop cycle. I'm trying to do this ...
Example code from a module:
somevar = "a"
def myfunc(somevar = None):
# need to access both somevars ???
# ... if somevar was specified print it or use the global value
pass
if __name__ == '__main__':
somevar = "b" # this is just for fun here
myfunc("c")
myfunc() # should print "a" (the value of global variable...
I'm a .NET / C# software engineer who's been recruited into a temporary job function I'm not thrilled with.
My company uses an MS-Access application for many of it's current functions. The Visual Basic version in use for this is (v6.5). The developer that assembled it (who's on vacation overseas at the moment) has a 'login' form that ...
I am writing a GTK+ application in C (though the principle here is widely applicable) which contains a GtkComboBox. The GtkComboBox is part of a larger structure returned by another function and packed into the main window.
I don't see how I can get the value of what is selected in the GtkComboBox other than by setting a global variable...
Hi everyone,
I'm new to iPhone development so want to ask, what is the best way to keep global variables and constants which can be accessed by many classes?
Shall I keep them in app delegate or there is a better way which I don't know?
Thanks
...
Hi. I have a url that look like this reg.php?lang=no_NO&passkey=testand im trying to get the passkey variable, but it keeps showing up blank.
When I try print_r($_GET); it prints Array ( ) ?! How can this happen?
The site look something like this
<?php
print_r($_GET);
include('..\libs\Smarty.class.php');
?...
Hi. I have a a login in script that is a little to complicated for my own good. I have a php file that calls a javascript based on the $_GET variable. The javascript/jquery makes html that uses iframe to call another php file, but I need the $_GET variable in that php code or I need to pass the $_GET variables to the other php file withi...
I'm trying to share the same variable between two .cpp files, they include the same .h file.
But I'm getting linking errors, telling me that I have multiple definitions. Which I find awkward, since I'm using include guards
//main.cpp
#include <cstdio>
#include "shared.h"
int main(){
shared_int = 5;
printVal();
return 0;
}
//sh...
I am relatively new to Objective C/iPhone Development.
I am developing a simple app with two views using a Navigation controller.
The first view contains several buttons a and the second view contains a uiwebview.
The idea is that when a button is pressed it switches to the second view and the web view loads a local html file. Which h...