a wordlist in perl without the print command

Get help using and writing Nisus Writer Pro macros.
Post Reply
js
Posts: 259
Joined: 2007-04-12 14:59:36

a wordlist in perl without the print command

Post by js »

The manual says that the original dedicated Perl macros are kept for backward compatibility, but you don't need them any more since you can integrate Perl into Nisus Macros. But earlier Nisus Perl macros often used the print command, which is anoutput command. Those earlier dedicated macros would define where the output goes. But how to do that within a Nisus macro? Let's say you have a list of words and you would like to pass this @wordlist on to Nisus as a real list with returns or something as separators. How to do that without the print command?
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

You have two options. The first is to pass the word list back as a scalar, eg:

Code: Select all

$str = ''
Begin Perl
    @words = ('red', 'green', 'blue');
    $str = join( "\n", @words );
End
Insert Text $str
Your other option is to use the print statement and simply direct the output to the current document:

Code: Select all

Begin Perl
    #Nisus Macro Block
    #destination front selection
    #End Nisus Macro Block
    @words = ('red', 'green', 'blue');
    $str = join( "\n", @words );
    print $str;
End
Post Reply