scope

Android use of an string array on another method

Hi all. Im trying to make an activity that has a multiple choice dialog after you push a button. In there you select from a list of things. But these things are received from a web method before the dialog appears. So I create a string array after I receive them inside the onCreate to initialise it there with the correct size. But my di...

Can I create an alias in C# or VB.NET within method scope?

Is there any equivalent to an aliasing statement such as: // C#: using C = System.Console; or: ' VB.NET ' Imports C = System.Console ...but within method scope -- rather than applying to an entire file? ...

Multiple choice dialog wont let me alter an array when clicked

Hi I have a multiplechoice dialog on my activity. I have a boolean array to keep track of which items are selected from the dialog. So I want each time an item is clicked to make the corresponding place on my array true. The array is being created in the onCreateDialog before the return. public Dialog onCreateDialog(int id) { userlist...

validates_uniqueness_of...limiting scope - How do I restrict someone from creating a certain number of entries...

I have the following code: class Like < ActiveRecord::Base belongs_to :site validates_uniqueness_of :ip_address, :scope => [:site_id] end Which limits a person from "liking" a site more than one time based on a remote ip request. Essentially when someone "likes" a site, a record is created in the Likes table and I use a hidden fie...

In Objective C, is there a way to call reference a typdef enum from another class?

It is my understanding that typedef enums are globally scoped, but if I created an enum outside of the @interface of RandomViewController.h, I can't figure out how to access it from OtherViewController.m. Is there a way to do this? So... "RandomViewController.h" #import <UIKit/UIKit.h> typedef enum { EnumOne, EnumTwo }EnumType; @i...

javascript scope problem when lambda function refers to a variable in enclosing loop

First question on stackoverflow :) Hope I won't embarrass myself... I have a javascript function that loads a list of albums and then it creates a list item for each album. The list item should be clickable, so I call jQuery's click() with a function that does stuff. I do this in a loop. My problem is that all items seem to get the same...

Why are variables set on a page load not available in the document.ready scope?

I have an included javascript file thats initializes an empty array object called "widgets" var Widgets = {}; function Widget(a,b,c){ this.a = a; ... } in the same include a bunch of function prototypes are defined to add widget info to a widget: Widget.prototype.addWidgetInfo(a,b,c){ this.info.a = a; this.info.b = b; ... } the...

Getting around IBActions limited scope

Hello, I have an NSCollectionView and the view is an NSBox with a label and an NSButton. I want a double click or a click of the NSButton to tell the controller to perform an action with the represented object of the NSCollectionViewItem. The Item View is has been subclassed, the code is as follows: #import <Cocoa/Cocoa.h> #import "Wiz...

JavaScript inner function scope chain?

In this example var a = 1; ( function(x) { function inner() { alert(a); alert(x); alert(y); } var y = 3; inner(); })(2); When does function inner get created? during execution time or parsing time of outer anonymous function? What is in the scope chain of function inner? What is the difference betw...

onload Event in embedded SVG not calling function in attached script. Scope Issue?

Hi So I've got an XHTML page with a script - not inline > <script type="text/javascript" > src="../global/js/scripts.js"></script> and an embedded (I tried embed and object, same behavior) SVG document with a onload="CheckIfLoaded(evt)" attribute. The problem is firefox doesn't call the CheckIfLoaded() function in scripts.js. Firebu...

Google Wave Robot / Python Variable question

I'm experimenting/having a little fun with wave robot python apiv2. I made a little 8ball app for the robot which works fine, and now I'm trying to make a trivia app. I've never programmed in Python but I'm pretty sure my syntax is correct. Here is the relevant code: elif (bliptxt == "\n!strivia"): reply = blip.reply() if (triviaS...

Cannot get UISearchBar Scope Bar to appear in Toolbar (or anywhere) on iPad

This is really causing me fits. I see a lot of info on putting a UISearchBar in the top row of a UITableView -- but I am putting the UISearchBar into the Toolbar at the top of my screen (on the iPad). I cannot find ANYTHING regarding how to handle UISearchBar and UISearchDisplayController using a UIPopoverController on the iPad. Any mor...

php access array value from function return

silly php question... why cant i do this? echo Auth::getFullUser()[ 'country' ]; instead you have to do this $user = Auth::getFullUser(); echo $user[ 'country' ]; ...

PHP scope question

Hi, I'm trying to look through an array of records (staff members), in this loop, I call a function which returns another array of records (appointments for each staff member). foreach($staffmembers as $staffmember) { $staffmember['appointments'] = get_staffmember_appointments_for_day($staffmember); // print_r($sta...

C++ Why am I unable to use an enum declared globally outside of the class it was declared in?

Right now, my project has two classes and a main. Since the two classes inherit from each other, they are both using forward declarations. In the first object, right underneath the #include statement, I initialize two enums, before the class definition. I can use both enums just fine inside that class. However, if I try to use those enum...

How can a Perl force its caller to return?

Possible Duplicate: Is it possible for a Perl subroutine to force its caller to return? I want to write a subroutine which causes the caller to return under certain conditions. This is meant to be used as a shortcut for validating input to a function. What I have so far is: sub needs($$) { my ($condition, $message) = @_; ...

How to access method variables from within an anonymous function in JavaScript?

I'm writing a small ajax class for personal use. In the class, I have a "post" method for sending post requests. The post method has a callback parameter. In the onreadystatechange propperty, I need to call the callback method. Something like this: this.requestObject.onreadystatechange = function() { callback(this.responseText); ...

Increment global variable on click in flash, actionscript 3

Hi, Making a flash page that can cycle through these three images on mouseclick. For some reason the local changes to count are not reflected on the global one. I tried _global but the syntax was odd and gave me errors. How should I implement this? import flash.events.Event; var images:Array = ["images/image.jpg", "images/image2.jp...

How to structure javascript callback so that function scope is maintained properly

I'm using XMLHttpRequest, and I want to access a local variable in the success callback function. Here is the code: function getFileContents(filePath, callbackFn) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { callbackFn(xhr.responseText); } }...

Limiting a search to records from last_request_at...

I am trying to figure out how to display a count for records that have been created in a table since the last_request_at of a user. In my view I am counting the notes of a question with the following code: <% unless @questions.empty? %> <% @questions.each do |question| %> <%= h(question.notes.count) %> end end This is happeni...