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
-1
votes
1 answer

How to make scene local JavaFX

The scene at the start of lambda has an error that is not local. How to make it local. I tried adding up top but shows null. How to make scene local at the lambda because scene sets primaryStage. I need the other nodes for GridPane. I am trying to…
user12060636
-1
votes
2 answers

Looping over many variables with the same prefix in their name

I have many variables starting by the same prefix grado. I would like to keep an observation when at least one of these variable equals a certain value, say 4. Elements of the variables grado*are byte. I have created a local and looped over its…
LisaB
  • 65
  • 5
-1
votes
1 answer

Variables loses value inside a while loop only

I am trying to compare data from 2 different spreadsheets in excel. When I am doing this I store the values from certain cells in the Check variables(userCheck, sessionCheck, and idCheck). What I am finding is that the between the first check and…
-1
votes
1 answer

How to update the value of global variable react native?

I want to update the value of bjpv and finally set it's state to new updated state, which I will get from the firebase function I am using expo for my react native application. This is a simple voting application. class Dashboard extends…
-1
votes
1 answer

Can't Access Value of Input Using Global or Local Variable

I'm not able to get the value of the variables height and weight. I made it global and renamed it but it still doesn't working. Quick run down of the code: the form stores the users input and writes it to the chat the form should take height and…
-1
votes
1 answer

Access numpy array (vs. python array) from another module

I am tryint to convert some of my python arrays to numpy arrays and have problems accessing a supposingly global np array in another module. Module 1 (imports data): import numpy as np jobs_db = [] def read_all_data(date, filepath): global…
Hendrik
  • 153
  • 1
  • 2
  • 18
-1
votes
1 answer

Global and Local Variables in Python3

I am having trouble with Global Variables. I am trying to create a variable, change it, print it, change it again and print it again. However, I get an error even though my variables are already defined as Global. Why is this? myGlobal = 5 def…
-1
votes
1 answer

Confusion with passing character pointer array by reference

How can I pass an array of character pointers by reference? I tried passing with &tokens and de-referencing in func() but it still won't work. Here's my code: #include void func(char* tokens[10]) { char word[10] = "Hello\0"; …
Wizard
  • 1,533
  • 4
  • 19
  • 32
-1
votes
1 answer

Python use input to select local variable inside another function

All, I have this request but first I will explain what I'm trying to achieve. I coded a python script with many global variables but also many methods defined inside different modules (.py files). The script sometimes moves to a method and inside…
Angelo
  • 1,594
  • 5
  • 17
  • 50
-1
votes
1 answer

JavaScript anonymous functions accessing local variables

I was trying to use FileReader to read from a text file and below is my code which throws an error. var message = document.getElementById("message"); function upFiles(files){ for(var x=0; x< files.length; x++){ var…
-1
votes
1 answer

Variable size element in embedded function but fixed input and output

I have a fixed input and output for my simulink embeded function. However I would like to compute a variable size element inside the function, (only used for calculation). Therefore I would prefer not to declare the block as receiving or sending…
Chewbaka
  • 184
  • 10
-1
votes
2 answers

How to make a Variable global to all keywords in Robot framework

${BEFORE_RESTART}= Get Restart Count This variable is local to one test case in robot framework. I want to access the same in other test cases of same test suite. I tried to figure out ways using Set Global Variables But didnt work.
-1
votes
2 answers

Accessing the local variable outside of function - python

In [1]: def test(array, func): ...: midres = [x**2 for x in array] ...: return func(midres) ...: In [2]: test([1,2,3], sum) Out[2]: 14 In [3]: p = test([2,3], sum) Is it possible to get to the midres that was calculated when…
P. Prunesquallor
  • 561
  • 1
  • 10
  • 26
-1
votes
1 answer

Is it faster to make std::string static in a function?

So I have a std::string that is always used every time the function gets called. void doSomething() { ... std::string temp_str; ... // bunch of codes which reads and writes to temp_str } Now I'm guessing, isn't it faster to change…
vbstb
  • 1,261
  • 1
  • 10
  • 14
-1
votes
2 answers

Compiler error - "use of unassigned local variable". what can go wrong?

Almost every blog I read says compiler flagging error "use of unassigned local variable" says its design decision because history says that unassigned variable are source of bug and compiler wants to stop you doing that. I am not sure how assigning…
rahulaga-msft
  • 3,964
  • 6
  • 26
  • 44