When I tried to run the macro, I receive an error message (see attachment).
In previous versions of NWP I have been able to use it. Has the macro been modified in the last 2 years? IS there an updated macro?
Thanks
Add Remove Blank Lines
Add Remove Blank Lines
- Attachments
-
- Screen Shot 2015-04-02 at 13.53.25.png (32.32 KiB) Viewed 19211 times
iMac 21.5” / MBP 13” Retina
Mac user since 1990
Mac user since 1990
Re: Add Remove Blank Lines
G’day, exegete77 et al
On my system, the current version of the Add or Remove Blank Lines macro is a .nwm file rather than a .pl one:–
$count = Find and Replace ‘\n\n+’, ‘\n’, ‘Eas’
If 0 == $count
Find and Replace ‘\n’, ‘\n\n’, ‘Eas’
End
It works fine when adding or removing blank lines, but one has to remember that it works only on a selection rather than on a whole (non-selected) document. It’s best to include the word “selection” or some other such mnemonic in the macro’s filename in such cases, to avoid the frustration of wondering why nothing happened when the macro was called.
These days, there are very few Perl macros in the Nisus-supplied set. For the record, I invoked one with no problem.
Cheers,
Adrian
On my system, the current version of the Add or Remove Blank Lines macro is a .nwm file rather than a .pl one:–
$count = Find and Replace ‘\n\n+’, ‘\n’, ‘Eas’
If 0 == $count
Find and Replace ‘\n’, ‘\n\n’, ‘Eas’
End
It works fine when adding or removing blank lines, but one has to remember that it works only on a selection rather than on a whole (non-selected) document. It’s best to include the word “selection” or some other such mnemonic in the macro’s filename in such cases, to avoid the frustration of wondering why nothing happened when the macro was called.
These days, there are very few Perl macros in the Nisus-supplied set. For the record, I invoked one with no problem.
Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
macOS Ventura
Nisus Writer user since 1996
Re: Add Remove Blank Lines
Thanks. I cleaned all those pl macros. But I can’t find the Add Remove Blank Lines macro on the NWP web site. Can you post it here?
iMac 21.5” / MBP 13” Retina
Mac user since 1990
Mac user since 1990
Re: Add Remove Blank Lines
I'm not sure that it should really have been necessary to clear out the Perl macros. The Perl version works fine for me (I'm using 2.1.1.beta).
That having been said, there is really no point to that macro being a Perl macro as it consists entirely of Nisus Macro code! The code is exactly as adryan says.
I'm posting it here as a file:
That having been said, there is really no point to that macro being a Perl macro as it consists entirely of Nisus Macro code! The code is exactly as adryan says.
I'm posting it here as a file:
- Attachments
-
Add or Remove Blank Lines.nwm
- (17.59 KiB) Downloaded 927 times
philip
Re: Add Remove Blank Lines
Thanks, Phillip. Downloaded and worked as previously. I did notice a few others NWP asked about updating. So perhaps my macros were a bit out of date.
iMac 21.5” / MBP 13” Retina
Mac user since 1990
Mac user since 1990
Re: Add Remove Blank Lines
In such cases I always start macros with a conditional selection:adryan wrote:one has to remember that it works only on a selection rather than on a whole (non-selected) document. It’s best to include the word “selection” or some other such mnemonic in the macro’s filename in such cases, to avoid the frustration of wondering why nothing happened when the macro was called.
Code: Select all
# conditional selection
$textExpression = Read Selection
if $textExpression == ''
prompt "You need to select some text first …"
exit
End
Re: Add Remove Blank Lines
G’day, Þorvarður et al
Great idea! I’ll use it. Thanks.
Cheers,
Adrian
Great idea! I’ll use it. Thanks.
Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
macOS Ventura
Nisus Writer user since 1996
Re: Add Remove Blank Lines
G’day, all
Actually, I’ve made what I think is an improvement:–
This means that the macro doesn’t abort and then have to be invoked again if you failed to present it with a selection the first time around. It just waits for you to make your selection and then executes any subsequent code.
Cheers,
Adrian
Actually, I’ve made what I think is an improvement:–
Code: Select all
# Ensure something is selected.
$textExpression = Read Selection
If $textExpression == ''
$proceed = Prompt "You need to select some text first…", '', 'OK, I will.'
If $proceed == 'OK, I will.'
While $textExpression == ''
Sleep '1'
$textExpression = Read Selection
End
End
End
Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
macOS Ventura
Nisus Writer user since 1996
Re: Add Remove Blank Lines
Cute trick!adryan wrote:Actually, I’ve made what I think is an improvement:–
I just thought I'd mention that you don't really need to use the "Read Selection" command. (Don't know if that command is wasteful or not, but it feels like overkill.)
There are a number of ways you could check for no selection, for example:
Code: Select all
if TextSelection.activeRange.length == 0
…
philip