variable-scope

Passing Objects into PHP constructor error

Hello, Is it possible to pass an object into the constructor of a PHP class, and set that object as a global variable that can be used by the rest of the functions in the class? For example: class test { function __construct($arg1, $arg2, $arg3) { global $DB, $ode, $sel; $DB = arg1; $ode = arg2; $sel = $ar...

Heeelp! Debugger says "out of scope"!

I just cannot imagine what the hell the problem could be. I made a pretty app, and decided to use only CALayers to "render". When I saw that the changes in the position property gets animated, decided to implement a custom getter-setter "abstract" property called tanCenter to set the position without animating. -(void) setTanCenter: (C...

What's going on in the background with regard to this JavaScript?

I was reviewing some today, when I encountered the following convention : TestParam(1); function TestParam(p){ var p = p + 1; alert(p); // alerts '2' } Now, obviously, the developer didn't mean to delcare 'p' within the function, instead maybe meaning: p = p + 1; But the code still worked, i.e. the value alerted was...

Problem getting variables from Class and passing a reference of that Class

Hi everyone, once again I'm getting plagued by the dreaded Flash error: Cannot access a property or method. I'm building a new video player and I need to send the total width of my progress bar(created in PlayerControls.as) to my VideoPlayer.as class. As well as control the width of the progress bar from an update function inside my Vid...

Java, executing a method when object's scope ends

I've an object with a certain state. The object is passed around and it's state is temporarly altered. Something like: public void doSomething(MyObject obj) { obj.saveState(); obj.changeState(...); obj.use(); obj.loadState(); } In C++ it's possible to use the scope of an object to run some code when constructing and di...

Why do Variables that are local to a method cannot be declared final?

Hi I like to know why Variables that are local to a method cannot be declared final.. Is there any specific reason? Does it mean are there no local constants in java? ...

Sinatra Variable Scope

Take the following code: ### Dependencies require 'rubygems' require 'sinatra' require 'datamapper' ### Configuration config = YAML::load(File.read('config.yml')) name = config['config']['name'] description = config['config']['description'] username = config['config']['username'] password = config['config']['password'] theme = config[...

How can you dynamically load Javascript functions using Ajax?

(Rhetorical Question) I ran into a bizarre scenario today where I wanted PHP to update how the javascript behaved on-the-fly. It was irritating, here is what I tried... /* * ajax-php-javascript-function-loader.php * * this gets called by AJAX and defines or re-defines the * definition of dynamicDoStuff() */ <script type="text/ja...

is there a hash equivalent to a custom 'class variables'? (ruby)

I used hash of hashes to store settings in my code. I wonder if I can have something like class variable that is the same for all instances of the class for my @profile hash. So both profiles below would have general profile variable equal to both of them. I want the solution to use hash. @profile = { "vB4Discussions" => { #profile...

Changing value of ruby variables/references

Hi there, I just stumbled upon something i don't quite understand. I know that variables in ruby are references. So that awesome stuff is possible. But when i pass a variable to a method, it behaves strangely: my_var_a = "nothing happend to me" my_var_b = "nothing happend to me" def parse_set(my_var_set) my_var_set = "my value chang...

C# and Storing Data in Memory

I'm using Visual C#.NET, and am making an app that uses winforms. I essentially need to open multiple files as strings, and manipulate the data in various places without saving the information back to the file. How do I go about storing this data so that I may use it in various parts of my code? ...

Is this scoping possible in javascript?

I am working on a javascript framework. I have several independent scripts that look like this: core.modules.example_module = function(sandbox){ console.log('wot from constructor ==', wot); return{ init : function(){ console.log('wot from init ==', wot); } }; }; this function is called from another external scri...

C# and Variable Scope in Winforms

Within a Winform app, I would like data in an instantiated class to be accessible by multiple form controls. For example, if I create Class Foo, which has a string property of name, I'd like to instantiate Foo a = new a() by clicking Button1, and when I click Button2, I'd like to be able to MessageBox.Show(a.name). There may be multipl...

jquery ui dialog - button click event handlers

I'm a js noob. I'm using the jquery FullCalendar plugin which exposes an eventClick(calEvent, jsEvent, view) event which is called when you click on an event on the calendar. In my event handler I want to pop up a dialog asking if the user wants to edit just one occurrence of a recurring event or the whole event. The problem is that the ...

[C++] Mixing extern and const

Can I mix extern and const, as extern const? If yes, does the const qualifier impose it's reign only within the scope it's declared in or should it exactly match the declaration of the translational unit it's declared in? I.e. can I declare say extern const int i; even when the actual i is not a const and vice versa? ...

Strange behavior with Powershell scriptblock variable scope and modules, any suggestions?

NOTE: I'm using PowerShell 2.0 on Windows Vista. I'm trying to add support for specifying build arguments to psake, but I've run into some strange PowerShell variable scoping behavior dealing specifically with calling functions that have been exported using Export-ModuleMember (which is how psake exposes it's main method). Following i...

How to Access String Variable in One View Controller to Another view Controller

Hi, I am new to iphone development, Now i want to access the string variable in all the view controller, but i know to declare the variables in delegate method, but i cant access it, please help me out. Mainviewcontroller-->Viewcontroller1_-->viewcontroller2-->viewcontroller3-->subwebview. i have created one main view controller and t...

Overwriting iframe's document.write

For my own purposes (cough lazy-loading an ad script), I am overwriting the document.write function in order to buffer the script's output, writing it to a div, and restoring the native document.write when I am done. The pseudo-code looks something like this: save off native code document.write redefine document.write eval and buffer ...

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

jquery passing a variable to a function

Hay guys, I'm making a simple preload function (function($) { $.fn.preload = function(settings) { var config = { before: function(){ return; }, end: function(){ return; }, after: function(a){ return; } }; if (settings) $.extend(config, settings); var limit = this.length - 1; var counter...