This question already has an answer here:
- Incremental variable definition 2 answers
I'm using AutoIt:
$1 = GetItemBySlot(1, 1)
$2 = GetItemBySlot(1, 2)
$3 = GetItemBySlot(1, 3)
$4 = GetItemBySlot(1, 4)
$5 = GetItemBySlot(1, 5)
The code repeats for 40 lines. How can I shorten it?
As per Documentation - Intro - Arrays:
Example in
GetItemBySlotMulti()
(untestes, no error-checking):Related.
You could shorten this by using Assign() and Eval().
That would be 3 lines instead of n lines. During runtime this will be expanded to:
To get the data of those variables you need to use the
Eval
function. Soreturns the value of
GetItemBySlot(1, $i)
.