Linebreaks

Hello guys,

I want to paste a specific text to an internal email app.

The script is:



set AppleScript's text item delimiters to {return & linefeed, return, linefeed, character id 8233, character id 8232}
set mytext to "Order number: " & ordernumber & "\nDate: " & ddate & "\nDelivery number: " & delnumber & "\n\nHello " & name & ","



set the clipboard to mytext
tell application "System Events" to keystroke "v" using command down


However the text is pasted without line breaks when the script is executed.

The interesting thing is that elsewhere (Notes, Word, etc) it works as expected, only in the specific internal mail app I see it a single line. Is there any other workaround?

Hi, have you tried using a CR, like:

 ordernumber & (return) & "Date: "

Hi,

Thanks for your reply. Yes, I had tried with the return keys but no luck.

Then hopefully I thought of splitting the text to lines and deployed the following solution, which is not optimal but at least it works:

set the clipboard to myline1
				delay 0.4
				tell application "System Events" to keystroke "v" using command down
				tell application "System Events" to key code 36
				set the clipboard to myline2
				delay 0.2
				tell application "System Events" to keystroke "v" using command down
				tell application "System Events" to key code 36
				set the clipboard to myline3
				delay 0.2
				tell application "System Events" to keystroke "v" using command down
				tell application "System Events" to key code 36
				tell application "System Events" to key code 36
				set the clipboard to myline4

You can also use:

ASCII character 10 --LF LineFeed
or
ASCII character 13 --CR CarriageReturn

I tried them both but unfortunately no luck… :frowning:

I don’t know why you are talking about “Text Item Delimiters”.
No where in the code are you converting text to a list or vice-versa.
So it is completely irrelevant.

Or am I missing something?

Did you try:

set mytext to "Order number: " & ordernumber & return &  "Date: " & ddate & return & "Delivery number: " & delnumber & return & return & "Hello " & name & ","

set the clipboard to mytext
tell application "System Events" to keystroke "v" using command down

Thanks for the reply.

Yes, I had tried that as well. Both the (return) and the “\n” without luck.

But as I mentioned above, I splitted the text to lines and so the new script (third post) pastes them one by one as I wanted.

You gave up quickly. Your solution is awkward for several reasons.

You tested your internal mail app with return(/r), then with linebreek(/n) , but haven’t tried combining them yet. Combination /r/n is not uncommon in internal applications. So, try this, maybe it works:


set {ordernumber, ddate, delnumber, |name|} to {102, current date, 355, "Mike"}

set mytext to ¬
	"Order number: " & ordernumber & return & linefeed & ¬
	"Date: " & ddate & return & linefeed & ¬
	"Delivery number: " & delnumber & return & linefeed & ¬
	return & linefeed & ¬
	"Hello " & |name| & ","

Oh wow!

Indeed awkward but temporary!

I did not give up, I was just waiting for you! :smiley:

For one more time you saved my time and you proved your talent!

Thank you so much man! Efcharisto!!!

PS: One other workaround that I just discovered accidentally is the combination Shift + Enter!