my script is generating a list (random number of items) and for each item I like to add a colour.
I can do it manually :
> set myList to {{"demo", "#5cdf64"}, {"icloud.com", "#FFFF00"}, {"more
> random e.g", "#FF0000"}}
but how can I add a different colour automatically to the list and based on the number of item on the first list?
I know how to count the primary list and do an action for each items :
set listSize to count of myList
set theList to {"demo", "demo1", "demo2", "demo2"}
repeat with a from 1 to length of theList
set theCurrentListItem to item a of theList
-- Process the current list item
end repeat
I think I'm nearly there the only thing is I'm not adding but replacing the items :
set theList to {"Demo", "ok", "blabla", "demo2"}
set ColortheList to {"5cdf64", "FFFF00", "FF0080", "FF1000"}
set myNewList to ""
repeat with a from 1 to length of theList
set theCurrentListItem to item a of theList
set myNewList to {item a of theList, item a of ColortheList}
end repeat
also tried
copy {item a of theList, item a of ColortheList} to myNewList
Best Answer
If you're wanting
myNewList
to return a list of lists I think you're trying to do:A little fun with
random number
. You can modify the color selection and then randomly add to a list:If you're wanting a string approach try:
The above can be modified in the
result
. Let me know if I'm understanding you or if you're needing something different.