Global variable inside function Topic is solved

Get help for the alpha version of AutoHotkey v2 here. Please state the v2 version you are working with in the title when making a new topic.
Posts: 4
Joined: 10 Aug 2020, 15:18

Global variable inside function

10 Aug 2020, 18:32

I have a problem:

Error: Call to nonexistent function.
236: {
---> 237: Global(%Team%, LV)
238: if (LV.GetNext() = 0)


Code: Select all

MyGui.Add("Button", "x502 y219 w120 h30", "To Lobby 1").OnEvent("Click", (*) => ToLobby("Team1"))

Code: Select all

ToLobby(Team) {
Global %Team%, LV
if(LV.GetNext() = 0) {
MsgBox "Choose account first"
Is it possible to insert a variable into the Global() method ?
Posts: 4142
Joined: 11 Jan 2017, 17:59

Re: Global variable inside function  Topic is solved

12 Aug 2020, 16:03

it might be. if u explain what "inserting a variable into the Global() method" means.
do u have a particular object on which u have define a method called .Global() accepting at least 2 parameters?
do u by "method" mean the "function" Global(), which u are trying to call with command-like syntax(eg Global arg1, arg2)?
do u by "method" mean the "keyword" global, with which u are trying import the variables Team1 and LV from the global scope? or are u trying to leak Team1 into the global scope?

if 3., u cant dynamically import variables. the most u can do is declare ur function assume-global(requiring that u do ur due diligence not to access other globals that u dont need and that u dont leak any locals that ure not supposed to) and simply reference the variable normally, eg

Code: Select all

ToLobby(Team) {

	... := %Team% ; get Team1
	%Team% := ... ; set Team1
	local dontLeakThis := ...

Return to “AutoHotkey v2 Help”

Who is online

Users browsing this forum: No registered users and 5 guests