Proper Syntax For Accessing Array Elements Of A Variable

There are a few places I’ve tried to use array elements without success:

Log ‘Coords = "%Variable%Coords%"’
Log ‘%Variable%Coords% contains %Variable%Coords[0]% and %Variable%Coords[1]%’
Click at (Coords[0],Coords[1]) from the Absolute Position

The LogFile shows:

2014-10-09 10:18:05 Log: Coords = "1656,520"
2014-10-09 10:18:05 Log: 1656,520 contains %Variable%Coords[0]% and %Variable%Coords[1]%
2014-10-09 10:18:10 Move or Click Mouse calculation Coords[0] failed.
2014-10-09 10:18:10 Move or Click Mouse calculation Coords[0] failed. Macro ‘Trying’ cancelled (while executing Move Mouse to (Coords[0],Coords[1]) from the Absolute Position).

Neither Set Variable To Text and Set Variable to Calculation seem to interpret array notation as I’d expect.
What is the correct syntax for accessing array elements in these instances?

Hey Montgomery,

I haven't fiddled with arrays, but a quick test on my system works fine.

The disabled item is just for show, but it works too.

The click action works as expected.

-Chris

1 Like

Ah, right! I’d forgotten that arrays were indexed starting at 1, not 0. Since all my tests used a temp[0], they all failed.

Thanks!

%Variable%Coords[1]% will not work because array access is only supported within calculations.

So you can use this in text fields: ***%Calculate%Coords[1]%***, or within a calculation field: ***Coords[1]***.

1 Like