Page 1 of 1

Is it a bad idea to use global objects like this?

Posted: 05 May 2017, 21:29
by magicinmath
The script I am thinking about has about 300 strings of data in text or numbers, which need to be accessible to about 5 different hotkey programs, which all share a function but have different instructions and input to the function. The script would be running for about 8 hours at a time.

Code: Select all

global data

data:=["string of data1","string of data 2", .... "string of data n"]

some_function_that_uses_data(input)
{
	; some instructions that use data and %input%
}

F1::
{
	; some instructions that define %input%
	
	some_function_that_uses_data(input)
	
	; some other instructions that use data
	
	return
}

F2::
{
	; some instructions that define %input%
	
	some_function_that_uses_data(input)
	
	; some other instructions that use data
	
	return
}

Re: Is it a bad idea to use global objects like this?

Posted: 05 May 2017, 21:47
by Soft
I don't think it's a bad idea, as long as it's not conflicting with other codes.
Defining super global variable/object can be useful on certain circumstances.