Code: Select all
global a,b,c,d,e
SetGlobal(varName, varVal) {
global %varName%
%varName% := varVal
}
Code: Select all
global a,b,c,d,e
SetGlobal(varName, varVal) {
global %varName%
%varName% := varVal
}
It is for double dereferencing, which is what OP was going for. As in the following:
Code: Select all
#Requires AutoHotkey v2.0
VarName := "MyVar"
MyVar := "hello"
MsgBox %VarName% ; output is "hello"
Code: Select all
checkBoxObj := MyGui.Add("CheckBox", "vAutoConfirmNoPicsLoaded " . (checked:=AutoConfirmNoPicsLoaded ? "checked" : ""), "Automatisch die Meldung 'Keine neuen Bilder' quittieren.")
checkBoxObj.OnEvent("Click", SaveCheckboxSetting.Bind(, , sectionName:="Auto Confirm No Pics Loaded Message", IniFilePath, secondaryFunctionName:="DoSomeMoreStuff"))
Code: Select all
; saves the setting of a checkbox/textbox/combobox to a given ini-File
; - ctrlObj: the control Object whose value needs to be saved
; - SectionName: the name of the section under which the setting needs to be saved in the ini-file
; - FilePath: the path to an ini.File
; - optional SecondaryFunctionName: the name of a function to be called after this one - with the value of the control as a paramenter
SaveCheckboxSetting(ctrlObj, info, SectionName, FilePath, SecondaryFunctionName:="") {
global IniFilePath
OutputDebug("SaveCheckboxSetting(GuiName,CheckboxHWND, SectionName, FilePath, SecondaryFunctionName)`n")
; MsgBox, CheckboxHWND:%CheckboxHWND%`nIniHeadingName:%SectionName%`nSecondaryFunctionName:%SecondaryFunctionName%`nFilePath:%FilePath%
FilePath := (FilePath == "") ? IniFilePath: FilePath
controlValue := (ctrlObj.Type == "ComboBox") ? ctrlObj.Text : ctrlObj.Value ; get the value of the checkbox / edit control. if it is a combobox, get it's text
IniWrite(controlValue, FilePath, SectionName, A_UserName) ; write the value to the ini file
if (SecondaryFunctionName != "") { ; call a secondary function if there is one
FuncToBeCalled := %SecondaryFunctionName%.Bind(controlValue)
FuncToBeCalled()
}
}
Code: Select all
global a,b,c,d,e
a := 5
SetGlobal("a", 6)
MsgBox(a)
SetGlobal(varName, varVal) {
varName := varVal
}
Code: Select all
global a,b,c,d,e
a := 5
SetGlobal("a", 6)
MsgBox(a)
SetGlobal(varName, varVal) {
global
%varName% := varVal
}
Code: Select all
global Settings := Map()
Settings["a"] := 5
SetGlobal("a", 6)
MsgBox(Settings["a"])
SetGlobal(varName, varVal) {
global Settings
Settings[varName] := varVal
}