Reply to topic  [ 4 posts ] 
Simple macro help for newbie 
Author Message

Joined: 2013-09-19 10:50:10
Posts: 2
I'm sorry to be so lazy, but I need two very simple macros to emulate and improve on Word's Cut To Spike feature. I need one macro to Copy Append text to another clipboard (say clipboard 2) without changing the current clipboard. And one to Cut Append text in the same manner.

Thanks in advance,
Millard


2013-09-19 11:14:22
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Hi Millard: these are relatively easy macros to write. Let's look at few ways we might tackle the problem.

1. This code works to quickly change the active clipboard before and after the copy/cut:
Code:
$originalName = Clipboard Name # save current clipboard name so we can restore it
Switch To Clipboard "Clipboard 2"
Append Copy
Switch To Clipboard $originalName
If you want a version that does a cut instead of a copy, just change "Append Copy" to "Append Cut".


2. This code doesn't actually change the active clipboard at any point, instead it directly modifies the clipboard contents:
Code:
$selected = Read Selection
$clipboard = Read Clipboard "Clipboard 2"
$joined = $clipboard & $selected
Write Clipboard $joined, "Clipboard 2"
If you want a version that does a cut, just insert a "Delete" command at the very end.

I hope that helps. Let us know if you have any questions.


2013-09-20 16:21:59
Profile WWW

Joined: 2013-09-19 10:50:10
Posts: 2
Thanks Martin, that is just what I needed. So there is no function to copy or copy append to a non-active clipboard, only write? Also, could you advise a place to start to learn the Nisus' macro language? I used to write simple macros like this with the old Nisus, but it seems very different now. Should I just get a book on Perl? Or is there a better way to get started?

Thanks again,
Millard


2013-09-24 14:57:42
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
miformby wrote:
So there is no function to copy or copy append to a non-active clipboard, only write?

Actually, now that you mention it, the macro language does have a command for that. I just missed it when answering initially. So you could simplify the entire macro to just:
Code:
$selected = Read Selection
Append to Clipboard $selected, "Clipboard 2"

I should point out that the macro language also lets you define your own commands. So if you are writing a macro that appends the selection to a clipboard a lot, you might do something like this:
Code:
Define Command AppendSelectionToClipboard( $clipboardName )
   $selected = Read Selection
   Append to Clipboard $selected, $clipboardName
End

AppendSelectionToClipboard( "Clipboard 2" )



Quote:
Also, could you advise a place to start to learn the Nisus' macro language? I used to write simple macros like this with the old Nisus, but it seems very different now. Should I just get a book on Perl?

I don't think a book on Perl would be too helpful, because these days you don't need to use Perl blocks very often, as the built-in NWP macro language has grown. Unfortunately there aren't any great resources on learning NWP macros. There is the Macro Language References (on the Help menu), but that's really intended primarily as a litany of what the language is capable of, not a teaching tool for beginners.

Sorry to not have a better answer. You can always ask questions or request macros here on the forum and we'll try to help out as best we can.


2013-09-24 17:34:03
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software