Questions tagged [local-variables]

Local variables have a limited scope, generally one function or one functional block.

Local variables have a limited scope, generally one function or one functional block.

Compare with global variables, which are accessible from any part of a program.

1302 questions
0
votes
1 answer

How do I store a LONG list of names in a macro in Stata?

I need to store a very long list of variable names in Stata and after something like 250 characters, no more characters can be stored in a local or global macro. Currently, I'm using many different globals to store the names of the many regressors…
0
votes
3 answers

more efficient to create static local objects c++

Edit: I know that declaring an object before a loop body is more efficient since it calls the constructor and destructor per function call rather than once per loop iteration. Lets say that objects of type A are more efficient outside a loop body…
bathtub
  • 426
  • 3
  • 15
0
votes
7 answers

Local variable in java

All code is in Java. public class TestLocal { public static void main(String [] args) { int x; if (args[0] != null) { // assume you know this will // always be true x = 7; // statement…
0
votes
2 answers

Re-defining global variable with conflicting local variable

So I was trying to get a handle on JavaScript's scope and looking up lots of info about it. I saw a lot of questions about people accidentally making local variables that conflicted with global ones. But I was wondering if there was a way to change…
JSNub
  • 3
  • 1
0
votes
3 answers

What is the name of objects passed from jQuery selector to handler function?

I don't understand following behaviour of jQuery 1.9.1 in Firefox 22.0, when following code (jsFiddle) does not produce ReferenceError as expected (not even in strict mode), but returns an object instead: $("#press").click(function(){ …
Aprillion
  • 21,510
  • 5
  • 55
  • 89
0
votes
1 answer

How to deal with shared data when throwing exceptions

When having multiple threads using shared data, how does one correctly handle the destruction of that data when exceptions are thrown? I'm working on an application where I want one process to be doing work while waiting for a result sent from…
maditya
  • 8,626
  • 2
  • 28
  • 28
0
votes
1 answer

How can I set a flag in javascript for a google chrome extension

I have this Twitter scanner (a Google Chrome extension), that I want to execute this IF statement exactly once. After that I still want it to be able to scan for other shoeName, but my flag that I set keeps getting reset. Here is my code: function…
0
votes
6 answers

Why local variable is initialized to zero

According to my knowledge, local variables are uninitialized i.e, it contains garbage value. But following program is giving 0 (zero) as output. main() { int i; printf("%d\n",i); } When i run above program it is giving always 0. I know that…
Chinna
  • 3,930
  • 4
  • 25
  • 55
0
votes
4 answers

Why default value of local variables in C is same?

#include int main() { int i,j=3; i=4+2*j/i-1; printf("%d",i); return 0; } It will print 9 every time,though i is not initialized, So, it must print any garbage value. Please Explain...
user2536783
  • 95
  • 1
  • 2
0
votes
2 answers

How are local variables in method counted java bytecode

I have been learning about java byte-code recently, and i have been understanding most of it, but i am confused about how the local variable count for example is counted. I thought it would just be the total of the local variables, but this code…
Popgalop
  • 737
  • 2
  • 9
  • 26
0
votes
2 answers

Thread safety of local variable of a method in jsp

Is a variable declared inside an user-defined function in jsp threadsafe? For example in the below snippet, is the variable 'i' thread safe? <%! public int increment() { int i=0; return ++i ; }
0
votes
2 answers

how do i access a return value from a jQuery function

I'm wondering how how access returned values from a jQuery function. I know the basic way with a javascript function like so: "var myVar=myFunction();" But can anyone please show me how I would do it with a jQuery function like this? If i was…
NickG77
  • 183
  • 2
  • 12
0
votes
2 answers

calling within ActionListener

I'm trying to plug my code into my GUI at the moment i can't find a way to call text in the ActionListener with out breaking my code I know there are some things in findAndReplace() i will need to work on to get it to work in my GUI... but at the…
Sage1216
  • 83
  • 1
  • 2
  • 7
0
votes
1 answer

Add a local variable to an actionscript or javascript function

First of all, it is my understanding that appart from some syntax javascript and actionscript operate in a very similar way regarding functions. And in both languages I have the need to add a local variable to an event listener of some sort. for…
Herbert
  • 5,279
  • 5
  • 44
  • 69
0
votes
2 answers

Trouble updating a "trivia game" code written in python 2 to python 3

I am trying to get the code for a trivia game written in python 2 to run in python 3. Here is what I've gotten so far, but I'm just too confused at this point. None of the multiple choice answers will display (just numbers). # the start of a state…
Andrew
  • 11
  • 1
  • 3