variables

Simple Rails Q: Where is this variable defined?

I'm following this tutorial (seems good) for Rails. After I run ruby script/generate scaffold Post then this link works in one of the erb files: <%= link_to "My Blog", posts_path %> WHY? I've looked for "posts_path" in the whole app and it's nowhere to be found. On the other hand, this <%= link_to "My Blog", home_path %> does no...

How do you write tests to test functions with variable return values?

I've got a simple function like this: function CreateFileLink() { global $Username; return date("d-m-y-g-i"); } How do you write code to test a function like that where the return data is variable? ...

In php when initializing a class how would one pass a variable to that class to be used in its functions?

So here is the deal. I want to call a class and pass a value to it so it can be used inside that class in all the various functions ect. ect. How would I go about doing that? Thanks, Sam ...

How to pass variable to SelectCommand of SqlDataSource?

I want to pass variable from the code behind to SelectCommand of SqlDataSource? I dont want to use built-in parameter types (like ControlParemeter, QueryStringParameter, etc) I need to pass a vraiable? the following example does not work <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionSt...

Is $_ more efficient than a named variable in Perl's foreach?

I am quite new in Perl and I woud like to know which of the following loops is more efficient: my @numbers = (1,3,5,7,9); foreach my $current (@numbers){ print "$current\n"; } or my @numbers = (1,3,5,7,9); foreach (@numbers){ print "$_\n"; } I want to know this in order to know if the use of $_ is more efficient because is...

c# reference variable mem allocation

Hi, Does anyone know how much memory is taken up when you create a reference type variable? String s = "123"; How much memory would 's' take up as a reference, not the data pointing to it? ...

Changing the values of variables in methods, Java

Hello, I have a questions about changing the values of variables in methods in Java. I have the following example class: public class Test { public static void funk(int a, int[] b) { b[0] = b[0] * 2; a = b[0] + 5; } public static void main(String[] args) { int bird = 10; int[] tiger = {7}; T...

C++ member variable aliases?

I'm pretty sure this is possible, because I'm pretty sure I've seen it done. I think it is awesome, but I will gladly accept answers along the lines of "this is a terrible idea because ____". Say we have a basic struct. struct vertex { float x, y, z; }; Now, I want to implement aliases on these variables. vertex pos; vertex col;...

Velocity and JavaScript

Hi, I have a bit of a problem here: #foreach($image in $command.lessonLearned.images) Image: $image.fileName <input type="submit" onclick="submitForm();setImageToRemove($image.id);setAction('removeImage');" value="REMOVE"/><br/> #end $image.id inside the onclick event is not evaluated as a velocity variable. How do I make it w...

What's a good way to keep track of class instance variables in Python?

I'm a C++ programmer just starting to learn Python. I'd like to know how you keep track of instance variables in large Python classes. I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members. But since Python allows you to add new instance variables on the fly, how do you keep track of...

How can I separate Perl variables from text in interpolated strings?

Hello, print " $foo", "AAAAAAAA", $foo, "BBBBBBBB"; Let's say I want to use this code with a print <<EOF;: print <<EOF; $fooAAAAAAAA$fooBBBBBBBB"; EOF That won't work because Perl thinks I have a variable called $fooAAAAAAAA. How can I easily use print << with such lines when I have a long test to print? ...

How do I get the result of a checked checkbox?

I'm really new to HTML, but I can't find anywhere how to return the variable from a check box. I've figured out how to get variables from forms and inputs, but I don't know how to get them from check boxes. Basically, I want a check box that if checked, will return the value yes. If not checked, it doesn't have to return a value, but no ...

Making a global variable accessible for every function inside a class (PHP5)

I have a variable on the global scope that is named ${SYSTEM}, where SYSTEM is a defined constant. I've got a lot of classes with functions that need to have access to this variable and I'm finding it annoying declaring global ${SYSTEM}; every single time. I tried declaring a class variable: public ${SYSTEM} = $GLOBALS[SYSTEM]; but this...

flash to php sending and recieving variables

I Have a unique id generated for each record that i store into the database i want to pass that id to php and run a select statement against that and get a value back from the database and pass it back to flash, what is the best possible way to do it? ps am using AS3 ...

How can I return a value from GM_xmlhttprequest?

I have this code here: var infiltrationResult; while(thisOption) { var trNode = document.createElement('tr'); var tdNode = document.createElement('td'); var hrefNode = document.createElement('a'); infPlanetID = thisOption.getAttribute('value'); var myURL = "http://www.hyperiums.com/servlet/Planetinf?securitylevel=90...

How are variables on the stack accessed?

Suppose we have these local variables: int a = 0; int b = 1; int c = 2; int d = 3; As far as I know, these will be allocated on the system stack, like this: | | | 3 | d | 2 | c | 1 | b |_0_| a Does this mean that in order to get the value of a, the values of d, c and b must first be popped out of the stack? If so, where do these ...

Parameter vs. Member variables

I've recently been working with someone else's code and I realized that this individual has a very different philosophy regarding private variables and method parameters than I do. I generally feel that private variables should only be used in a case when: The variable needs to be stored for recall later. The data stored in the variab...

instantiate a class from a variable in PHP?

I know this question sounds rather vague so I will make it more clear with an example: $var = 'bar'; $bar = new {$var}Class('var for __construct()'); //$bar = new barClass('var for __construct()'); This is what I want to do. How would you do it? I could off course use eval() like this: $var = 'bar'; eval('$bar = new '.$var.'Class(\'v...

Dynamically accessing nested movie clips in flash actionscript 2

I have a nested movie clip instance that I want to access. The path to the movie clip is defined by two variables ( similar to a row and column). I am already dynamically accessing the parent movie clip like this: eval("row" + ActiveRow) Now I want to access one of row(#)'s children called let(#) dynamically. Here are my best guesse...

Class variables, scope resolution operator and different versions of PHP

I tried the following code in codepad.org: class test { const TEST = 'testing 123'; function test () { $testing = 'TEST'; echo self::$testing; } } $class = new test; And it returned with: 1 2 Fatal error: Access to undeclared static property: test::$testing on line 6 I want to know whether referencing a class const...