Page 1 of 1
Posted: 2007-08-21 06:27:53
I gather that the macro language of NWP is still under development (e.g. you still can't do arithmetical operations -- have to use perl). It looks as if the language will eventually be as powerful as Nisus Classic, which would be wonderful. Meanwhile, I find the documentation missing. For example, the macros supplied are peppered with such bizarre lines as $text =~ s/\^/**/g;. It would be extremely useful -- and not terribly difficult -- if Nisus made a comprehensive guide to the macro language available. At least, the supplied macros could be commented extensively. Is there any more detailed documentation of the current macro language available?
Posted: 2007-08-21 12:27:33
You are correct, the macro language will be expanded as NWP itself is updated. The official help file accessed from the menu Help > Nisus Writer Pro Help contains the most detailed documentation on the Nisus macro language that we provide.
As for the bizarre line of text- that is a Perl statement. Explaining all but the simplest Perl is beyond the scope of the NWP documentation. However, I think a quick internet search should yield a vast collection of Perl resources if you're interested in learning the language.
All that said, you're welcome to ask Perl questions here if you like. The specific line of Perl you noted is a find and replace operation that acts on the $text variable. Specifically the expression takes the form:
$var =~ s/find/replace/ops;
So in this case we're replacing all "^" characters with "**". The "g" in the options string means do it globally, eg: replace all instances in $text.
Posted: 2007-08-22 11:21:48
Someone must have asked this -- but it would seem to me that it would not be THAT hard to write a conversion utility from NWC macros to NWP. With Perl, even arithmetical operations could be handled. Another point: it appears that the macro language for NWP is more developed than that for NWE, and that's why the macros included use so much Perl. Why not rewrite them, as NWP is clearer and I suspect many users (like myself) would be more comfortable with NWP's language. Yes, I'd love to learn Perl, but it's not exactly trivial, while the NWP language seems much more straightforward. Do macros in Perl execute faster, slower, or the same as the same as macros in NWP?
Posted: 2007-08-22 16:03:51
talaivan wrote:it would seem to me that it would not be THAT hard to write a conversion utility from NWC macros to NWP.
A general purpose converter would be quite an undertaking. To say it would be "hard" is an understatement. Also, the NWP macro language does not have all features that Classic macros had.
Why not rewrite them, as NWP is clearer and I suspect many users (like myself) would be more comfortable with NWP's language.
Most of the macros that ship with NWP have been written using the Nisus macro language. Some still use Perl because they require features found in Perl or are simply more natural to write in Perl.
Do macros in Perl execute faster, slower, or the same as the same as macros in NWP?
In general Perl will be faster. However, any Perl code must be executed as a separate application/process, so there is an associated startup cost with running any Perl at all.
Posted: 2007-08-27 23:46:34
What is somewhat doable and very useful is to create macros that will massage NWC Find/Replace macros into analogous NWP macros. I've been working on building this up as I have time.
As far as that goes, I can also suggest that NWP Find/Replace macros are a lot less crazymaking if they are built in the single-quoted form:
Find and Replace 'whatever', 'whatever', '-s-va-uU-wWE'
It greatly reduces the amount of extra slashes required for escaping special characters, so that, for the most part, the macro expression looks the same as the actual PowerFind expression.