Pasting from Clipboard Line by Line  SOLVED

User-to-User discussion about the PhraseExpress macro programming.
Post Reply
SandBird
Posts: 2
Joined: 11 May 19, 22:07

Pasting from Clipboard Line by Line

Post by SandBird » 11 May 19, 22:17

Hello,
I have searched the forms briefly but with no luck.

What I am trying to do is to paste line at a time from clipboard.
Scenario steps:
1. Copy a multi line text (a list) to the clipboard.
2. Use a hotkey to paste the first line.
3. Using the same hotkey again, will paste the 2nd line from that same clipboard and so on.

Is it possible?

Any help would greatly appreciated.

Thanks in advance!

Using PhraseExpress Free 14.0.139f for Windows

Peter Stotz
PhraseExpress Expert
Posts: 880
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 13 May 19, 06:24

My suggestion:

Code: Select all

(* 20190513 • Outputs the currently first line of the clipboard content
   Delete empty lines from the clipboard (RegEx)
*){#setclipboard {#trim {#regexrep -text {#insertclipboard} -expr ^\h*\R -repexpr }}{#asc 13}}(* 
  Output line 1 of the current clipboard content
*)»{#trim {#substr {#insertclipboard} -from 1 -count {#calc {#pos {#insertclipboard} -substr {#asc 13}}-1 -round 0}}}«(* 
  Remove line 1 from clipboard content
*){#setclipboard {#substr {#insertclipboard} -from {#calc {#pos {#insertclipboard} -substr {#asc 13}}+1 -round 0} -count }}
The best way to use the macro program is to assign a hotkey to it.
Peter
Windows 10 - PhraseExpress v14.0.143

SandBird
Posts: 2
Joined: 11 May 19, 22:07

Post by SandBird » 13 May 19, 06:34

Hello Peter,

Thank you so much, simply amazing - this works!

mh348
Posts: 13
Joined: 29 Aug 18, 10:30

Post by mh348 » 16 Feb 20, 11:09

Hi Peter, is there any way to adapt this to paste the 3rd paragraph only from the clipboard?

Also if possible for the code to work on PE Android & Windows..

I'm basically copying a tweet which has mentions to other twitter users (all start with a @ sign) and a url, so Alternatively if not all macro functions are supported on Android (to copy exact paragraph), then if the code can just strip out all mentions (all words starting with @) and all urls.

Example text/tweet I copy:

ExampleA

Code: Select all

#UPDATE 1

Date: 16 February 2020

Today's update is as follows, hello sample text
@Peter @mh348
@John @ JaneDoe https://www.phraseexpress.com/docsa2/09/manual.htm
ExampleB

Code: Select all

#UPDATE 2
Date: 16 February 2020

For today the following occurred

@Peter @mh348 @John @ JaneDoe https://www.phraseexpress.com/docsa2/09/manual.htm
I only need the text
ExampleA "Today's update is as follows, hello sample text."
ExampleB "For today the following occurred"

Each days wording is different

Peter Stotz
PhraseExpress Expert
Posts: 880
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 16 Feb 20, 19:19

@mh348
This code for Windows extracts the 3rd paragraph from the clipboard:

Code: Select all

(* 20200216 • Select the 3rd paragraph from the clipboard content
  1. Delete empty lines from the clipboard (RegEx)
*){#setclipboard {#trim {#regexrep -text {#insertclipboard} -expr ^\h*\R -repexpr }}{#asc 13}}(*
  2. Remove the 1st and 2nd paragraph from the clipboard content
*){#loop {#setclipboard {#substr {#insertclipboard} -from {#calc {#pos {#insertclipboard} -substr {#asc 13}}+1 -round 0} -count }} -count 2}(*
  3. Select the 3rd paragraph for output
*){#trim {#substr {#insertclipboard} -from 1 -count {#calc {#pos {#insertclipboard} -substr {#asc 13}}-1 -round 0}}}
Peter
Windows 10 - PhraseExpress v14.0.177

Mamede
Posts: 21
Joined: 07 Apr 18, 13:47

Post by Mamede » 29 Feb 20, 13:11

Hi Peter,
Is there any way to adapt past line by line from clipboard to paste from clipboard paragraph by paragraphe
IE:
1. Copy a multi paragraphe text to the clipboard.
2. Use a hotkey to paste the first paragraphe.
3. Using the same hotkey again, will paste the 2nd paragraphe from that same clipboard and so on.

Thanks in advance

Using PhraseExpress 14 Pro.

Mamede

Peter Stotz
PhraseExpress Expert
Posts: 880
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 29 Feb 20, 17:14

@Mamede
The macro program 'Insert line by line from the clipboard' interprets character strings that end with a line feed (Enter key with code CR = {#asc 13}) as lines.
However, this also corresponds to the definition of paragraphs.
Therefore 'Insert line by line from the clipboard' is identical to 'Insert paragraph by paragraph from the clipboard'.

Using the macro program of my above posting from Mo 13. May 2019, 07:24 :
1. Copy with CTRL+C a multi paragraph text to the clipboard.
2. Use a hotkey to paste the first paragraph.
3. Using the same hotkey again, will paste the 2nd paragraphe from that same clipboard and so on.

Peter
Windows 10 - PhraseExpress v14.0.177

Mamede
Posts: 21
Joined: 07 Apr 18, 13:47

Post by Mamede » 01 Mar 20, 11:32

Hi Peter
Thank you very much.
I didn't initially understand
faithfully

Mamede
Posts: 21
Joined: 07 Apr 18, 13:47

Post by Mamede » 05 May 20, 10:50

Hi Peter
When the texte copied to clipboard contain many pages , the macro pasting from Clipboard Line by Line dont work
the text copied should not exceed one page
does the macro must be modified
faithfully
Mamede

Peter Stotz
PhraseExpress Expert
Posts: 880
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 06 May 20, 17:00

Hello, Mamede
you wrote: Macro output fails "if the text copied to the clipboard contains many pages".
But a long text should not be a problem ...

I rather suspect another reason:
Macro output might fail because the selected text contains curly braces { } and/or PhraseExpress code snippets.
This will cause the output of the macro to abort.
Can you check that, please?

Peter
Windows 10 - PhraseExpress v14.0.183
Translated with www.DeepL.com/Translator

Post Reply