I have a function called fillUI() whose main purpose is to fill the UI that has been created. In my original script I need to go over more than 20 Edit Controls and fill them with content. The content is stored inside an array.
The problem that I am facing is that I am unaware of how "return" a global variable with content, whose variable name is made up from a string.
It's like saying myVar1 := "Hello World" is the original variable. Then I point to that variable with varName := "myVar1" and then change it with varName := "foobar" but myVar1 will still be Hello World in the end..
Is such a thing possible?
; Start of script
#SingleInstance Force
FillUI()
Gui, Add, Edit, x12 y9 w350 h30 , %Text_1%
Gui, Add, Edit, x12 y89 w350 h30 , %Text_2%
Gui, Add, Edit, x12 y159 w350 h30 , %Text_3%
Gui, Show, w390 h278, Code testing
return
FillUI() {
words := {1:"Hello World",2:"foobar",3:"lorem ipsum"}
i := 1
while(i <= words.MaxIndex()) {
global variable_name := "Text_" i
word := words[i]
; I need to return a variable here whose variable name needs to be something like "Text_X" and whose content is %word%
; This is in order to fill the UI above
;
; Is this achievable?
variable_name := word
i++
}
}
GuiClose:
ExitApp
return
; End of script