Find in Macros
Find in Macros
Is it possible to use find in macros? If so, what is the syntax? If not, make that a feature request. In Classic, PowerFind in conjunction with macros allowed you to do some cool stuff.
I don't believe so, but you can use regular expressions in Perl macros to do much of what you could with Find in macros. (That's why I'm trying to teach myself Perl.)
To second your motion, I think it would be great to have Find built into the macro facility without the need for Perl -- especially once Find becomes sensitive to formatting.
--Craig
To second your motion, I think it would be great to have Find built into the macro facility without the need for Perl -- especially once Find becomes sensitive to formatting.
--Craig
Yes, although often what I was interested in was going the other way around (e.g., setting everything that matches a certain pattern to be red). I don't think you can do that with perl, although... is there some way of handing the results of a perl search back to a command macro?cchapin wrote: -- especially once Find becomes sensitive to formatting.
Example of find/replace in macro
Took me a few days to learn enough of Perl to do this but I've been programming since '77 in lots of languages (your mileage may vary).
Start with web pages to get free Perl manuals:
[/url]http://www.ebb.org/PickingUpPerl/pickingUpPerl.pdf[/url]
[/url]http://www.perldoc.com/perl5.8.4/pod/perl.html[/url]
The heart is in
$textfile =~ s/find/replace/g; #Switches all (the g) "find"s to "replace"s
but takes overhead and must be a Perl file (ends in .pl) in your macros folder (easiest). Also note that backslashes are necessary in more places than in PowerFind Pro (before forward slash and period) in order to work in code.
This example takes Bank of America web page transactions copied to a NWE 2.0.1 file and makes it tab delimited and sets the style to Simple (my style sheet name) including font, size, color and rulers. The style part works under code control better than choosing it from the palette where the rulers don't get applied.
#Nisus Macro Block
#source clipboard
#destination clipboard
#Before Execution
#Clipboard 1
#Select All
#Copy
#After Execution
#Paste
#Simple
#Clipboard 0
#End Nisus Macro Block
use warnings;
use strict;
my $textfile = undef;
read STDIN,$textfile,1000000;
$textfile =~ s/\n[^0-9\/]*([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9])[^0-9\/\n]*\n\s*(.+)\s*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*\n[^\$0-9,.\n]*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*/\n$1\t$2\t$3\t\t$4/g; # Debit
$textfile =~ s/\n[^0-9\/]*([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9])[^0-9\/\n]*\n\s*(Check.+)[\s|\n]*(.+)\s*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*\n[^\$0-9,.\n]*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*/\n$1\t$2$3\t$4\t\t$5/g; # Check
$textfile =~ s/\n[^0-9\/]*([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9])[^0-9\/\n]*\n\s*(.+)\s*\n[^\$0-9,.\n]*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*/\n$1\t$2\t\t$3\t$4/g; # Credit
print $textfile;
And I need a job (San Antonio, Design Engineering/Programming)
Start with web pages to get free Perl manuals:
[/url]http://www.ebb.org/PickingUpPerl/pickingUpPerl.pdf[/url]
[/url]http://www.perldoc.com/perl5.8.4/pod/perl.html[/url]
The heart is in
$textfile =~ s/find/replace/g; #Switches all (the g) "find"s to "replace"s
but takes overhead and must be a Perl file (ends in .pl) in your macros folder (easiest). Also note that backslashes are necessary in more places than in PowerFind Pro (before forward slash and period) in order to work in code.
This example takes Bank of America web page transactions copied to a NWE 2.0.1 file and makes it tab delimited and sets the style to Simple (my style sheet name) including font, size, color and rulers. The style part works under code control better than choosing it from the palette where the rulers don't get applied.
#Nisus Macro Block
#source clipboard
#destination clipboard
#Before Execution
#Clipboard 1
#Select All
#Copy
#After Execution
#Paste
#Simple
#Clipboard 0
#End Nisus Macro Block
use warnings;
use strict;
my $textfile = undef;
read STDIN,$textfile,1000000;
$textfile =~ s/\n[^0-9\/]*([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9])[^0-9\/\n]*\n\s*(.+)\s*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*\n[^\$0-9,.\n]*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*/\n$1\t$2\t$3\t\t$4/g; # Debit
$textfile =~ s/\n[^0-9\/]*([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9])[^0-9\/\n]*\n\s*(Check.+)[\s|\n]*(.+)\s*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*\n[^\$0-9,.\n]*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*/\n$1\t$2$3\t$4\t\t$5/g; # Check
$textfile =~ s/\n[^0-9\/]*([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9])[^0-9\/\n]*\n\s*(.+)\s*\n[^\$0-9,.\n]*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*\n[^\$0-9,.\n]*(\$[0-9]*,?[0-9]*\.[0-9][0-9])[^\$0-9,.\n]*/\n$1\t$2\t\t$3\t$4/g; # Credit
print $textfile;
And I need a job (San Antonio, Design Engineering/Programming)
Be seeing you
Darren
Progressive Proximity Principle
Darren
Progressive Proximity Principle