Hello Yusuke,

On Thursday, October 24, 2002, at 12:15 AM, Kino wrote:

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!
Yes, very simple, But, if I understand well, your script repeats

Frontier Do Script 'MacJPerl.runScripts.executeScript ("hiragana2katakana", {Nisus.basicUtilities.returnedValue})'

for each selection in NW? It is not rare for me to treat over 5000 character offsets or strings in a storage variable with NW macro. So this might take not a very short time. In the current NW macro, I think your method would be the best.
Well, I gave that example only to show the ability of the Nisus/Frontier/Perl combo with the looping construct. This can be done in "one go" for a whole file. In theory, there is no limit of length of string that Frontier can handle. And if the file is VERY large (say for example 500KB or more...), it is possible to write the converted text into a file, and open it in Nisus. In macro, the first method would be:

> Select All
> Frontier Sample Macro:�Send Selected Text
> Frontier Do Script 'MacJPerl.runScripts.executeScript ("hiragana2katakana", {Nisus.basicUtilities.returnedValue})'
> MacroPaste

For the second method, we would write another perl script in Frontier: it would take a file path, and write the converted text to a file, with the same path plus ".out" extension; and the Nisus macro be:

> Clipboard = DocPath
> Frontier Do Script "Nisus.basicUtilities.returnedValue = clipboard.getValue ('TEXT')" "-"
> // with this "-", the clipboard will not be overwritten by the return value from Frontier;
> // otherwise, the clipboard will be "true"
> Frontier Do Script 'MacJPerl.runScripts.executeScript ("hiragana2katakanaToFile", {Nisus.basicUtilities.returnedValue})'
> Clipboard = DocPath + ".out"
> Open '\CC'

or something like this (I did not test these macros/scripts).
BUT the problem is that with these methods, all the style attributes (with graphics, footnotes, script attribute, etc.) will be lost. If you write only the selections, at least the original style attributes will not be lost.

The problem of style attributes and other "non-pure-text" things in Nisus documents, will be the most difficult part of problem. This may be perhaps solved if the documents are saved in (for example) rtf (or TeX) format, and if there is a *very good* rtf (or TeX) parser, which would allow the users to not take care of all the style problems (I mean the rtf details...) all the time.

But, with the *hypothetical* NW X macro language, I will be glad if I'll be able to do, for example, something like this:

// convert hiragana to katakana

set tmp_out=AUTO
set tmp_in=AUTO

Find All "[:hiragana:]+" "ogT"
s->push (StartEnds)
tmp_out->push (Strings)

// tmp_out will be generated automatically as a temporary file
// with an appropriate path/name and an appropriate
// separator between items.

DoShellScript ( ~/bin/hiragana2katakana.pl < tmp_out > tmp_in )

// tmp_in -- with an appropriate name automatically assigned by NW X
// -- will be read by NWX and used as a storage variable
// of the same name in the current macro.

loop:
SetSelect(s->pop, s->pop)
clipboard=tmp_in->pop
MacroPaste
if(s->size) goto loop

// end of macro

One thing that I don't like very much in current Nisus macro language is the (very frequent) use of clipboard... It would be much better if we could write more directly, for example:
set selected text to temp_in -> pop
...

But this point apart, I think your method may be implemented even now with Nisus/Frontier/Perl combo -- although it would be not very fast...

But anyway, Frontier/Radio will not be a choice for Nisus Writer X, because they are not free...!


Anyway, for this specific problem, the best solution would be to implement such features to NW X macro language. But the interactive ability above described will give the unlimited extensibility to NW X macro language. This is what I think to be the most important.
I agree totally.

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