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
2 answers

How to access thread and its components?

I create a thread type ss_thread = class; ss_thread = class(TThread) protected Fff_id : string; Fff_cmd : string; Fff_host : string; Fff_port : TIdPort; procedure Execute; override; public constructor Create(const…
jmp
  • 2,456
  • 3
  • 30
  • 47
0
votes
2 answers

Use variables in scope of a given function without passing

I want to use local variables like 'thisModule' in scope of the given 'functionToRun' without passing them as parameters. Onsetsu.run = function (functionToRun) { var thisModule = Onsetsu.namespace(resolvedModule.moduleName); …
Stefan Ramson
  • 531
  • 1
  • 6
  • 18
0
votes
2 answers

executing a javascript function within a function

This question refers to kineticJS but the problem is about the basic logic of nested functions I believe. I have a kineticjs stage on a div:
The kineticjs script puts a shape on the stage: function…
seinecle
  • 10,118
  • 14
  • 61
  • 120
0
votes
3 answers

How to change local static variable value from outside function

#include void func() { static int x = 0; // x is initialized only once across three calls of // func() printf("%d\n", x); // outputs the value of x x = x + 1; } int main(int argc, char * const argv[])…
Anand
  • 67
  • 4
  • 9
0
votes
3 answers

How can I access the arguments?

I want a method to be used within another method and returns the arguments without the need of mentioning the argument names, something like return_arguments in the following. def foo a, b, *c ... # part a p return_arguments ... # part…
sawa
  • 165,429
  • 45
  • 277
  • 381
0
votes
2 answers

Returning an address of local variable behaviour

Possible Duplicate: Can a local variable's memory be accessed outside its scope? input: #include #include int func2(void); int* func1(void); int func2(void) { int* b; b = func1(); printf("%d", *b); …
Nizarazo
  • 139
  • 2
  • 10
0
votes
2 answers

Using a local variable in the from statement in SQL

I have a database where each table is named by standard conventions. I am building a SQL script to run periodically on various sets of similarly named tables. I would like to declare a local variable that contains common part of table names between…
user1636742
0
votes
0 answers

Local variable versus One-row Table

Is there any significant decrease in performance, or other adverse effect by using 1-row tables instead of local variables? instead of: Declare @DT date = getdate() use: Select convert(date, getdate()) as DT into #DT The reason I would want to do…
VISQL
  • 1,960
  • 5
  • 29
  • 41
0
votes
7 answers

Local variable may not have been initialized

public class DatabaseHandler extends SQLiteOpenHelper { // All Static variables // Database Version private static final int DATABASE_VERSION = 1; // Database Name private static final String DATABASE_NAME = "contextsManager"; // Locations table…
user340
  • 375
  • 12
  • 28
0
votes
3 answers

Declare Locally or Globally in Delphi?

I have a procedure my program calls tens of thousands of times that uses a generic structure like this: procedure PrintIndiEntry(JumpID: string); type TPeopleIncluded = record IndiPtr: pointer; Relationship: string; end; var …
lkessler
  • 19,819
  • 36
  • 132
  • 203
0
votes
3 answers

Ruby is storing classes inside of local variables instead of instance variables

Why is Ruby forcing me to instantiate/store these classes inside of local variables instead of instance variables? Before I changed my code to make it functional, I had this: require 'test/unit' require 'converter' class TestConverter <…
boulder_ruby
  • 38,457
  • 9
  • 79
  • 100
0
votes
2 answers

PostgresQL Stored Procs: Using a set of results in an update statement without looping through the set

I have a stored procedure in which I need to query for a set of ids and then use that set in an UPDATE statement's WHERE clause. I'm using PostgresQL 9.0+. I'd rather not use a loop over the set of ids and issue multiple UPDATE statements -- that's…
jacaetevha
  • 23
  • 1
  • 5
0
votes
1 answer

Address of local variable is assigned to member pointer in Structure

struct a { int *val; }; void main(){ int n; struct a *a1; a1= malloc(sizeof(a1)); n=10; a1->val = &n; func(a1); printf("After changing %d\n",a1->val); } void func(struct a *a2){ int a = 5; a2->val =…
shunty
  • 375
  • 2
  • 7
  • 24
0
votes
1 answer

no of records in a store are not returning in extjs

I am new to extjs and was working on creating a dynamic screen depending on the no of records from the Ext.data.store(); getTotalCount/getCount are used to get the no of records from the store. I need to store the total no of records in a var and…
Anurag Sharma
  • 4,839
  • 13
  • 59
  • 101
0
votes
1 answer

Do delegates create thread safety issues with local variables?

I am initializing a mutable class instance as a local variable with new keyword. Then I pass this object as a parameteter to a delegate. Is this variable's lifetime extended by the delegate? Do other threads use this variable or create their own…
Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156