Creating a Multiple Line Text File

Sorry all, I have a very basic question.

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

Sorry for the basic question…I’ll get there.

Thank you in advance!

Okay, how about this…

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

Thanks again in advance

heres I snippet, I don’t have nay links to give you but I suggest O’rielys Applescript the definitive guide


	open for access theFile with write permission
	write (theData & return) to theFile starting at eof
	close access jobLog

you were on the right track though

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.

set theData to ("1 " & TheJob & " " & TheJob & “proda” & “” & TheJob & “prodb” & " & jobQty & "
" & return)

Another way is to write twice:

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.

gl,

mcgrailm,

I didn’t see the return in your script when I first read this thread.

gl,

You guys are great! I really do appreciate it!