Newbie Q - Edit box and indexes

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
globalzen
Posts: 2
Joined: 19 Feb 2018, 20:37

Newbie Q - Edit box and indexes

19 Feb 2018, 20:55

I want to type in a number into an edit box and use it as an index to an array.
Could someone let me know why it doesn't work


::!H::
Array := []

myVar := 1

Array.push("Dog")
Array.push("cat")
Array.push("mouse")

MsgBox % Array[myvar]

; so far so good
; everything up to here works.

Gui, New
Gui, Add, Text,, varid
Gui, Add, Edit, vvarid
Gui, Add, Button, Default gRunMe, OK
Gui, Show
return
OK:
Gui, Submit
MsgBox %Username%
return
RunMe:
Gui submit
MsgBox % changing val to a varid
myvar := %varid%
;This line does not show what I expect.
MsgBox % Array[%myvar%]

return
User avatar
tomoe_uehara
Posts: 213
Joined: 05 Oct 2013, 12:37
Contact:

Re: Newbie Q - Edit box and indexes

19 Feb 2018, 21:17

Maybe this?

Code: Select all

::!H::
Array := []

myVar := 1

Array.push("Dog")
Array.push("cat")
Array.push("mouse")

MsgBox % Array[myvar]

; so far so good
; everything up to here works.

Gui, New
Gui, Add, Text,, varid
Gui, Add, Edit, vvarid
Gui, Add, Button, Default gRunMe, OK
Gui, Show
return
OK:
Gui, Submit
MsgBox %Username%
return
RunMe:
Gui submit
MsgBox changing val to a varid
myvar := varid
;This line does not show what I expect.
MsgBox % Array[myvar]

return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 413 guests