Menu
  • HOME
  • TAGS

Calling jquery function with javascript

javascript,jquery,function,global

Because of the way jQuery works. This error is predictable. What is happening, is the declaration of fxn is waiting until the document is actually ready. Where the call to this method is not. So, by attempting this you are in essence trying to call a function that doesn't yet...

Storing this object in custom private variable

javascript,jquery,this,global

I would follow along the lines of Mike's recommendation, but go the full Module pattern route. This will allow you to have "private" functions as well in the event that you want to collect any common functionality. With this solution, I don't see a need for the self variable, unless...

Why is 'event' available globally in Chrome but not FF?

javascript,jquery,javascript-events,event-handling,global

In IE, the event object was a global object, (which is not passed to the handler function) but accessed as a global object. You can also access it as a property of the window object like window.event In in FF and other browsers the event object was passed as an...

Patterns for avoiding name-space pollution

javascript,design-patterns,namespaces,global

There is no commonly accepted best way. Sorry. As Pointy said, your method involves creating the MyObj constructor function, which presumably will never be used again, as well as the myApp namespace object. It has at least one other minor disadvantage: you can't prevent yourself or someone else using the...

How can i define a global variable Class in Swift

class,swift,variables,global

You can us something like this: class Favorites { var favoritesArray:Array <AnyObject> init(favoritesArray:Array <AnyObject>) { self.favoritesArray = favoritesArray } } and declare it as : var favoritesInstance = Favorites(favoritesArray:["Harpers_Bazaar_Ch_03_15_0000.jpg"]) and call it from anywhere as : let x = favoritesInstance.favoritesArray ...

Can't get functions to work properly

function,global,autohotkey

Sorry to say but you are using the % in way too many places Its use depends on where you are using the variable if it in an expression you do not use % around variables, in most other places you do, next thing is then to know when you're...

Defining Global Arrays in C

c,arrays,global

I think, you missed to define the array. IMO, what you want is byte GlobalAr[10] = {0}; GlobalAr[0] = 0b00001111; GlobalAr[1] = 0b00001010; and so on. Otherwise, as per your code extern byte GlobalAr[10]; and byte GlobalAr[0] = 0b00001111; you're trying to redefine the GlobalAr array with a different size[10...

How do I declare a global variable in python? [closed]

python,variables,undefined,global

FTFY #!/usr/bin/python def travel(): travel.totrate=0 def guide(): print"Due to prefer a guide??" print"a guide inperson...rate=1000" print"maps,3g....rate=2000" ch6=raw_input("ENter your choice") if(ch6=="person") or (ch6=="PERSON"): increment = 1000 elif(ch6=="gadget" or ch6=="GADGET"): increment = 2000 else: print "invalid" travel.totrate += increment print travel.totrate guide() travel() You really don't need a global variable at all....

trouble using printwriter from another class

java,class,sockets,global,printwriter

I think this is giving you the NullPointerException ChatPanel.pw.println(ChatPanel.name + " has disconnected from the chat."); because ChatPanel.pw has never been initialized in your code, and therefore is null You should ensure that ChatPanel.pw has been initialized somewhere (maybe within the constructor) inside your ChatPanel class before calling the ChatPanel.pw.println()...

Passing Variable through Javascipt from one html page to another page

javascript,html,variables,undefined,global

Without reading your code but just your scenario, I would solve by using localStorage. Here's an example, I'll use prompt() for short. On page1: window.onload = function() { var getInput = prompt("Hey type something here: "); localStorage.setItem("storageName",getInput); } On page2: window.onload = alert(localStorage.getItem("storageName")); You can also use cookies but localStorage...

How can i use other function variables?

javascript,global

To use a in genTable, either Give genTable a parameter and invoke with it from colNum // in function colNum genTable(a); // a refers to the variable named a // ... function genTable(a) { // a refers to the parameter named a } var a; in a closure that contains...

Python module reusing the same object

python,global

This is simple enough, don't declare your list outside of the function. Move node_list = [] into your function definition: def scan(ipnet, port): node_list = [] for x in range(1,255): ip = '{0}.{1}'.format(ipnet, x) t = Thread(target=probe, args=(ip, port)) t.start() return node_list Essentially, you want to read up a little...

