Copying single element from array to named clipboard

EDIT: I found my mistake… arrays start at 1, not 0 :’(

Disclaimer: This is my first post and I’ve only had KM for a few hours

I have set up a variable as username1,username2,username3 … etc.
I want to copy the username1 to the clipboard, paste it somewhere else, then copy username2 and repeat.

What I’ve done currently is make a loop with a new variable i and set i = 0.
Then I tried to access the first element of the array by doing VariableName[i], but that didn’t work. I also tried %VariableName%i% but that didn’t work also. I think my problem is syntax.

I should note I then go on to perform the actions and then I increment i=i+1.

You might try something like this:

###MACRO:   @LIST Process Items in a List [Example]

~~~ VER: 1.0    2016-12-28 ~~~

@LIST Process Items in a List [Example].kmmacros (3.5 KB)

1 Like

@JMichaelTX’s solution is a good one.

You can also use the new %Variable% array facility (new in 7.2+) to access a variable as if it is a comma separated array of text using the notation %Variable%[3]% where 3 can be any Calculations. You can use a different item separator by putting the text between the ] and % characters, eg %Variable%[3]:%. Arrays are indexed starting from 1.

Alternatively, you can use the For Each action directly with the substrings facility:

1 Like