The code below works. It returns the list variable in the results tab of the script editor. I want to write that to a text file.
set A to text set B to text set C to text set D to text set E to text set F to text set G to text set H to text set I to text set J to text set K to text set L to text set M to text set N to text set O to text set P to text set Q to text set R to text set S to text set T to text set U to text set V to text set W to text set X to text set Y to text set Z to text set Alphabet1 to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"} set Alphabet2 to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"} set Alphabet3 to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"} set IdleLoop2 to "set value of cell (µ∑†∏µ & LastRowCrypto + 1) to current¥Price" set findText3 to "∑" set findText4 to "†" set findText5 to "∏" set findText6 to "¥" set ListOfExcel to {} repeat with A from 1 to length of Alphabet1 set replaceText4 to item A of Alphabet1 set newText4 to do shell script "sed 's|" & quoted form of findText3 & ¬ "|" & quoted form of replaceText4 & "|g' <<< " & quoted form of IdleLoop2 copy newText4 to the end of ListOfExcel end repeat repeat with B from 1 to length of Alphabet2 repeat with D from 1 to 26 set IdleLoop3 to item D of ListOfExcel set replaceText5 to item B of Alphabet2 set newText5 to do shell script "sed 's|" & quoted form of findText4 & ¬ "|" & quoted form of replaceText5 & "|g' <<< " & quoted form of IdleLoop3 copy newText5 to the end of ListOfExcel end repeat end repeat repeat with C from 1 to length of Alphabet3 repeat with E from 27 to 53 set IdleLoop4 to item E of ListOfExcel set replaceText6 to item B of Alphabet3 set newText6 to do shell script "sed 's|" & quoted form of findText5 & ¬ "|" & quoted form of replaceText6 & "|g' <<< " & quoted form of IdleLoop4 copy newText6 to the end of ListOfExcel end repeat end repeat return ListOfExcel I've tried this:
set the logFile to ((path to desktop) as text) & "DOG.txt" set the logText to ListOfExcel try open for access file the logFile with write permission write (logText & return) to file the logFile starting at eof close access file the logFile on error try close access file the logFile end try end try And tried this:
do shell script "echo " (I forgot the rest) And tried this:
write ListOfExcel to textFile But those ideas don’t seem to work.
I just don't understand the things necessary to change the format of the list variable, how to call the text file into existence with permissions and have AppleScript write to that file.
21 Answer
After reviewing what the working script in your OP and its contents for the ListOfExcel list, I'm not sure why you would want to write that to a file, however, assuming you want to write the contents of the ListOfExcel list to a file as text, then replace return ListOfExcel in the working code shown in your OP with the following example AppleScript code, which is using the variables shown in your OP:
set the logFile to ((path to desktop) as text) & "DOG.txt" set {TID, AppleScript's text item delimiters} to ¬ {AppleScript's text item delimiters, linefeed} set logText to ListOfExcel as text set text item delimiters to TID writeToFile(logText, logFile, true) on writeToFile(theData, theFile, overwriteExistingContent) try set theFile to theFile as string if theFile contains "/" then set theOpenedFile to open for access theFile with write permission else set theOpenedFile to open for access file theFile with write permission end if if overwriteExistingContent is true then set eof of theOpenedFile to 0 write theData to theOpenedFile starting at eof close access theOpenedFile return true on error try close access file theFile end try return false end try end writeToFile Notes:
The writeToFile(theText, theFile, overwriteExistingContent) handler is a slightly modified handler from: Reading and Writing Files
The handler from the linked Apple support document was modified to handle both POSIX and HFS+ file paths, and its name was changed too.
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.