variables

Pushing a variable outside of a function

I have a jQuery code block for a twitter widget i'm developing , $.getJSON("http://twitter.com/users/show.json?screen_name=" + twitterfeed + "&callback=?" , function(data) { var fString = ($('<div id="userimage"><h1>'+ data.followers_count +'</h1></div>').digits()).text(); var tString = ($('<div id="userimage"><h1>'+ d...

Where should I store calculated values I use throughout my application in Rails?

I have the following variable definition: @monday = (Time.now).at_beginning_of_week I use that in different models, controllers, and views. Where can I define it (and how should I define it -- @@? ) so I can define it once and use throughout my Rails application? Should it be in environment.rb? Should it be a @@? ...

Efficient computation of "variable (number of points included)" moving average in R

Hi everybody, I'm trying to implement a variable exponential moving average on a time series of intraday data (i.e 10 seconds). By variable, I mean that the size of the window included in the moving average depends on another factor (i.e. volatility). I was thinking of the following: MA(t)=alpha(t)*price(t) + (1-alpha(t))MA(t-1), whe...

Delphi Access to Thread Variables

I have a thread that does a WMI query for me and I need to access some variables in the thread after it has executed the query. The thread is created as follows ... procedure TFormMain.RunThread; var WMIQ: TThreadWmiQuery; begin WMIQ := TThreadWmiQuery.Create(True); ... WMIQ.OnTerminate := WMIQThreadOnTerminate; WMIQ.Resume;...

Sensible variable names for a text adventure action

This is a difficult one, I've been racking my brains but I just come up with a sensible name for these variables. Someone will probably instantly hit on one. Take these example actions: "throw bottle at wall" "push John into door" "attack Ogre with sword" action thing at/with/on/in/to thing I need a sensible name for the first "thi...

PHP to JSON on client side

Hi, I'm using Rob Monies 'Jquery Week Calendar' to build a calendar application. I have a MSSQL DB a with table named 'dates' and the following fields: id start end title I would like to query this DB in PHP and then pass the results to Javascript, Javascript will then render the events in the browser. The Javascript needs to receiv...

Matlab- How does you name a new variable based on other variables' values?

I want to name a variable using values of other variables given in a function. So, if I have values for an x1,x2 I can make the new variable's name as: x_(x1's value)_(x2's value) as a name. I've checked out the eval, num2str, strcat functions, but as of yet I can't make it so that I have a variable with the name above which I can assi...

How can I pass data from an ajax request to a global variable?

Ok. I'm totally baffled. Here's the code: $(document).ready(function(){ var newToken = 1; $.get("junk.php", function(newToken) { alert(newToken); // alerts "junk" }); alert(newToken); // alerts "1" }); As per my comments, the first alert of newToken is "junk" (the only output of junk.php). Once outside the .get, ne...

Storing a PHP loop as a string in a variable

Hello! I have a problem storing a PHP loop in a variable. The loop is like this: for( $i = 1; $i <= 10; $i++ ) { echo $i . ' - '; } for this it's OK for an echo or print as it will produce: 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - now I want to store the whole loop in a variable like $my_var which means: echo $my_var; ...

Class variables messing up

consider this code : Class Controller_xyz extends Controller { protected $res=' '; public function action_reg() { $this->res="blah"; $x="blah" echo $this->res; echo $x; } } output : b blah why am I not able to change class variable? ...

Is var necessary when declaring Javascript variables?

Possible Duplicate: Javascript: is using 'var' to declare variables optional? When creating variables in javascript is adding "var" before the variable name a must? For example instead of var message = "Hello World!" can I use message = "Hello World!" ? I notice that scripts like Google Adsense don't use var Example...

PHP replace variables in Word document

Hello everyone I have a word document that contains certain variables (for example the string $$title$$). Now I want to open this word document in PHP and replace the string $$title$$ with a string I read out of the database. Final step would be to save this word document and give it to the user for download. Replacing the string and s...

Boost Condition Variable Argument Error

Hello to all, i encounter an error in the code below. recursive_mutex m_RecurMutex; condition_variable cond; unique_lock<recursive_mutex> lock(m_RecurMutex); cond.wait(lock); // Error Here. What is the reason cause this error ? Thanks. ...

Can I share variables between different functions in PHP?

I'll try to explain with an example... Let's say I have two different functions, and one of them has a defined variable. In the second function, I don't wanna write the same variable again, can I simply use the variable from the first function in the second one WITHOUT redefining it in the second function? Something like: function a()...

javascript: can not use global variable in a function, to navigate the dom

hello, beginner here... what am i missing? i define a global variable that is a reference to an html element: var x=document.getElementById("xxx1"); then, inside a function a try to reference that variable to navigate the dom: x.innerHTML="dsfgfdgdf"; ...doesn't work; if i define the variable inside the function ...

What is better in python, a Dictionary or Mysql ?

What would be faster ? Query mysql to see if the piece of information i need is there, OR load a python dictionary with all the information then just check if the id is there If python is faster, then whats the best what to check if the id exists? Im using python 2.4.3 Im searching for data which is tagged to a square on a board, im s...

access to variable within inner class in java

I'm trying to create an array of JLabels, all of them should go invisible when clicked. The problem comes when trying to set up the mouse listener through an inner class that needs access to the iteration variable of the loop used to declare the labels. Code is self-explanatory: for(int i=1; i<label.length; i++) { label[i] = ...

Avoid using isset in PHP when accessing $_POST, $_GET, and other variables?

Hello all, how can I prevent PHP from returning an Undefined variable error every time I try to check a variable if it has contents and that certain variable hasn't been used yet? In my previous setup, I can check $_POST['email'] even if I haven't put anything into it yet. It simply returns a blank or empty result. That's how I want my P...

Using a batch file to extract the variable part of a string to use in renaming txt files

I'm using batch files to process text files with names of the form: CLL*1.txt, CLLM*2.txt located in a specific "download" folder. All files contain a string of the form: "File Reference : 0xxxx", where xxxx is a unique numerical identifier. I am trying, without much success, to use the following script to rename the file to CLL*xxxx...

Question on C# local variables scope

Hi, I am just wondering, I thought I cannot have variables with the same name: int Test; public void A(int Test) { } Why this does compile? I know I can use this keyword but seems to me strange that as the method is in the scope of the class it allows me to declare the variable with the same name. ...