Hello Yusuke and others,

I read your posting with great interest.

On Tuesday, October 22, 2002, at 11:46 PM, Kino wrote:

[snip]

But what is annoying for a NW user I am is that TextExtras or a script executed via TextExtras does not allow me to call a menu command belonging to the application. You cannot even make it open a new document window in TextEdit. Another annoyance is the inability to control style/formatting at all. What you can do very easily with a NW macro like selecting some text portions by PowerFind Pro and apply Italic style on them is impossible with a *pure* perl script.

So I'd like to have the ability to exchange data between NW macro and perl/shell commands in NW X. In other words and for example, the ability to send strings selected non-contiguously to perl and replace them with those processed by perl one by one so that perl/shell process does not affect style attributes of non selected portion.
This can be done already with the Frontier/Perl combination, although there may be problems of timing. -- I just tested a simple macro of the kind you described. Here it is:

> Find All "^.+" "g-SA"
> s -> push (StartEnds)
> loop:
> if (! s -> size) Exit
> SetSelect (s -> pop, s -> pop)
> Frontier Sample Macros:�Send Selected Text
> Frontier Do Script 'MacJPerl.runScripts.executeScript ("hiragana2katakana", {Nisus.basicUtilities.returnedValue})'
> MacroPaste
> GoTo loop

And I have a Perl script named "hiragana2katakana" in Frontier's databse, at "user.MacJPerl.scripts" table. This worked without any problem. You see how this is simple!

I tried to send shell script from Frontier also (using AppleScript), but that failed. With Radio UserLand, this is *perhaps* possible.

As Frontier (for OS X) is no longer free (and Radio is not free either: it costs $39), I think NW X will no ship with Frontier (or Radio); so it should have another scripting support. There will be certainly some implementation of AppleScript -- but if it is the same system as the one we have currently, that would be very disappointing: embedding AppleScript scripts in Nisus macros is a pain, and as the scripts have to be compiled every time they run, that is unbearably slow. But it seems that this is due to the nature of AppleScript itself. We have the same slowness with AppleScript scripts embedded in Perl scripts (in MacPerl as well as Unix Perl).

Another possibility is the same kind of scripting support as AppleScript scripts in Style or Tex-Edit Plus, etc. These applications have a "Scripts" menu; we can write AppleScript scripts and save them in a folder named "Scripts" inside Style folder or Tex-Edit Plus folder, and these scripts are available from the "Scripts" menu of these applications. These scripts being already compiled, they run much faster than the embedded scripts in macros. But then, the integration or collaboration between macros and AppleScript scripts will be an important problem...

One possiblity would be that all the macro language is integrated in AppleScript "dictionary" ('aete' resource). This may be perhaps a good solution. But the "backward compatibility" should be assured also. If this is implemented, we would be able to write AppleScript scripts like the following:

tell application "Nisus Writer X"
tell window 1
Find all "^.+" "g-SA"
s -> push (StartEnds)
repeat while (s -> size)
SetSelect (s -> pop, s -> pop)
set s to selected text
do shell script "perl 'hiragana2katakana.pl' " & s -- the script "hiragana2katakana.pl" may be in
-- a sub-folder named "perl scripts" inside /Applications/Nisus Writer Folder/Nisus Tools/
-- Scripts/; there may be other sub-folders, like "shell scripts", "python scripts", etc.
set res to result
set selected text to res with property {font: "Times", style: "Italic"}
end repeat
end tell
end tell

If this kind of scripting support could be implemented, that would be perhaps ideal...

Thus I assume it would be possible ;-) to implement such a functionality to NW X macro language. And then, I'd like to request the ability to specify the path of perl or other commands.
If the model I described above could be implemented, then there would be no problem to specify the path of perl or other commands. We would simply do:

....
do shell script "/opt/perl/bin/perl 'hiragana2katakana.pl' " & s
....


Perhaps Apple Script could satisfy some of lacks mentioned above. But I know nothing about it and it would be hard for me to learn more than a language at the same time ;-)
Yes, I understand. And I find the AppleScript language not easy at all in general (by the way, Perl is not easy either...!). But if the Nisus macro language could be preserved as far as possible in Nisus AppleScript dictionary, I think the scripting of Nisus would not be too difficult (for those who are used to Nisus macro language).

Anyway, I think people should post in this list descriptions of the scripting support that they wish to be implemented in Nisus Writer X -- with specific examples if possible. This may give ideas to Nisus developers.

Best regards,

Nobumi Iyanaga
Tokyo,
Japan

The Nisus Interactive List
[EMAIL PROTECTED]

Searchable archives:
http://www.mail-archive.com/nisus-interactive%40nisus.com/

To unsubscribe from this list please send a message with "unsubscribe
nisus-interactive" in the body of the email to [EMAIL PROTECTED]



Reply via email to