1

I have created a 'choose from list' in Applescript where the choices are lines in a .txt file. It looks like this:

set listofUrls to {}
    set Urls to paragraphs of (read urlList)
    repeat with nextLine in Urls
        if length of nextLine is greater than 0 then
            copy nextLine to the end of listofUrls
        end if
    end repeat
    choose from list listofUrls with title "Refine URL list" with prompt "Please select the URLs that will comprise your corpus." with multiple selections allowed

This works very nicely, and if I 'return result', I get a list in the results window in the formal "urlx", "urlb" etc.

The problem is thaat when I try to save this list to a textfile, with, for example:

write result to newList

the formatting of the file is bizarre:

listutxtÇhttp://url1.htmlutxtÇhttp://url2.htmlutxt~http://url3.htmlutxtzhttp:// ...

It seems that null characters have been inserted, too. So, does anybody know what's going on? Can anybody think of a way to either:

a) write results as clean (preferably newline delimited) txt? b) clean this output so that it is back to normal?

Thanks for your time! Daniel

4

1 回答 1

0

没有看到你要写入文件的内容我认为你只需要将结果转换为带有段落的字符串

伪代码

set listofUrls to {}
set urlList to ":Users:loaner:Documents:urllist.txt" as alias
set Urls to paragraphs of (read urlList)
repeat with nextLine in Urls
    if length of nextLine is greater than 0 then
        copy nextLine to the end of listofUrls
    end if
end repeat
choose from list listofUrls with title "Refine URL list" with prompt    "Please select the URLs that will comprise your corpus." with multiple selections allowed

set choices to the result
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set list_2_string to choices as text
set AppleScript's text item delimiters to tid
log list_2_string
write list_2_string to newList
于 2013-06-18T16:56:15.197 回答