I am currently working on a project where I want to capture comments and preferences for certain files and projects. I would like to create simple text files for each project listing these features.
Everytime I put these into applescript it writes one extremely long line into the text file.
I would like to know how to tell applescript to “hit return” or insert a line break before the next entry of data.
ie.
Line 1 - File name Date Task
Line 2 - File name2 Date2 Task2
as opposed to:
Line 1 - File name Date Task Line 2 - File name2 Date2 Task2
Could someone please direct me to a beginner site so I can figure this out?
Sampling of script where I need line break:
set theData to ("1 " & TheJob & " " & TheJob & “proda” & “” & TheJob & “prodb” & " & jobQty & "
") as string
set theFile to open for access (data_folder & TheJob & “.txt”) with write permission
write theData to theFile
close access theFile
You can add line endings several ways. But first, you can use linefeed or carriage return. To use carriage return, you can concatenate it to the string. Here, I added it at the end.
write theData to theFile starting at eof
write return to theFile
This writes a return after the firstt write. Or you can write it before:
write return to theFile starting at eof
write theData to theFile
When writing twice like this, you don’t need to write starting at eof again, because the file marker moves to the after the end of the last read/or write.
If you write to a TextEdit file, you might want to use linefeed instead. By default, TextEdit uses linefeed (ascii character 10). So, you would use this instead of return.