Macros in 2.5

Have a problem? A question? This is the place for answers from other Express users.
midwinter
Posts: 333
Joined: 2004-09-09 18:07:11
Location: Utah
Contact:

Re: Speaking of the space

Post by midwinter »

Jzents wrote:I have some macros that I wrote to add "canned" comments to papers I am grading. I do not want them to add a space in front of the pasted text, but they do. Does anyone know a trick to make that stop or is that the bug reappearing in a new place.
Would you be willing to share? I used to have a ton of macros in Word that did this (assigned to fn keys) and miss them in NWE.
Jzents
Posts: 49
Joined: 2005-08-03 12:17:16
Location: USA

Re: Speaking of the space

Post by Jzents »

midwinter wrote:
Jzents wrote:I have some macros that I wrote to add "canned" comments to papers I am grading. I do not want them to add a space in front of the pasted text, but they do. Does anyone know a trick to make that stop or is that the bug reappearing in a new place.
Would you be willing to share? I used to have a ton of macros in Word that did this (assigned to fn keys) and miss them in NWE.
Sure, happy to. Email me at me address in the signature line and I will send you a .zip file with them in it. Cheers!
Jeffrey Zents
jzents@mac.com
User avatar
Matze
Posts: 170
Joined: 2004-12-14 07:54:49
Location: Düsseldorf Germany
Contact:

Re: creating Macros

Post by Matze »

cgc wrote:
How often do you do this? Just curious...
In NWClassic I have got a Shortcut assigned to the Macro "Transpose the Two"

//==================== MACRO Transpose the Two
// Assuming two things are non-contiguously selected, this will transpose them, putting each in the place of the other

s->push(startends)
if(s->size!=4) goto warn
4
setselect(s[3],s[4])
MacroCopy
setselect(s->pop,s->pop)
Swap Paste
setselect(s->pop,s->pop)
Paste
0
exit

warn:
beep
:1 "This macro requires two non-contiguous selections."
exit

because I very often change the position of words, sentences and paragraphs. Probably ten times a day.

This is quiet an advanced macro, but the trandposing of two letters in NWC is a laugh to create.

Find Next "\(.\)\(.\)" "oO-SAir-wt-Gg"
Replace With "\2\1" "oO-SAir-wt-Gg"

Via the Marcoize button.

What would I give for an easy Macro language in NWE and a Macroize Button in F/R.

Best, Matze
User avatar
Matze
Posts: 170
Joined: 2004-12-14 07:54:49
Location: Düsseldorf Germany
Contact:

Re: Missing an integrated macro language

Post by Matze »

dshan wrote:But if NWX had it's own scripting language you'd still have to "learn another programming language": NWX's language.
Hello dshan!

I have to disagree here.

Learning NWCs Macro language was nothing compared to learning PERL.
The most macros I have written for NWC were done by typing menucommands into the macrofile or use some Find/Replace Expressions (via the Macroize-Button.)
Reading the Macro Chapter in Joe Kissels The Nisus Way and you had the skills for writing very helpfull macros.

To do that in Perl you just have to study programming!

Best, Matze
riccardo
Posts: 15
Joined: 2005-05-30 09:09:28
Location: Maine

How much pain for how much gain?

Post by riccardo »

Learning NWCs Macro language was nothing compared to learning PERL.
This is somewhat my point. In Word for instance, there's a lot of help for people who are somewhat computer savy, but don't write code 24/7. You can record macros to get the basic syntax, then you can edit the resulting macro to add any more specific customization. If you want more ideas on a function or command, it's only a click away in the help file. I could go on...

Perl is apparently a good and popular programming/scripting language, but you have to learn an awful lot about it before you can use it -- not an investment of time that all writers might want to justify. Just having a macro recorder in Nisus would be a great help.
dshan
Posts: 334
Joined: 2003-11-21 19:25:28
Location: Sydney, Australia

Re: creating Macros

Post by dshan »

Matze wrote: In NWClassic I have got a Shortcut assigned to the Macro "Transpose the Two"

//==================== MACRO Transpose the Two
// Assuming two things are non-contiguously selected, this will transpose them, putting each in the place of the other

[Deleted]

because I very often change the position of words, sentences and paragraphs. Probably ten times a day.

This is quiet an advanced macro, but the trandposing of two letters in NWC is a laugh to create.

Find Next "\(.\)\(.\)" "oO-SAir-wt-Gg"
Replace With "\2\1" "oO-SAir-wt-Gg"
Matze,

I can't see how to transpose two non-contiguous selections with a NWX Perl macro alas (if anyone does know how I'd like to see the code). Non-contiguous selections seem to be copied to the clipboard (and then passed to Perl) by NWX as one contiguous string and you can't paste/replace into noncontiguous selections from the clipboard either unfortunately.

However, your second macro - to transpose selected contiguous characters (two or more) - is easy to do in Perl:

Code: Select all

#Nisus Macro Block
#source clipboard
#destination clipboard
#Before Execution
#Copy
#After Execution
#Paste
#End Nisus Macro Block

while (my $line = <>) {
    print (join("",reverse(split(//, $line))));
}
User avatar
Matze
Posts: 170
Joined: 2004-12-14 07:54:49
Location: Düsseldorf Germany
Contact:

Re: creating Macros

Post by Matze »

Hi dshan,
dshan wrote: I can't see how to transpose two non-contiguous selections with a NWX Perl macro alas

oh, I didn't want to make you think about how to write this macro in PERL, I just wanted to give an example how easy it is to write macros in NWC and how difficult in Perl/NWE
dshan wrote: However, your second macro - to transpose selected contiguous characters (two or more) - is easy to do in Perl:

Code: Select all

#Nisus Macro Block
#source clipboard
#destination clipboard
#Before Execution
#Copy
#After Execution
#Paste
#End Nisus Macro Block

while (my $line = <>) {
    print (join("",reverse(split(//, $line))));
}
Great, I thank you very much for this one!

But it also proofs my point: Perl is difficult, NWC macro language is easy!

Loads of parantheses, many different commands, a syntax that doesn't explain itself immediately.

The NWC macro on the other hand can be created by just using the Find/Replace Window. In power find or pf pro choose two characters each in parantheses from the F/R menu for "Find" and "Found2 Found1" from the same for Replace, hit the Macroize button, give the macro a name, and you're done!

I hope, that this will be availabe in NWE sometimes.

Best, Matze
Post Reply