Kevin
Kevin

Reputation: 1106

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

Upvotes: 0

Views: 388

Answers (2)

vadian
vadian

Reputation: 285260

You can use your code after setting text item delimiters accordingly.

set myList to {"1024343495", "84734348416", "100434439171", "86343425", "13434290", "83434946", "81711343497", "43534347319", "863434490"}
set {TID, text item delimiters} to {text item delimiters, ", "}
set the clipboard to myList as text
set text item delimiters to TID

Upvotes: 1

Pro Blaster
Pro Blaster

Reputation: 491

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

Upvotes: 1

Related Questions