How to get 1st line of text?

Hi,

For a new text macro:

How to get 1st line of text in a file, f ex TextEdit?

I need it to for the file name.

Then I want to save the file with this first line (which is the title).

/
with best regards,
Omar K N
Stockholm, Sweden

Hi,

straight forward


tell application "TextEdit"
	1st paragraph of text of document 1
end tell

Hi StephanK,

I get with this script the error message:

‘Expected end of line but found unknown token.’

I guess that document 1 ( or the name of my document ) has to be better defined, (of folder of other folder.) ?

Maybe you could have another look at it,

with best regards,
Omar K N
Stockholm, Sweden

If there is any open document with at least one line of text the code is supposed to work in TextEdit

Sorry, doesn’t work.

please check if the double quotes in the first line of code are real double quotes (0x22)

Yes they are real quotes, straight down quotes, such as ", but not ".

BTW in:

tell application "TextEdit"¨
1st paragraph of text of document 1
end tell

Shouldn’t there be some kind of command. like read or get…

(But really I’ve have no idea.)

I also wonder where is the AppleScript reference of TextEdit?

with best regards,
Omar K N
Stockholm, Sweden

Hello

I clicked on [Open this Scriplet in your Editor:] in the first message posted by StefanK.
I opened a TextEdit document as StefanK urged you to do.
And, what a surprise, the script did exactly what it was designed to do.

Yvan KOENIG (VALLAURIS, France) samedi 17 mai 2014 21:03:07

Yes - when using the script IT WORKS!

What happened is that I copied the AppleScript and pasted it into the Editor and there must have been some invisibles.

Anyway thanks to StefanK and Mr. Yvan Koenig!

with best regards,
Omar K N
Stockholm, Sweden

(AppleScript is nice and I want to learn more!)