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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
magicinmath
Posts: 162
Joined: 12 Apr 2017, 23:03

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

05 May 2017, 21:29

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
}
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

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

05 May 2017, 21:47

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.
AutoHotkey & AutoHotkey_H v1.1.22.07

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: SmithyZoomZoom and 160 guests