I have combed through the search results “read text” in AppleScript | OS X for probably a good 2 hours to no avail.
What I want applescript to do is create a list from text returned from a file. Problem with the code I am using is it only returns the first two characters and in reverse.
tell application "Finder" to get folder of (path to me) as Unicode text
set workingDir to POSIX path of result
set theFile to workingDir & "hashtag.txt"
read theFile
set hashtaglist to result as list
The location of hashtag.txt may change from system to system depending on the users personal preference. However, it will always be located in the same place as the script. I currently have hashtag.txt formatted as follows:
#whitenoice
#tips
#broken
#sarcasm
When I run the above script I get the following results:
{"w#"}
Later on in the script I plan to implement the following:
choose from list hashtagist with prompt "Please select #hashtag"
set choice to result as text
So having a list is a must.
Model: MacBook Pro
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)
tell application "Finder" to set workingDir to get folder of (path to me) as Unicode text
set theFile to workingDir & "hashtag.txt"
set hashtaglist to paragraphs of (read file theFile)
The read command expects the file reference number, alias, or file reference of the file to read as a direct parameter. Not a POSIX path. To get every paragraph, you can easily request it with plain English.
choose file -- returns an alias
read result
get every paragraph of result -- returns list
this is in response to the first response.
trying second response now…
edit+
While the choose method works I would prefer if the user wasn’t prompted. Which is why I tried setting the location of the file. Anyway to get it to work by setting the location in the script?