scope

What kind of localization does occur in a "foreach" loop ?

UPD: I updated the question with more details. In this example: my $x = 1; for $x (2..3) { } print $x; # 1 $x is localized to the loop. man perlsyn says that "... If the variable was previously declared with "my", it uses that variable instead of the global one, but it's still localized to the loop." But the variables are not th...

javascript webkitTransform style attributes not setting - scope?

Hi, I'm trying to set the webkitTransform style attribute, but it's not setting for some reason. But there are other attributes that are successfully being set to the div. This doesn't work: var cell = document.createElement("div"); var canvas = document.createElement("img"); cell.className = "baz"; cell.appendChild(canvas); cell.st...

PHP Foreach array as a error in function (invalid argument for foreach in...)

Im working on a new minimal Project, but i've got an error, i dont know why. Normally, i use arrays after i first created them with $array = array(); but in this case i create it without this code, heres an example full code, which outputs the error: <?php $i = array('demo', 'demo'); $array['demo/demodemo'] = $i; ?> <?php $i = array('...

Scope of a delegate in C#

Hi folks, can delegates be private, if not what's the reason behind this other than the normal restrictions caused by it being private. TIA ...

Referring to const value @ compile time - when is a const's definition really available?

I tried const int i[] = { 1, 2, 3, 4 }; float f[i[3]]; // g++ cries "error: array bound is not an integer constant" int main() { const int j[] = { 0, 1, 2, 3 }; float g[j[3]]; // compiler is happy :) return 0; } What is the difference between the two aggregates? How come referring to a const aggregate's e...

[C#] How to access locals through stack trace? (Mimicking dynamic scope)

Background Even though it's possible to compile C# code at runtime, it's impossible to include and run the generated code in the current scope. Instead all variables have to be passed as explicit parameters. Compared with dynamic programming languages like Python, one could never truly replicate the complete behaviour of eval (as in th...

F# Checked Arithmetics Scope

F# allows to use checked arithmetics by opening Checked module, which redefines standard operators to be checked operators, for example: open Checked let x = 1 + System.Int32.MaxValue // overflow will result arithmetic overflow exception. But what if I want to use checked arithmetics in some small scope, like C# allows with keyword c...

Javascript outer scope variable access

OperationSelector = function(selectElement) { this.selectElement = selectElement; } OperationSelector.prototype.populateSelectWithData = function(xmlData) { $(xmlData).find('operation').each(function() { var operation = $(this); selectElement.append('<option>' + operation.attr("title") + '</option>'); ...

How to pull data and export to excel within an ajax framework.

Hi, I have a very specific problem and i'm looking for input on a good way to approach it. edit:(simplified question) Essentially I have been working on a remote monitoring system for retail kiosks. I am operating within a framework that is entirely dependent on AJAX. I have been using XML to pass data between the clientside/serve...

Send complex sets of data to php from javascript without ajax

How can javascript pass data, for example from an HTML table, without using AJAX? I am lacking the understanding of how to actually pull data, format (into json likely), and pass it. I am trying to pass data to a php function that sends a file to the user to download. (something ajax can't handle as I understand it) EDIT - please give...

How to get a pointer out of scope

This is not exactly my code but it looks a lot like it I have 2 tables of type CTable. They work in the same way as normal arrays but can be allocated dynamically and resized. So lets just pretend that they are arrays right now One table has object references MyObj obj1; MyObj obj2; MyObj table1[10]; table1[0] = obj1; table1[1] = obj...

Creating a function from string which inherits the parent scope

In Javascript, is there a way to create a function from a string (such as through the new Function() constructor) and have it inherit the parent scope? For example: (function(){ function yay(){ } var blah = "super yay" yay.prototype.testy = new Function("alert(blah)") yay.prototype.hello = function(){alert(blah)} ...

TransactionScope With Files In C#

I've been using TransactionScope to work with the database and it feels nice. What I'm looking for is the following: using(var scope=new TransactionScope()) { // Do something with a few files... scope.Complete(); } but obviously this doesn't work -- if there are 20 files, and an exception occurs on the 9th file,...

In jQuery, how do you resolve the scope of "this", when you are in the scope of each()?

I've created an Object, and have a method setup() in the object. this.debug = function (){...} this.setup = function(){ var fieldsets = form.children("fieldset"); fieldsets.each(function(){ this.debug($(this).attr("class"))); }); } I'm trying to call this.debug which is in the scope of the Object but not in...

how to have global variables among different modules in Python

hello, I investigated that scope of global variables in python is limited to the module. But I need the scope to be global among different modules. Is there such a thing? I played around __builtin__ but no luck. thanks in advance! ...

Why do un-named C++ objects destruct before the scope block ends?

The following code prints one,two,three. Is that desired and true for all C++ compilers? class Foo { const char* m_name; public: Foo(const char* name) : m_name(name) {} ~Foo() { printf("%s\n", m_name); } }; void main() { Foo foo("three"); Foo("one"); // un-named object printf("two\n"); } ...

Are ASP.NET Cache values scoped equally or more narrowly than a static variable?

In order to synchronise access to a Dictionary object in the ASP.NET cache, it is recommended that a synchroniser object be used. Dino Esposito recommends a static variable as the target for locking (See http://www.drdobbs.com/cpp/184406369). However, this will only work if the ASP.NET Cache values have the same scope (or narrower scope...

How do I access UIImageViews that have gone outof scope and that shares the same name as multiple others

I have a for loop that creates multiple UIImageViews that I add to self.view I do this in my custom init method. - (id)init { if ( self = [super init] ) { for ( int i = o; i < [count]; i++ ) { //count is a variable I am using (typicly 3) UIImageView *tmpImageView = [[UIImageView alloc] initWithImage[data getImage]]; ...

Assigning scope amongst jQuery.getJSON and a JS.Class

I'm trying to assign some JSON data to a property of a JS.Class instance. var MyClass = new JS.Class({ initialize: function(uuid) { this.uuid = uuid; }, write: function() { $.getJSON(url+"?callback=?", {}, function(data) { Assign(data); }); function Assign(data) { this.content = data; }; } }); var m = ne...

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...