scope

javascript: recursive anonymous function?

Lets say I have a basic recursive function: function recur(data) { data = data+1; var nothing = function() { recur(data); } nothing(); } How could I do this if I have an anonymous function such as... (function(data){ data = data+1; var nothing = function() { //Something here that calls the func...

What is the lifecycle of a HttpServlet?

Hi all, Basically, how long is an instance of a servlet around for? I am kind of guessing it is session scope. However, I suppose it could have some sort of timeout or garbage collection to remove old instances. Thanks, Grae ...

javascript: can not use global variable in a function, to navigate the dom

hello, beginner here... what am i missing? i define a global variable that is a reference to an html element: var x=document.getElementById("xxx1"); then, inside a function a try to reference that variable to navigate the dom: x.innerHTML="dsfgfdgdf"; ...doesn't work; if i define the variable inside the function ...

How do I generate memoized recursive functions in Clojure?

I'm trying to write a function that returns a memoized recursive function in Clojure, but I'm having trouble making the recursive function see its own memoized bindings. Is this because there is no var created? Also, why can't I use memoize on the local binding created with let? This slightly unusual Fibonacci sequence maker that starts...

javascript/jquery scope has me stumped

I have wrapped a common ajax call into a function. It pings a script, returns JSON. However for the life of me I can't seem to be able to have the JSON object be the return value of the function. Must be something fairly simple I am missing, bu for the life of me can't work it out. function queryCostCenter(user_id, currency_id, countr...

javascript function not calling possibly due to scope issue

I am looking to call my clear() JS function to clear the text values in some input fields on my webpage, but for some reason, the function doesn't appear to be called correctly. I believe this may be a scope issue, but I'm not sure. Here is my markup, script and styling kept together for ease-of-use currently, but will be mended once s...

VB .Net 2008 - List all objects currently in scope?

Hi Guys, Please can any one advise me if there is an object in .net that can be used to get a list or references to all objects that are currently in scope for an object. For example if the code is currently executing in a method, what objects declared in this method are currently instanciated and alive and what objects that are decla...

Event Handler access context JavaScript

I have a question in JavaScript context. I'm a little confused by this issue. The code below describes my question: $(..).someFunction{ var outOfScope = "OUT OF SCOPE!"; $('somelink').click(handler); function handler() { alert(outOfScope); } } My question is: how outOfScope variable (which was defined outside the handler...

Reverting the 'global <var>' statement

Hello everyone! I am learning Python and just had this question. It possibly has no practical worth, I'm asking this out maybe because of a pedantic curiosity. I have a function: def f(): x = 12 #this is a local variable global x #this is a global I declared before x = 14 #changes global x <How can I return the...

typedef templates in global scope

using template classes I usually make some typedefs like: typedef super<puper<complex<template<type> > > > simple_name I usually do it in 2 ways: template <class A, ...> struct Types { typedef ... } template <class A, ...> class Part_Of_Logick { public: typedef ... } Is it possible to set typedefs at the global sco...

Ruby variable scoping is killing me

I have a parser that reads files. Inside a file, you can declare a filename and the parser will go and read that one, then when it is done, pick up right where it left off and continue. This can happen as many levels deep as you want. Sounds pretty easy so far. All I want to do is print out the file names and line numbers. I have a cl...

Scope of object within an object in Java

I'm learning Java at the moment so I hope this question isn't too obvious. I come from another language which does not have garbage collection. In this other language I sometimes created objects in constructor and then deleted them in the destructor so I could use them for the entire life of the object. As a simplified example, I have a...

Access problem in local class

void foobar(){ int local; static int value; class access{ void foo(){ local = 5; /* <-- Error here */ value = 10; } }bar; } void main(){ foobar(); } Why doesn't access to local inside foo() compile? OTOH I can easily access and modify the static variable v...

Is there anyway to initialize an object from an outer scope in an inner scope?

For example: int main() { { // I want this array to be part of the inner scope string s[] = {"Ben","Joe","Bob","Matt"}; // And I want to use it to initialize this vector, but I want this // vector to be visible in the outer scope vector<string> names(s,s+4); } } Is there any way to do t...

Drupal custom module object not accessible from GUI PHP tags

So I have created a custom module for Drupal 6.x and it works as I can see the desired results in the page.tpl.php page, but when I edit a page from the GUI (it allows php tags) the object is not accessible. I can set the values in a SESSION which I can access from the GUI as well as the module but is this the correct way to do this? H...

How to insert a click function inside of a plugin call?

Inside of fullCalendar(), a jQuery plugin, I can get the value of view.visStart. Outside of the function view.visStart is not available. How can I either get view.visStart out (and is this bad because it is Global?) or how do I insert a click function within the plugin call? thanks. $('#calendar').fullCalendar({ events: "js/events.j...

Ensuring a reference that will not become invalid is given

I'm making a TextField class, which at the moment stores a reference to a variable, and whenever the programmer wants, they can call TextField.show() and the referenced variable will be read and displayed on-screen. This however can result in problems if the reference becomes invalid. For example, if the variable referenced goes out of ...

Redefining :all

I have users in my system that can elect to 'hibernate', at which point they can remove themselves and all of their associated records entirely from the system. I have queries all over my site that search within the User table and its associated tables (separated by as many as 5 intermediate tables), and none explicitly test whether the ...

Javascript variable scope in event

I have this web application where users are able to fill out and submit reports. The reports and scripts are part of a whole system, that is, they are used on a couple of different clients written in both vb and c#. This is the web-version of those clients. The scripting language is javascript and is executed using different script engi...

Struct Scope Access

Hi this a continuation of a previous question I asked however I wasn't registered then and thus cannot edit the question. Anyways I have a struct typedef struct { char input[100][100]; int count; char name; int startTime; }INPUT; extern INPUT *global; this is within the header file. A stackoverflow member suggested that in my sou...