Put RGB colors into List

I am trying to put a some RGB colors into a list that I can transfer between functions but all I get is the first value of the RGB stored in each item

put colorAtLocation(100,100) into tempColor1
put colorAtLocation(110,100) into tempColor2
log "tempColor1 = " & tempColor1
log "tempColor2 = " & tempColor2
put tempColor2 as item 2 into tempList
log "tempList = " & tempList

return tempList <-- To pass to various other scripts

log tempColor1 = 255,0,0
log tempColor2 = 0,255,0
log tempList = (255, 0)

It seems something got changed in copying your script into the message, because this line doesn’t make any sense and won’t compile, so I can’t really tell exactly what you’re doing wrong:

put tempColor2 as item 2 into tempList

However, to answer your question, you can easily return a list of two colors, like this:

return (tempColor1, tempColor2)

Or, if you are actually capturing a number of colors, you might prefer to use the insert command (NOT put) to add each color to a list, like this:

insert colorAtLocation(100,100) nested into tempList
insert colorAtLocation(110,100) nested into tempList
return tempList

The word “nested” is needed since each color (in standard RGB format) is itself a list. Alternatively, you could set the listInsertionMode to “nested” to change the default behavior of the insert command, or set the colorFormat to use one of the text color formats rather than the basic list format.