Hellp with A_Index

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Draken
Posts: 53
Joined: 08 Dec 2022, 01:19

Hellp with A_Index

Post by Draken » 08 Dec 2022, 01:25

Hello, please help with the following code, the result should be displaying

11 - 22
22 - 33
33 - 44

Thank you

Code: Select all

X1 = 11
X2 = 22
X3 = 33
X4 = 44

Loop, 3
{
	;C := A_Index+1
	MsgBox, % X%A_Index% " - " X%A_Index+1%
}
return

User avatar
Chunjee
Posts: 1435
Joined: 18 Apr 2014, 19:05
Contact:

Re: Hellp with A_Index

Post by Chunjee » 08 Dec 2022, 02:18

dynamic variables are so 2002; ahk has real arrays now.

Code: Select all

myData := [11, 22, 33, 44]

Loop, 3 {
	msgbox, % myData[A_Index] " - " myData[A_Index + 1]
}
; => 11 - 22
; 22 - 33
; 33 - 44

Draken
Posts: 53
Joined: 08 Dec 2022, 01:19

Re: Hellp with A_Index

Post by Draken » 08 Dec 2022, 02:36

Chunjee wrote:
08 Dec 2022, 02:18
dynamic variables are so 2002; ahk has real arrays now.

Code: Select all

myData := [11, 22, 33, 44]

Loop, 3 {
	msgbox, % myData[A_Index] " - " myData[A_Index + 1]
}
; => 11 - 22
; 22 - 33
; 33 - 44
Thank you very much for your help, I am working with dynamic variables, is there any way to work with them or rewrite the rest of the script and use arrays?

just me
Posts: 9495
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Hellp with A_Index

Post by just me » 08 Dec 2022, 02:51

You were rather close:

Code: Select all

X1 = 11
X2 = 22
X3 = 33
X4 = 44

Loop, 3
{
	I2 := A_Index+1
	MsgBox, % X%A_Index% " - " X%I2%
}
return

Post Reply

Return to “Ask for Help (v1)”