variables

Passing JS variable name to function?

Hello all, So here is what I am trying to do: 1.My variable named data_1 is set. var data_1 = { "y_legend": { "text": "# of Patients", "style": "{font-size: 20px; color: #778877}" }, "x_legend": { "text": "AUG 09 - OCT 09", "style": "{font-size: 20px; color: #778877}" } }; In a drop down a user selects an op...

How does it know where my value is in memory?

When I write a program and tell it int c=5, it puts the value 5 into a little bit of it's memory, but how does it remember which one? The only way I could think of would be to have another bit of memory to tell it, but then it would have to remember where it kept that as well, so how does it remember where everything is? ...

save python output to log

I have a python script the runs this code: strpath = "sudo svnadmin create /svn/repos/" + short_name os.popen (strpath, 'w') How can I get the output of that command stored in a variable or written to a log file in the current directory? I know, there may not be an output, but if there is, I need to know. ...

How can I use a variable variable in PHP?

Here is what I am trying to do: <?php $my_str = "My String"; $str = "%my_str"; $str = str_replace("%", "$", $str); echo $str; ?> The above code prints '$my_str' to the screen. But I want it to print 'My String', as in the actual value of the variable $my_str Anyone know how to do this? The reason I want this is bec...

Quoting not respected inside a bash variable

I'm storing the arguments to a command in a variable. The final command I want is: mock -r myconfig --define "debug_package %{nil}" --resultdir results --rebuild mypackage.src.rpm Here's my attempt: set -x # for debugging RESULTDIR=results MOCK_CONFIG="myconfig" MOCK_ARGS="-r $MOCK_CONFIG --define \"debug_package %{nil}\" --resul...

PHP: setting variables in IF-construct?

Can I set variables inside if-construct? In general, where is it allowed to set variables? function set_login_session ( $passhash ) { $_SESSION['login']['logged_in'] = 1; if ( ERROR ) return false; } // Does it set the Session variable? if ( set_login_session ( $passhash ) === false) return false; ...

Performance: Single Variable Assignment vs Objectgraph Navigation (Java)

Hello, my question is about two possible ways to access data: (My question is about "real life usage" of java statements like below, accessing the data 2-10 times in a function. Not iterating over such statements with thousands of iterations/calls.) System.out.println(request.getParameter("locale")); System.out.println(request.getPar...

Get variable (not hard-coded) name?

I am looking for a way to retrieve the variable name, so I don't have to use hard-coded declarations when needed (for property names etc.): I hardly believe it's possible; maybe someone has a solution. Note: even not variables, properties would also be a move. 'Pseudo: Module Module1 Sub Main() Dim variable = "asdf" ...

Variable scope problem accessing outer variable

I have a function with a big hierarchy: function func(){ $a= 0; // Here the variable is 0 while(...){ echo $a; // gives me always 0 for(...){ if(...){ if(...){ $num = func3(); $a = $num; // this $a does not corrospond to $a in the beginning ...

$_SESSION variables being controlled by PHP configuration?

I commonly see people setting $_SESSION variables as $_SESSION['example']=$_REQUEST['something']; $example=$_SESSION['example']; is this redundant? I am currently working on a new server and $_SESSION['example']=$_REQUEST['something']; gives me access to $example without any extra code is this normal or a php configuration makin...

Calling a Variable from another Class (C#)

How can I call a variable from a public class to another public class in C#. I have: public class Variables { static string name = ""; } I need to call it from: public class Main { } Thanks for help in advance. Working in a Console App. ...

Changing IMG SRC with Javascript

I'm new at javascript and while there are many more complex solutions, I don't understand them and hope I don't have to at this point. I have a main picture... <img src="main-picture.jpg" name="Mainpic" id="image"> ...and I want to be able to change this picture when I click on one of two thumbnails. <a href="" onclick="FirstPic()">...

Include the result of a Foreach loop in a variable in PHP ? ( for the function mail() )

Hi, I'm French so I maybe not speak english very well. I'm trying to "put" the result of a foreach loop in a varible like that : $msg = '<html><head> <title>Commande de photos</title> </head><body> <p>Voici la liste des photos demand&eacute;es :<br /> <ul> HERE I WANT TO "PUT" THE RESULT OF THE FOREACH LOOP</ul>'; H...

Using $ variables in preg_replace in PHP

Ummm... how do I use variables in a call to preg_replace? This didn't work: foreach($numarray as $num => $text) { $patterns[] = '/<ces>(.*?)\+$num(.*?)<\/ces>/'; $replacements[] = '<ces>$1<$text/>$2</ces>'; } Yes, the $num is preceeded by a plus sign. Yes, I want to "tag the $num as <$text/>". ...

How to write a php/htaccess script to redirect form variables to another website

Hey here is my problem : i made a flash and i can`t change it no mather what. That flash had a form that was sending data to my subdomain.. i had to remove the subdomain and i got a new website, the problem is this : how do i redirect the form data from the old site to the new one? In the flash i had the form send the data to : subdomain...

In Java, should variables be declared at the top of a function, or as they're needed?

I'm cleaning up Java code for someone who starts their functions by declaring all variables up top, and initializing them to null/0/whatever, as opposed to declaring them as they're needed later on. What are the specific guidelines for this? Are there optimization reasons for one way or the other, or is one way just good practice? Are t...

Readonly local variable in VB.Net

This is a really simple question and I'm suprised I have to ask it but... How does one declare a readonly local variable in VB.Net? Java and C++ have final/const local variables so I'm sure VB.Net must have them, but I just can't find the syntax for it. ...

How to extract and then refer to variables defined in a python module?

I'm trying to build a simple environment check script for my firm's test environment. My goal is to be able to ping each of the hosts defined for a given test environment instance. The hosts are defined in a file like this: #!/usr/bin/env python host_ip = '192.168.100.10' router_ip = '192.168.100.254' fs_ip = '192.168.200.10' How ca...

Powershell: Setting an environment variable for a single command only

On Linux, I can do: $ FOO=BAR ./myscript to call "myscript" with the environment variable FOO being set. Is something similar possible in Powershell, i.e. without having to first set the variable, call the command, and then unset the variable again? To be more clear about my use case - I don't want to use this as part of a script. R...

Compound primary key in Table type variable

SQL Server 2008: DECLARE @MyTable TABLE( PersonID INT NOT NULL, Person2ID INT NOT NULL, Description NVARCHAR(100), CONSTRAINT PK PRIMARY KEY CLUSTERED (PersonID, Person2ID) ); Gives: Msg 156, Level 15, State 1, Line 5 Incorrect syntax near the keyword 'CONSTRAINT'. Is there any way to have compound Primary key in Table ...