KevinCork KevinCork - 4 months ago 10
AppleScript Question

Applescript saving each item from a list as text

I have a list of numbers (the number of numbers is random)

for example here is my current result :

Result:
{"1024343495", "84734348416", "100434439171", "86343425", "13434290", "83434946", "81711343497", "43534347319", "863434490"}


I would like to print them in a text file, or save in the clipboard, but this is not working

set the clipboard to myList


so I tried to convert the all as a string :

set the clipboard to myList as string


but then I have just a huge number :
1024343495847343484161004344391718634342513434290834349468171134349743534347319863434490

Answer

try

set myString to ""
set i to 0
repeat (number of items in myList) times
    set i to i + 1
    set myString to myString & ((item i of myList)as string) &  ", "-- this last bit here is what goes in between each list item
end repeat
return myString

result "1024343495, 84734348416, 100434439171"-etc