global and local variable execution context in javascript

javascript,variables,global,local

Because when you do foo = 7; it makes a global variable and sets it to 7, even after the function is done it's still 7. You probably want it to be a local variable: (function Test() { var foo = 7; console.log("foo=" + foo); })(); ...

Creating global array of objects (java)

java,arrays,object,global

There are multiple issues You cannot have arbitrary code in the body of your class, e.g. the WEAPONS[0] = calls. However, you can initialize the array directly using new Type[]{} syntax. You could also use a static initializer static {} but this is not recommended. Also, you need to use...

C global function (not C++)

c,function,function-pointers,global

Declaration, usually in a .h file but also possible to just copy-paste to a .c file directly (for quick & dirty testing etc, for any real code you should write a proper .h file). Duplicates in same compilation unit are are ok as long as they match. You can use...

R scoping: disallow global variables in function

r,scope,global

My other answer is more about what approach you can take inside your function. Now I'll provide some insight on what to do once your function is defined. To ensure that your function is not using global variables when it shouldn't be, use the codetools package. library(codetools) sUm <- 10...

Argument grouping in bash scripts

bash,function,arguments,global

You can use quotes to prevent this. Examples : test() { for i in "[email protected]" do echo "$i" done } test "[email protected]" Output : $ ./test.sh foo "bar baz" foo bar baz Without quotes : test() { for i in [email protected] # no quotes do echo "$i" done } test...

jQuery | Using globals variables in this small snippet

jquery,variables,global

Just wrap everything in a function: function resizeSidebar() { var pageWidth = $('#page').width(), pageWidthFifth = pageWidth / 5, wrapAndSidebar = $('#sidebar-wrap, #sidebar'); wrapAndSidebar.width(pageWidthFifth); } resizeSidebar(); $( window ).resize( function() { resizeSidebar(); } ); Please note I haven't tested this code in the browser, but it's pretty much what you must...

global variable in octave

global,octave

You have to declare the var also global inside the function as described here: https://www.gnu.org/software/octave/doc/interpreter/Global-Variables.html global m = 1; function p = h() global m; m endfunction h() ...

Global character array won't be reassigned or outputted correctly

c++,arrays,char,global

You cannot reassign an array like: board[3][3] = { { '1', '2', '3' }, { '4', '5', '6' }, { '7', '8', '9' } }; Since you never use board before you try to assign values to it in main() just replace char board[3][3] = { { ' ', '...

Location of Including PHP File Affects Global Variable Scope

php,xampp,global

This is because in the second case, functions.php is looking to include config.php from within the current path which is /api/. Also, why the global $database declaration if you are going to be calling getDatabase() anyway?...

Global object declared in function not accessible by other functions

javascript,canvas,scope,global

I assume the list line is draw();. You are seeing this error because you are calling update(); and draw() before init() is called and set map. Solution: Ensure that update and draw are called after init has been called. For example, by placing the calls inside the load event handler....

how to grab unser inputed data from one function and use in another python

python,function,variables,global

You could solve this problem using global variables: see here. However, it's a better practice in Python to use classes, and keep functions that share variables, along with the variables they share, in a particular class. In your code, that would look something like this: class MediumHandler(object): def __init__(self): self.hydro...

Static member/ methods and Global scope [closed]

java,jvm,global,static-methods

Static methods (in fact all methods) are stored in the PermGen/metaspace and static fields are stored in a special object for each class on the heap, since they are part of the reflection data (class related data, not instance related). If your static variable is a reference to an object...

iOS using xib + global methods for overlay UIView (Swift)

ios,swift,global,xib

I have set up a custom class (subclass of UIView) to link a xib file No, you haven't. No such "link" is possible. what am I missing? You're not missing anything, because you've already figured it out! Merely creating a LaunchCustomScreen instance out of thin air (i.e. by saying...

Drools marshall/unmarshall not save global

marshalling,global,drools,unmarshalling,kie

Globals are not inserted into the Working Memory, consequently they are not saved with the KieSession's state. Globals have to be inserted every time you restore KieSession's state....

PHP global config files

php,config,global

global is evil, please don't use it. I'd use constants for the database parameters: define('DB_NAME', 'MyDatabase'); define('DB_USER', 'root'); define('DB_PASSWORD', '1234'); Then, use require instead of include for your config.php. Your application should not proceed without it....

preg_replace_callback store match in global array and replace

php,arrays,global,preg-replace-callback

Ok, at the beginning: global $idarray; $idarray=array(); ...

Combine two POSTs using global variables

php,post,scope,submit,global

I think you have to look at the life-span of the script When the user hits First button: Form submitted script runs (sets your variable) script terminates (as does all things related) Second button: Form submitted script runs (does not set second variable) script terminates (as does all things related)...

Declaring global inside a function

python,python-3.x,global

It tells the compiler that binding the name should be performed in the module scope rather than the local scope. It has no use if you're simply mutating the object (e.g. fruits.append('apple')).

tkinter entry variable from function

python,tkinter,global,entry

Does this solve the problem? def show_entry_fields(): global site, score, master site = e1.get() score = e2.get() master.destroy() At least the print at the end of the program is printing the right answer....

Azure Active Directory disable while developing localhost

asp.net-mvc,azure,active-directory,global

This solution is not very general, but might be just want you want if you are deploying to Azure Web Sites. You can ask Azure Web Sites to enforce authentication with an AAD before allowing users to reach your site. Basically, you can develop locally WITHOUT any AAD in your...

Android simple method to create and use global variables?

java,android,variables,global

You can use the singleton design pattern to make a new class that stores all the data you wish to keep across all your activities. http://en.wikipedia.org/wiki/Singleton_pattern Essentially you create a class that only contains a get method. The method creates an instance of an object if there is none or...

Having multiple threads perform actions based on a global variable

python,multithreading,variables,global

You are never changing the global variable output. The variable output in ColorRandomizer.run is a local variable that shadows the global. Insert the line global output a the top of the run function of Color_Randomizer. Remove the return output statement in Color_Randomizer(). Your time.sleep call in the next line is...

Avoiding global context in jQuery used on all pages of a CMS

javascript,jquery,function,global,encapsulation

$(function() { is just a shortcut to $(document).ready(function() {. In both cases you are inside a function, so as long as you use the var when assigning variables they won't pollute the global scope. Note that you can use multiple ready handlers with no problem....

How can I edit the array elements?

c,arrays,global-variables,global

#include<stdio.h> #include<conio.h> int sudoku[10][10]; main() { int i,j,n; clrscr(); printf("enter the array size\n"); scanf("%d",&n); printf("enter the values into an array\n"); for(i=0;i<n;i++) { for(j=0;j<n;j++) { scanf("%d",&sudoku[i][j]); } } arr(sudoku,n); getch(); } void arr(int sudoku[10[10],int n) { printf("array content are as follows\n"); for(i=0;i<n;i++) { for(j=0;j<n;j++) { printf("%d",sudoku[i][j]); } printf("\n"); } } ...

Global variable not changing in main C++

c++,variables,global

void read_control() { double P, T; ifstream file; string u = "useless data"; file.open("control.inp"); file>> u >> u >> P >> T; file.close(); cout << "Read_control says T = " << T << endl; } The variable T declared here is a local variable for this function and its scope...

Python “global” keyword doesn't work with “from … import …”

python,global

Globals are not shared between modules. Your test2 namespace got its own indepdendent reference to the 1 value a references in the other module. Setting a in test1 then rebinds the test.a name to a new object (the 2 integer value), but the test2.a reference is not going to be...

Referencing global primitives vs. objects

python,pointers,global

As Ffisegydd points out, there is no such thing as a primitive in Python: everything is an object. You should however note that you are doing two completely different things in those two snippets. In the first, you are rebinding x to the value of x+1. By attempting to assign...

Python import modules in another file

python,python-2.7,global,python-import,python-module

Yeah I guess there is a more elegant way of doing this which will save redundant line of code. Suppose you want to import some modules math, time, numpy(say), then you can create a file importing_modules(say) and import the various modules as from module_name import *, So the importing_modules.py may...

Javascript global module or global variable

javascript,module,global

Let's simplify: ;(function(root) { ... }(this)); So, we have a function that takes an argument called root. This function is being immediately invoked (http://benalman.com/news/2010/11/immediately-invoked-function-expression/), and we are passing the value this to it. In this context, this is your global object. If you are using a browser, your global object...

Setting global variables and wrap in $(window).load

javascript,variables,global

Declare globally: var sidebarHeight, sidebarOffset; Set locally: $(window).on('load', function(){ sidebarHeight = $('.sidebar').height(); sidebarOffset = $('.sidebar').offset().top; }); They won't have a value between their declaration and setting them, so other code which uses them may need to account for that. But if you need them to be in global scope then...

Global variable is out of scope! What the heck?

c++,scope,global,sfml

You never call loadGraphics. Call that at the start of main, and your program will probably work. But you'd almost certainly be better off without globals; and in any case, you don't want to define them in a header since that will break the One Definition Rule if you include...

Updating the global integer variable

global,drools

You can change the value of the object reference stored in a DRL global only by using the API: then //... kcontext.getKieRuntime().setGlobal( "deviceCapacity", $snrData.getDeviceCapacity() ); end Clearly, this is ugly and not checked at compile time. You might consider writing a wrapper class IntWrapper { private int value; // getter,...

Convert local coordinates to scene coordinates in SceneKit

global,local,scenekit,coordinate

SCNNode exposes the following methods to convert between coordinate spaces: -convertPosition:fromNode: -convertPosition:toNode: -convertTransform:fromNode: -convertTransform:toNode: ...

Global variable becoming undefined from within event listener - javascript

javascript,global,addeventlistener

Something similar to item 8 in this post is going on I suspect: What is the scope of variables in JavaScript?...

Global variables have nil value, attempt to call global (a nil value) in Corona

lua,corona,global,nil,value

currently your textlistenerlocation function is not being called. So when you hit the submit button, locationGlobal has not yet been defined. The following looks suspicious: locationTxtbox:addEventListener("textListenerLocation",locationTxtbox) the addEventListener should take an event string and then a function to call when the event happens. textListenerLocation is your event handling function, it...

Is it possible to alter or delete properties of the global object in Javascript?

javascript,global

It depends - is the property writable/configurable or not? Infinity is neither, as exposed by the following console log: > Object.getOwnPropertyDescriptor(window,'Infinity') < Object {value: Infinity, writable: false, enumerable: false, configurable: false} However, other global properties, such as frames, are configurable: > Object.getOwnPropertyDescriptor(window,'frames') < Object {value: Window, writable: true, enumerable: true,...

php get variables from inside a function when outside

php,jquery,wordpress,global,shortcode

You have to echo variables for them to output columnWidth: <?php echo $masonry_item_width ?>, gutter: <?php echo $masonry_item_padding ?>, As to how to get your values... Wordpress makes plugins such a mess with all these standalone callbacks. Normally I would abhor doing this but I can't think of any other...

python : variables in a list and outside a list

python,list,global

A possible work around for this problem is something simple like this: def get_my_list(): return [var1, var2] var1 = False var2 = False print get_my_list() >>> [False, False] var1 = True print get_my_list() >>> [True, False] Then you just use get_my_list() in place of where you had the list before....

Tcl $argc and $argv variables

variables,tcl,global,argv,argc

You appear to make two wrong assumptions here: If a proc does not use a special argument args in its defintion (see below for more info), it accepts only the fixed number of arguments—exactly matching the number of parameters used in its definition. Each call is checked by the interpreter,...

Python: access variable in a function in another file

python,variables,import,global,local

I recommend the following: lib.py def test(): return "Hello!" test.py from lib import * var = test() print(var) ...

Global variable from included file in static function

php,global

Because the way the file $lang.php is included, the variable $translation lands as a local variable in a function and not as a global variable as method Strings::translate() expects it. After we discussed in chat and I understood the problem, I can suggest two solutions: Solution 1 (the quick workaround)...

Syntax and missing type specifier errors at global array initialization in C++ [closed]

c++,arrays,global

You are missing the namespace: You can add the following at the beginning of your file after your includes (note that in a more complex scenario this could be a problem. see here) using namespace std; or you can specify the namespace each time you are using string: std::string...

How can I define global variables inside a twig template file?

php,variables,twig,global,templating

Using Symfony2 configuration If you are using Symfony2, you can set globals in your config.yml file: # app/config/config.yml twig: # ... globals: myStuff: %someParam% And then use {{ myStuff }} anywhere in your application. Using Twig_Environment::addGlobal If you are using Twig in another project, you can set your globals directly...

Difference between static and const variables [duplicate]

c#,variables,static,const,global

const and readonly perform a similar function on data members, but they have a few important differences. A constant member is defined at compile time and cannot be changed at runtime. Constants are declared as a field, using the const keyword and must be initialized as they are declared. The...

Best practices for weaning myself off of globals?

python-3.x,global-variables,global

It depends on the purpose of that Settings object. If you're doing it for your personal convenience to pass data around then that's the wrong reason. But if your application as various configuration settings / flags that are needed in various places then passing a Settings object around it a...

variable global const “macros” in C++ and optimal design patterns

c++,design-patterns,mfc,const,global

Your inheritance tree essentially defines two different values for the base struct. You don't need inheritance just to define those values, you only need two variables: struct eOfficeExtensions{ const CString WORD_EXTENSION; const CString EXCEL_EXTENSION; const CString WORDPAD_EXTENSION; const INT EXTENSION2007; }; const eOfficeExtensions extensions2003{_T(".doc"), _T(".xls"), _T(".rtf"), 0}; const eOfficeExtensions extensions2007{_T(".docx"),...

Beginner tips needed for storing user information across all Angular controllers

angularjs,authentication,user,global

So actually you want to encapsulate a third party service to reduce your dependency on a third party library. Your third party library provides a service $localStorage with some properties you want to access. Here is one way to do so: function YourAuthService($localStorage) { this.isAuthenticated = function () { return...

why is my javascript function not applying changes to my global variables?

javascript,arrays,function,variables,global

Of course it would help if you paste more of your code, but first try to change the variable name "values". Edit: I checked your code and screenshot and even tried your code and the output came as expected. It seems you are working on Google Chrome, did you try...

What is the best way to pass lots of constants and workspace variables to an fsolve objective function?

performance,matlab,function,variables,global

Here is a simplified example of how I would go about solving this: function y = example % a1 = -2; a2 = -1; save('example_constants.mat') constants = load('example_constants.mat'); y = fsolve(@(x) myfun(x, constants), [-5;-5]); end function F = myfun(x, c) F = [ 2 * x(1) - x(2) - exp(c.a1...

Ruby on Rails - Source a file and save ENV variable as global

ruby-on-rails,constants,global,env

The above won't work because the backtick command starts its own shell and ends it so those variables are never included in the rest of your script. I think you'll have to parse the file yourself and add the entries to ENV. I would look at the dotenv gem and...

global variable returns null when sent to list

php,variables,null,return,global

I would check the actual value of $_SESSION['action'], as well as separately echoing out (or var_dump) other variables such as $emp_name for testing / ensuring they are actually populated as you expect. As Jay Blanchard mentioned, using $_SESSION['someVar'] is better than using the global keyword. Found some good info here:...

declaring global perl subroutines or global aliases

perl,oop,object,global

You can add throw to the UNIVERSAL package (which isn't a good practice). Note that your throw ignores the message and displays just the class name. #!/usr/bin/perl use warnings; use strict; { package UNIVERSAL; sub throw { die shift } } { package MyClass; sub new { bless {}, shift...

Concrete5 Enabling Bootstrap Grid in a Global Area

twitter-bootstrap,grid,global,area,concrete5

Why not enable bootstrap grids in the template/page type and then add the global areas that you want? Or alternatively create any global area and then add HTML which sets up the bootstrap for you? As so: <div class="row"> <div class="col-md-8 col-xs-12"> <div id="divExampleContent"> <h1 class="decorated"><span>Example1</span></h1> <?php $a = new...

Why is it faster to allocate memory in the heap for a local array compared to a global array?

c++,memory-management,global,local

Since the first test run is slower, no matter which it is, then probably the OS takes longer to allocate 4GB and then map it to writable memory on the first pass through. In extremis, it might need to save other things out to swapfile to make RAM available the...

Confused about protractor v1.4.0 'protractor' and 'browser' global variables

variables,global,protractor,definition

1) There are 3 important keywords: element, browser, and protractor. element is how you select content on the page, browser is how you interact with the browser that you're testing (i.e. browser.get(...)), protractor is a shortcut for you to access static variables defined in the webdriver namespace. For example: browser.get('http://www.someUrl.com');...

Do I need a global variable or better OO design in this rails application?

ruby-on-rails,ruby,variables,design,global

Rather than passing a @discogs variable around your application, you can create a global object in an initializer like so: config/initializers/discogs.rb DiscogsWrapper = Discogs::Wrapper.new("My awesome web app") Now you can refer to the DiscogsWrapper object in other parts of your application. Example 1: module Artists def self.search(name, wrapper = DiscogsWrapper)...

How to make Window var global

c#,global,partial-classes

Ok, so I found the easiest way to do this is to use this class: static class MBW { public static ProjectName.MessageBoxWindow MessageBox_Window = System.Windows.Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MessageBoxWindow) as MessageBoxWindow; } Then just use: MBW.MessageBox_Window to access everything inside that window without having to copy out the long code...

Is storing query selectors globally always bad practice?

javascript,jquery,jquery-selectors,global

Most of the time you can avoid polluting the global name space by wrapping your code in an immediately executed function expression: (function() { // declare variables here var $_element_1 = ...; // use them here function animate_1() { ... } // register event handlers ... })(); // invoke the...

PHP global variable is not changing [duplicate]

php,variables,global

Your solution could look like this: <?php require_once("rpcl/rpcl.inc.php"); //Includes use_unit("forms.inc.php"); use_unit("extctrls.inc.php"); use_unit("stdctrls.inc.php"); //Class definition class Page1 extends Page { public $Label8 = null; private $someVar; public function __construct($application) { parent::__construct($application); //load from storage $this->someVar = $_SESSION['someVar']; $this->Label8->Caption = $this->someVar; } public function __destruct() { //save to storage $_SESSION['someVar'] = $this->someVar;...

Certain Javascript works on single pages, but not when loaded globally via a Drupal theme's javascript

javascript,jquery,drupal-7,global

The solution was simply to put every single "script" in a seperate .js-file. If they were put into one .js-file, they would simply all become dysfunctional. Anyone knows whether this is a Drupal-specific strategy, or whether this is general to Javascript and known to everyone in "the field"?...

How to share an instance created in main with a class in another module

python,class,share,instance,global

* Main module ***************** import matplotlib as plt import plotter import shapes def main(): global thePlot thePlot = plotter.plotter() cyl = shapes.cylinder(r, c, n, color) cyl.draw() plt.show() And this: global thePlot * This line causes the error thePlot.plot(self.x, self.y, self.z, self.color) Should become: main.thePlot.plot(self.x, self.y, self.z, self.color) With the condition...

can't get the global variable to work on a function

php,forms,function,variables,global

declare your global variables inside your function function get_instance(){ global $d , $e ; $d = $_POST['a']; $e = $_POST['b']; } ...

In Python I get an error that a global variable is not found, but in codeskupltor - the code works fine

python,global

The problem is in your last four lines of code -- frame.start() doesn't quit until your game is finished, but you have new_game() after that, so the globals are never initialized.

Assign a value to all variables that start with certain string

javascript,variables,find,global,assign

You want to modify window[i] (the value of variable i), not i (the variable name). So you can do something like this: for (var i in window) { if (i.indexOf('variableName') == 0){ window[i] = true; } } ...

Use Commands from argv to Initialize a Global Mutex

pthreads,global-variables,global,mutex,argv

You can use dynamic allocation, just like you would for any other type. The only difference here is that dynamically allocated mutexes must be initialised with pthread_mutex_init(): pthread_mutex_t *mutex; size_t n_mutex; int main (int argc, char **argv) { size_t i; if (argc < 2) return 1; n_mutex = atoi(argv[1]); if...

Passing variables around a GUI (using globals)?

python,user-interface,global

I recommend looking at this site. The way this example is set up, the tkinter app is a class. Your load_files() and run_process() functions will be functions of the class, and instead of using global variable (stay away from globals in python!), the variables will be class properties. Unfortunately this...

Backbone Global Variable

javascript,variables,backbone.js,global

I want to mention that Global variables are bad. Try to limit yourself to as few of them as possible. Global namespace pollution is very dangerous and can cause unexpected errors in the future. A technique I often use to get around the issue of polluting the global namespace is...

Why is globals() a function in Python?

python,global

Because it may depend on the Python implementation how much work it is to build that dictionary. In CPython, globals are kept in just another mapping, and calling the globals() function returns a reference to that mapping. But other Python implementations are free to create a separate dictionary for the...

I cannot get the restart button to work on my stopwatch. Using Pythonista on iPhone

python,iphone,user-interface,uibutton,global

By default, when you assign to an identifier for the first time in a function it creates a local variable, even if there's a global one with the same name. Try this: def restart_time(sender): global start start = int(time()) button2 = str("Stopwatch restarted.") sender.title = None sender.title = str(button2) From...

C: Passing variables between files

c,scope,global

Ciro's solution would have worked if I am only using func1 once; however func1 is called recursively so variable a cannot be global in file1 (i.e. the variable has to live on the stack and not on the heap). Here's the solution I ended up using: File1.c: #include <something.h> extern...

Angularjs reload value in factory

global,value

I've resolved my problem. I am not sure what I was doing wrong but now it works. For everyone who will have similar problem, don't forget to inject your values or constans to factory.

How can I change the value stored in local macro from string to numeric in Stata?

types,macros,global,local,stata

If you add =, then Stata will evaluate the expression that defines local date: clear set more off set obs 10 gen y_passed = _n local date = substr("$S_DATE",8,.) display `date' gen start_year = `date' - y_passed list Otherwise, the local just holds a string, but not a number in...

Global name error in python program [closed]

python,button,tkinter,global

In the start method, you're referring to a variable called eth_addr, which isn't defined anywhere. It's also exactly what your error message is telling you. (you're probably looking for self.eth_addr) (in addition, stop using start_new_thread -- it's a low-level primitive that should never be called directly. Use threading.Thread objects instead.)...

How are global functions defined in Swift?

function,swift,global

Unless you declare the function as private, which limits the visibility to the file where it is defined, you can use it anywhere in the module if declared as internal (the default), and also from external modules if declared as public. However since you say that you need it in...

Is it possible to use common fragment generate function globally?

java,android,android-fragments,global

You could just pass the fragment manager into the method: public static void generateFragment(FragmentManager fragmentManager, String speechString, String buttonString) I would avoid having a BaseActivity as others have suggested, because it limits you to what you can extend from: e.g. FragmentActivity, ActionBarActivity, ListActivity, PreferenceActivity, e.t.c. Google "composition over inheritance" to...

Global Variable - AJAX jQuery

javascript,jquery,ajax,variables,global

In JavaScript, a variable which has been declared without var keyword inside a function becomes global only after function's call. Consider this: function foo(){ bar = 123; } // Reference error - bar is undefined console.log(bar); Now before testing bar variable, let's call the foo function. function foo(){ bar =...

Global scope inside if/else for a running median

python,variables,if-statement,global,scoping

Has nothing to do with scope. The heaps don't grow because you pop newly added elements right off at the end: return (heapq.heappop(leftHeap) + curMedian)/2 else: return (heapq.heappop(rightHeap) + curMedian)/2 Just look at the max/min element without popping it off: return (leftHeap[0] + curMedian)/2 else: return (rightHeap[0] + curMedian)/2 My...

How should a global (module) object be created in a Python function?

python,url,import,global,local

Also a thing to consider: Perhaps, just return a module and use it where needed? # hello.py def world(): print 'hello world!' # smuggle.py def smuggle(url, name): code = urllib.urlopen(url).read() module = imp.new_module(name) exec code in module.__dict__ return module hello = smuggle("http://127.0.0.1:1234/hello.py", "hello") hello.world() # prints out "hello world!" You...

Implementing Universal search in rails 4

ruby-on-rails,ruby,search,global

I think the best way in your case is to use ElasticSearch. A neat integration gem is provided here. Links to documentation are provided on that page.