8,880 questions
5
votes
0
answers
227
views
Is there a way to have uninitalized globals in C++? [duplicate]
I am writing an embedded OS to run on Risc-V. As part of that, I'm implementing a FIFO for UART buffering using the classic single consumer/single producer module. The class looks like this:
template &...
0
votes
0
answers
79
views
How to save global variable in Spring application
I need to integrate with a third-party system. I need to authenticate there and obtain a sessionId. So, my application will have a URL, login, and password to obtain a sessionId. But to avoid having ...
1
vote
1
answer
637
views
Codex with API key on Macbook not working
I had codex originally authenticate via openAI web. Since i hit my limit i would now want to upgrade to the "pay per use" via api key. After following all the steps on https://github.com/...
1
vote
0
answers
25
views
Using SASS partials in a multi-client setup
Since @import will be deprecated in Dart SASS, I've tried to find a solution for the following problem. I want to use the same partials for different clients which have different, colors, fonts, font ...
0
votes
0
answers
51
views
Escaping strings using mysqli without passing a connection parameter in PHP to function [duplicate]
I am updating some legacy PHP code that makes use of mysql_escape_string to escape strings. The web host has not included the PDO module in their latest upgrade (I have spent hours in pointless chat ...
1
vote
1
answer
160
views
Sharing constants between CPU and GPU in CUDA
I'd like to share some constants between CPU and GPU in order to allow for execution of the same code (wrapped in between) on either. That includes some compile-time parameters which are most ...
0
votes
0
answers
34
views
How to define a global helper (e.g. getUserFromToken like console.log()) for all Next.js API routes without importing it in every file?
I'm building a Next.js app and I have a helper function called getUserFromToken(token) which extracts and verifies user info from a JWT.
I'd like to use this helper in all my API routes without ...
-1
votes
1
answer
122
views
I am trying to call a function in thonny and then printing the variable changed by the function. Why isn't it working? [duplicate]
i define the function "player" and inside, assign the variable "health".
def player():
health = 100
player()
print(health)
but when i try to run the program, i recieve this
...
-1
votes
1
answer
62
views
Why is global not incrementing in functions (Python)?
This code does not work properly:
def anyFunction(var):
for i in range(3):
try:
exec(var+"+=1")
except NameError:
exec("global "+var+"\n"+var+"=...
0
votes
0
answers
43
views
About defining spreadsheet object in onOpen script file [duplicate]
I am new to Google Apps Script platform. So I am having difficulty about defining variables in the most suitible place. I have many sheets and script files in a spreadsheet. I am using ss variable ...
4
votes
1
answer
216
views
How are constexpr device variables accessible from host?
My colleague came across this situation where global __device__ constexpr variables are accessible from both the host and the device.
#include <array>
#include <cstdio>
__device__ ...
1
vote
1
answer
90
views
Python global variable changes depending on how script is run
I have a short example python script that I'm calling glbltest.py:
a = []
def fun():
global a
a = [20,30,40]
print("before ",a)
fun()
print("after ",a)
If I run it from ...
1
vote
1
answer
36
views
Does file_obj.close() nicely close file objects in other modules that have been set equal to file_obj?
I have a file main_file.py that creates a global variable file_obj by opening a text file and imports a module imported_module.py which has functions that write to this file and therefore also has a ...
0
votes
0
answers
61
views
Global variables not showing up while debugging with VS code cppdebug extension
My setup:
I am using C/C++ for Visual Studio Code (version 1.25.3) and OpenOCD (0.12.0) and JLink for debugging and am enabling the debugging using launch configs and setup commands.
My configs:
...
-6
votes
2
answers
103
views
Looking for ideas on efficient ways to transfer random variables between functions [closed]
I have been experimenting with code structures and in this case I am not sure that I can figure out a better way to make the second example more efficient.
This code works:
A_list = [
# item,...
0
votes
0
answers
52
views
How do I change a global constant of a loaded module so that other global variables of the loaded module that depend on it reflect the change?
This question may have a simple answer. I have a near-trivial module0.py:
a = 1
b = a + 3
I import this module into a script and redefine module0's global constant a:
import module0 as m0
m0.a = 2
...
0
votes
0
answers
60
views
Finding global variables in ARM disassembly
My question is related to In the ARM ABI, how are global variables accessed? but is somewhat different.
I'm trying to debug an issue and for that I went looking in the build outputs of my project. I ...
1
vote
4
answers
149
views
Why doesn't JavaScript's garbage collector clean up global variables? [closed]
I've been reading an article about memory management in JavaScript, and it says that the global scope objects don't get cleaned from the memory.
If a global variable is not being referenced anywhere ...
0
votes
0
answers
44
views
How to set global PS variable in a manifest
I am converting a script module to a manifest module.
In the script module I do the below at the end
#
# Whole module Verbose output
#
# We will output verbose "Continue"
# We will NOT ...
0
votes
2
answers
100
views
application helper understanding global
I know there are religious wars fought over part of what I'm about to ask. I'm not here for any of that. I'm just curious why in my rails application helper I cannot have a global level variable ...
2
votes
1
answer
177
views
What is the difference between alias `our` and the original global variable?
This is one question encountered while reading the answer of this QA (as ikegami's comment says, how subroutine foo works is complicated. IMHO that may be due to using one outside variable):
sub foo { ...
-4
votes
1
answer
165
views
Unexpected behavior of Global Scope Variable in C#
I have been trying to understand two code blocks.
The first code block:
string status = "Healthy";
Console.WriteLine($"Start: {status}");
SetHealth(status, false);
Console....
-1
votes
1
answer
119
views
Global variable value not translating from Userform to Subroutine
In my code, I have a combobox on a userform. The user selects an option from the drop down and the userform sets the selected value to a global variable "monthYearEntered".
Then i have a sub ...
0
votes
1
answer
330
views
Laravel Livewire VOLT, I get undefined variable name error
I am trying to develop a page in which available appointments are listed. So the students will be able to choose one for foreign language talking exercise. Everything is fine. I get
Undefined ...
3
votes
2
answers
92
views
variable declaration from inside a function on another cpp file
I have an interest in cryptography and have decided to try and write an AES library. However it has been a long time since I have programmed cpp and I'm a bit rusty. I have this code in my AES.cpp ...
0
votes
0
answers
53
views
Understanding a Formula using Global Variables PowerApp created from Dataverse
I have a PowerApp that was created using a Dataverse table. many, many years ago. I did not create this app nor the dataverse and its contents. I am trying to decipher what this formula using global ...
1
vote
1
answer
64
views
Need to defer the `name` variable in a Bash script
How to defer the name variable in our Bash script so that it expands correctly within quotes in the loop, in such e.g:
name='*'
curate() {
local e=
for e in $(export HOME='/home/me'; echo /home/me/...
-1
votes
1
answer
332
views
What happens to the variables stored in the lifecycle state in FastAPI?
I have a FastAPI app with MongoDB connected via Motor. I open a MongoDB connection at the beginning of an app and close it at the end using lifespan:
from contextlib import asynccontextmanager
from ...
-1
votes
1
answer
66
views
Python- Pass a global Variable (that is constantly being updated) into a Class
I am trying to instantiate a class using a constantly updating global variable as an argument. But what is happening is the class (which runs in its own thread) won't recognise the global variable ...
-1
votes
3
answers
106
views
Can I call an anonymous function inside a <scrip> tag linked to an external js file? [duplicate]
HTML File(firstHTML.html)
<!DOCTYPE html>
<html>
<body>
<h2>My First Web Page</h2>
<p id="demo">First Paragraph</p>
<p id="demo2">...
-1
votes
1
answer
104
views
How do I read values directly into a global HashMap?
How do you create a global variable that is a HashMap and is populated with data directly? The code below has a local variable 'e' that works as intended. However, I am struggling to make it a global ...
1
vote
4
answers
94
views
Make constant array visible to different source file
Is it possible to make contents of constant array be visible across multiple other source files so that compiler can optimize access to the array.
I have an array const int myTable[10]; and in ...
1
vote
1
answer
55
views
Why would javsascript think a global variable is undefined [closed]
I'm writing a function to check if a table on the page is empty and insert rows with or without a header as appropriate.
The code on the page itself is:
<div id='uncoveredServices' style='display:...
0
votes
1
answer
33
views
Python - SyntaxError: name 'point_to_managedDB' is assigned to before global declaration
point_to_managedDB = None
def _get_correct_DB_flag():
if ENV == "dev":
global point_to_managedDB
point_to_managedDB = os.environ.get("OIA_POINT_TO_MANAGED_DB_DEV&...
1
vote
1
answer
77
views
How to access a struct from another file?
I have the following code and the objective is to make use of the colour variable as a binary flag in the code.
main.cpp
#include "turn.h"
#include <stdio.h>
void subfunc(Turns t) {
...
4
votes
2
answers
275
views
How do I call a global C function pointer in NASM without warnings?
Given main.c:
#include <stdio.h>
void (*fn_ptr)(void);
void foo(void);
void bar(void) {
printf("bar\n");
}
int main(void) {
fn_ptr = bar;
foo();
}
and foo.s:
extern ...
1
vote
2
answers
62
views
I am getting a type error when trying to return count along with the sorted lost
count = 0
def merge(L1,L2):
m = len(L1)
n = len(L2)
i = 0
j = 0
c = []
k = 0
while i<m and j<n:
if L1[i]<=L2[j]:
c.append(L1[i])
...
1
vote
1
answer
122
views
How to make a shared library's global object survive exit() function?
I have a problem with a shared library's global object getting destroyed before it is used. I do not know all details nor do I have control over an application that uses the library but my assumption ...
0
votes
0
answers
70
views
pass value of a variable with the same name between procedures/functions in Scheme
I want to pass values of variable with the same name (say "bindings") between procedures, but have problems with it. For example, I have several procedures like the one below, they all have ...
2
votes
1
answer
163
views
How to fix NetLogo error “There is already a global variable called [ ]"
I keep getting the error There is already a global variable called “DOTTED-LINE-VISIBLE” but when I change the name it gives me the same error but with the new name. How to fix it? The global variable ...
2
votes
2
answers
102
views
Problem accesing global variables in main.c through .S assembler source file (MPLABxIDE)
My project consists in:
Using a 4 digit 7-segment display to show certain numbers, representing the amount of cash stored in a moneybox. I am using both .c and .S files.
To rotate between the 4 digits ...
0
votes
0
answers
25
views
how to implement a global shared resource within the scope of a class [duplicate]
This question is not about the difference between class and instance variables.
I want to design my program in such a way that my main class provides global resources to modules for them to use but ...
0
votes
1
answer
67
views
python: class with global variables [closed]
Of course there should be no global variables - vars should be passed with function calls. My actual implementation needs lots of variables which are used in different "xxx.py" modules. So I ...
-4
votes
1
answer
101
views
How can I assign to a global variable from inside a function? How do I reset a painted-over image with CV2?
I'm working on a small program that open an image and lets the user click on points to draw lines.
import datetime
import cv2
import numpy
clicked = False
path = "files/file1.png"
...
0
votes
1
answer
46
views
SAS Capturing a regression output and use it as a variable
I am running a regression on var_x versus var_y in a calibration step. In a later step I want to use the outcome of this regression as a variable in my code.
For now I am running the regression and ...
1
vote
1
answer
135
views
Why the value of the global variable does not change when modified within function
I am programming a Raspberry Pi Pico in C. I have this MWE:
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include "hardware/uart.h"
#define UART_ID uart0
#...
4
votes
1
answer
115
views
Is there any use for a top-level global variable declaration?
In Python, the global declaration is used inside function definitions to specify that assigning the variable will create/update a global variable, rather than the default local variable.
Python also ...
-2
votes
1
answer
98
views
Declaring Global variable inside of a function in C++ [duplicate]
I have a function inside a class. I want to declare about 10 global variables of different types: vector, queue, int, 2d-vector etc., How do I do this?
Also I just cant declare the variables outside ...
0
votes
0
answers
46
views
Problem with Eslint js and global variable
I have a problem with eslint when building my docker containers, but for some reason when I want to create it it gives me an error in a global variable, which I use in the same component but it only ...
0
votes
1
answer
329
views
FreeRTOS event-task architecture to handle different flags around the code
I'm working on a FreeRTOS project in C/C++ that has about 10 tasks for gpios, displays, wifi, and so on.
These tasks are only triggered by events. For example, the user chooses an option on the menu &...