Questions tagged [global]
Refers to a space where variables and other items may be accessed from any scope.
global
4,722
questions
0
votes
1
answer
15
views
Modify the values in a (global) list of dictionary without reference
I'm new to python - being an educator trying to write to python script to score student's performance downloaded from an online polling platform. I've solved most problems until something like this: I'...
1
vote
1
answer
23
views
React Native trying to use same array globally
I am trying to learn React Native and am wondering if there is a way to store an array, say in a constant file or something, and reuse it in different components. States will be one, as an example. I ...
0
votes
1
answer
55
views
Why I didnot get Multiple definition Error?
#include <stdio.h>
#define MAX 5
static int data = 10;
int increment(void *);
int increment(void *ptr)
{
int *p = ptr;
static int data =15;
for (int loop=0; loop < MAX; loop++...
0
votes
0
answers
42
views
Global CSS cannot be imported from files other than Custom <App>
My React App works fine on my friends computer using global CSS, however, I've been having this issue since I opened on my VSCode.
⨯ ./styles/globals.css Global CSS cannot be imported from files other ...
2
votes
1
answer
34
views
xlwings not updating global variable correctly when using threading
Here is my logic that I am trying to understand.
import xlwings as xw
import threading
workbook = ""
def function1():
t1 = threading.Thread(target=function2)
t1.start()
t1.join()...
1
vote
2
answers
39
views
Defining global lists in Stata if elements consist of several words
I need to make some operations with many Excel files with long names of the type "Saratov Region.xls" (I mean that names of these files contain one or more blank spaces).
I tried to write ...
-1
votes
0
answers
11
views
What is the use of Project -> Settings -> Deployments -> Globals in jBPM?
In jBPM, under the Project settings, there is a section called Deployments. Inside this section, there is a tab called "Global". Is this for defining global variables? How is it used in ...
-2
votes
0
answers
50
views
i want to acsess the global variables from a function body in python [duplicate]
I have a very long program and I want to implement a method to access the global variables present in the main program ( main.py ) from within a function called from a library ( file.py ).
main.py :
...
0
votes
0
answers
24
views
How can i list root objects JavaScript [duplicate]
So I have several objects and classes in my script tag
const Main = {}
const App = {}
class Game {}
let state = 777
etc. I'd like to list them.
I've tried
Object.keys(Object.getOwnPropertyDescriptors(...
-1
votes
1
answer
74
views
var vs let for *globals*... what practical difference does "a property on the global object" make?
I have seen this (or similar):
At the top level, let, unlike var, does not create a property on the
global object.
many times.
My question is: what practical difference does this make ?
Or, to put ...
0
votes
0
answers
16
views
MSVC global variables initialization order
MSVC 2022 VERSION.
If i use MFC static lib,i can use #pragma init_seg(lib) to change global variables initialization order. make my local global variables earlier than the lib.
and Now I have to use ...
0
votes
0
answers
32
views
Create one nodemailer test account and hold it in a module global
I have a nodejs application. One of the modules is for the mail transporter. I'd like to create a mail test configuration one per launch and store it (in global) so it can be reused.
However, during ...
0
votes
0
answers
21
views
What to do after installing npm packages globally with sudo?
I installed a npm package globally on my Mac. I used sudo for it since I had permission issue.
I know this is totally not the way to do it, but at this time I wasn't aware of it. I read a lot things ...
1
vote
1
answer
117
views
How to use Rust OnceLock get_mut() method?
The Rust documentation has a OnceLock::get_mut method that returns a mutable reference. But the following code does not compile. What am I missing?
use std::sync::OnceLock;
#[derive(Clone)]
struct ...
0
votes
0
answers
35
views
Unable to mock Webpack-defined global variables in Jest testing
I was trying to test a function using Jest where I need to mock a Webpack-defined global to test all the cases. I was unable to do so.
// webpack.config.js
...
new webpack.DefinePlugin({
__ENV__: `'${...
0
votes
1
answer
17
views
Thymeleaf enums refactoring issues
I encountered difficulties while refactoring a template. I have many references to a limited number of enum values in one template. (in a code snippet i indicated only a short part for clarity)
<...
0
votes
0
answers
22
views
MKDocs - Global Variables Possible Within Page?
Regarding MKDocs, is it possible to set a global macro or variable from within a page? My intent is to have a start page with a drop down menu. The global variables would be set based on the user's ...
-1
votes
1
answer
34
views
difference between local and global dependencies in angular
What is the difference between downloading local and global dependencies? For example, if I run "npm i bootstrap" in the project folder, will I download it from the location?, and if I want ...
-1
votes
1
answer
90
views
Global file pointer in C
I'm having a problem with a global file pointer in C with Visual Studio 2022 in a solution involving a large number of files that are compiled and linked using the "Build" command.
Based on ...
1
vote
1
answer
47
views
Caching previous values in solve_ivp
I want to use the temperature at the previous timestep when evaluating the next timestep. I don't want to use global, because I think it slows down the code and it is not very clean.
I use scipy....
0
votes
0
answers
35
views
How to get position of a rectangle which I draw using Custom Paint in flutter
I am creating a waste management app where user can take image then this Image is shown in a screen where user can draw rectangles around trash. I am using Stack with Custom Paints for doing this. But ...
1
vote
1
answer
38
views
using eval() inside function with input of function as part of string
I have this code:
def system(into):
global sys
x = into
sis = [eval(i) for i in sys]
return sis
if __name__ == "__main__":
sys = ['x[0]+x[1]','2*x[0]-3*x[1]']
I would ...
-2
votes
2
answers
69
views
Shell script for finding global variables
How would one write a shell script that finds all the global variables in a given C program?
I don't need a long line like
global_vars=$(grep -E '^[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]*[[:space:]]+[a-zA-...
1
vote
1
answer
36
views
global variables get different values (web / terminal)
While learning php I came across the following problem.
I don’t understand why I get different values on my local site and in the terminal when I run the following code:
function scopeTest(): int
{...
0
votes
2
answers
40
views
How to solve this global is not defined problem?
This is the error image
I'm working on a project and suddenly caught this error , I don't know where the error came from and it didn't have any information, please help me
<script>
var ...
4
votes
2
answers
75
views
Python global variables in recursion get different result
I have this code, which prints 1:
s = 0
def dfs(n):
global s
if n > 10:
return 0
s += dfs(n + 1)
return n
dfs(0)
print(s)
If I modify dfs like this:
def dfs(n):
...
0
votes
1
answer
49
views
Why do different delivery methods have different results when applying PHP's global keyword?
PHP implements the static and global modifier for variables in terms of references. For example, a true global variable imported inside a function scope with the global statement actually creates a ...
1
vote
0
answers
34
views
Changing PHP code which uses PHPs $_REQUEST super global
New to php and have read up on $_REQUEST being strongly discouraged, due to the fact that it makes it nearly impossible to determine the source of the data, and also being a security risk as well.
Not ...
0
votes
1
answer
60
views
Global event monitoring with WPF
I would like to ask for help in this matter: in WPF, I would like to monitor the keydown, mousedown and mousewheel events even if the window is not currently active.I use c# with WPF. I tried many ...
-4
votes
1
answer
98
views
What functions can access a global variable that appears in the same file with them?
I asked ChatGPT and Google Bard a C++ question that "What functions can access a global variable that appears in the same file with them?"
They answered that "Any function within the ...
1
vote
1
answer
36
views
Global variable not being updated with a thread in python
I have a Thread that is checking every hour of a time and keep updating a global variable, for some reason global statement is not working and it's keeping the same value in the global variable even ...
1
vote
2
answers
82
views
How to call global static method from class static method in C#?
The following program compiles et executes just fine in recent versions of C#, where a Main function is not necessary:
Module2.SayHelloDouble();
static class Module1
{
public static void SayHello(...
0
votes
0
answers
47
views
Lua error "mutating non-standard global variable 'love'"
I'm starting to code with love2d, so I installed love2d with the love2d support extension, there is no problem running the code and it works perfectly (I can draw hello world and have it appear on a ...
0
votes
1
answer
201
views
rust: static map initialization with enum keys
First up: I am a very newbie with Rust; learning.
This issue arises most probably from thinking in terms of other languages. So most probably the best solution is doing this in a completely different ...
0
votes
0
answers
17
views
Global Variable in Invoke Command
I want to use a global Variable in an Invoke-Command.
In the example below I want to replace the Get-Service with the global variable which will be filled in an earlier Function, $global:ServAction = ...
0
votes
0
answers
41
views
Laravel Inertia-React share function with parameters
In Inertia I know I can share datas via HandleInertiaRequests middleware, can I share a function that gets arguments?
Below code (dummy code) gives the error: TypeError: can is not a function
'can' =&...
-2
votes
1
answer
91
views
Powershell regex replace : string is unchanged
I'm trying to regex replace some groups of charactes in powershell using the following pattern:
/^(thedir[ ]=[ ]")(.)(:[/\])([a-zA-Z0-9])([/\]?.)$/gm
by using this instruction:
$fileContent = Get-...
0
votes
0
answers
39
views
Add persistent global function across pages via window, or localstorage, etc
I am trying to hide an icon on a page I can't edit directly. I need to add a function that has in it document.getElementById('icon').style.display = 'none';. I don't need help with the function.
So ...
0
votes
1
answer
54
views
How to get rid of a global.target within the terminal on MacOS?
I have run into this problem where anything I install with pip installs to my main location of python and not to my virtual environments.
The following line is what I get when I run: python3 -pip ...
0
votes
1
answer
478
views
Can't delete AWS RDS Global database. Deletion protection option missing
Trying to delete a Global RDS database (Postgres 11.9).
I deleted all the instances, and region clusters.
For this Global database cluster, getting error "Cannot delete protected Global Cluster **...
0
votes
3
answers
144
views
Universal function like Start() in Unity C#
I am creating a multiplayer system for unity that is aimed towards people who don't want to mess with anything with networking.
To simplify it, I want to create universal functions (for lack of a ...
1
vote
2
answers
256
views
How can I run a func that lives in a seperate View in SwiftUI?
I have an app wherein once navigated to a second page and shown some results, the user has the option of running the same function but with some different parameters.
I am stuck on figuring out how to ...
1
vote
0
answers
36
views
Using a varibale outside of the event listener block
I have been having difficulty accessing the variables populated within an eventlistener which is used to obtain the results from a php query. I tried a number of different ideas but I have been ...
0
votes
1
answer
60
views
Python logging global variable in an imported library
Can someone explain the behavior of logging behavior in a library which is imported? The log contains a supposedly global variable called trace_id.
I have the following library:
my_library/
__init__....
0
votes
0
answers
11
views
Globals designation is not being recognised in Excel VSTO C#
public CollageAllFunctionsRibbon()
: base(Globals.Factory.GetRibbonFactory())
{
InitializeComponent();
}
I get the message that "Globals" does not ...
0
votes
0
answers
187
views
Using pragma in .c and .h file
I am using pragma like this in .c file:
#pragma ghs startdata
#pragma ghs section bss=".BSS"
static int A;
#pragma ghs section bss=default
#pragma ghs enddata
in .h file:
extern int A;
...
-1
votes
2
answers
73
views
how to create a Python global variable whose name is the value of another variable [duplicate]
Given...
myGlobalVariableName = "zorp"
myGlobalVariableValue = "hello"
, ...how can I use the values of myGlobalVariableName and myGlobalVariableValue to create the global ...
0
votes
0
answers
34
views
Calculated field with usage of global variable on WordPress
I have created a custom global variable using the Custom Global Variables plugin because I want to display this variable in various places on my website and at the same time use it inside a calculated ...
0
votes
0
answers
21
views
php variable why it is visible in other files without being declared global? [duplicate]
I defined the following files
0.php
<?php
$v='good';
echo 'In file: '.__FILE__." v={$v}<br>\n";
?>
1.php
<?php
require '0.php';
echo 'In file: '.__FILE__." v={$v}<br&...
0
votes
0
answers
74
views
Unexpected global objects in node 18 [duplicate]
When executing with node v18.17.1, why are there different versions of the global object?
function foobar() { return this; }
console.log(this); // {}
console.log(foobar()); // Large output, as below:
...