I have Dropbox file with two lines of data that I'd like to parse into two variables. The following function should have the right logic but doesn't seem to work:
set versionFile to do shell script ("curl -L 'https://www.dropbox.com/s/5eugzgr1alfgsp9/version.txt?dl=1'")
set lineDelimiter to read versionFile using delimiter return
repeat with oneLine in lineDelimiter
if length of oneLine is greater than 0 then
set variable to oneLine
log "variable: " & variable
end if
end repeat
Error:
error "Can’t make \"1.0.0.2
www.example.com/download-link-here\" into type file." number -1700 from "1.0.0.2
www.example.com/download-link-here" to file
Any help is greatly appreciated. Cheers.
Best Answer
As coded,
versionFile
is a variable that contains the contents of the file not the file itself and you're using theread
command improperly, as it reads data from a file, not a variable.Change:
To:
Results:
Since the
versionFile
variable contains the text contents of the file, then in this case to work with it, use the elements of text objects, one of which isparagraph
and in the context defined as: