Reply to topic  [ 11 posts ] 
Wanted: Filename Macro 
Author Message

Joined: 2007-07-25 05:51:34
Posts: 5
Hi,
I am contemplating making the move from Word to Nisus Writer Express. One function that I would really need is to be able to put the filename, the pagenumber & the total number of pages of the document into the footnote section. I can do this manually in 3 steps but I was wondering if there is a Macro to do this with one click.
Thanks


2007-07-25 05:58:00
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
This should do it:
Code:
$name = Document Property "File Name Without Extension"
Type Text "$name, page "
Menu ":Insert:Automatic Number:Page Number"
Type Text " of "
Menu ":Insert:Automatic Number:Pages in Document"

Note that the file name is not automatically updating, so if you rename your file you'll have to run the macro again (or edit the header/footer).


2007-07-25 09:35:15
Profile WWW

Joined: 2007-07-25 05:51:34
Posts: 5
Post 
Hi Martin,
Many thanks for the quick reply. Unfortunately I get the folowing compilation error:
"Semicolon seems to be missing at /tmp/NisusScript line 8.
Semicolon seems to be missing at /tmp/NisusScript line 9.
String found where operator expected at /tmp/NisusScript line 10, near "Menu ":Insert:Automatic Number:Page Number""
(Do you need to predeclare Menu?)
Semicolon seems to be missing at /tmp/NisusScript line 10.
Semicolon seems to be missing at /tmp/NisusScript line 11.
String found where operator expected at /tmp/NisusScript line 12, near "Menu ":Insert:Automatic Number:Pages in Document""
(Do you need to predeclare Menu?)
syntax error at /tmp/NisusScript line 9, near "Type Text "
Execution of /tmp/NisusScript aborted due to compilation errors
."
Any ideas?
Thank you


2007-07-25 12:57:58
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
My apologies, that macro will only function in Nisus Writer Pro. I should have been more observant with regard to your initial post.

I'm sorry to say there's no single macro that can accomplish what you desire in Express. This is probably the closest:

Code:
#Nisus Macro Block
#source front selection
#destination front selection
#After Execution
#Insert:Automatic Number:Page Number
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

$path = $ARGV[1];
$path =~ /\/([^\/]+?)(\.\w+?)?$/;
$name = $1;
print "$name, page ";


2007-07-25 13:45:38
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
I thought about it and there is a solution for you. Save the following as a macro called "Insert Total Pages":

Code:
#Nisus Macro Block
#source front selection
#destination front selection
#After Execution
#Insert:Automatic Number:Pages in Section
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

print " of ";


And then you can make use of this single macro to do what you desire:

Code:
#Nisus Macro Block
#source front selection
#destination front selection
#After Execution
#Insert:Automatic Number:Page Number
#Macro:Insert Total Pages
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

$path = $ARGV[1];
$path =~ /\/([^\/]+?)(\.\w+?)?$/;
$name = $1;
print "$name, page ";


2007-07-25 13:49:35
Profile WWW

Joined: 2007-07-25 05:51:34
Posts: 5
Post 
Many thanks Martin,
That almost works i.e. it pastes the filename and the word "page". It does, however, give an error message about a faulty menu in the macro i.e. "contains an unknown menupath" (I am translating from german) and asks whether to stop or continue the macro.
Michael


2007-07-25 16:27:50
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
Michael, you'll need to translate the menu paths to the German equivalents. Just replace the following lines in the macro with German menu names:

Insert:Automatic Number:Page Number
Insert:Automatic Number:Pages in Section
Macro:Insert Total Pages


2007-07-25 17:35:17
Profile WWW

Joined: 2007-07-25 05:51:34
Posts: 5
Post 
D'OH!!
Thanks


2007-07-25 21:15:01
Profile

Joined: 2007-07-25 05:51:34
Posts: 5
Post 
Hi Martin,
I have changed the menu items to their german equivalent but I am getting the same error messages & results i.e. Name of file & "page" are inserted as before. I have checked and rechecked all the items that may need translation but seem to have exhausted all the possibilities.
Michael


2007-07-27 03:29:31
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
Can you send your macro via the feedback mechanism? Just use the menu Help > Send Feedback. I'll take a look and see what the problem could be.


2007-07-27 11:52:31
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
I've thought about this some and this macro should do exactly what you wanted and does not make use of any menu commands, so it will work in the German localization no problem:

Code:
#Nisus Macro Block
#source front selection
#destination front selection
#Send Text as RTF
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

$path = $ARGV[1];
$path =~ /\/([^\/]+?)(\.\w+?)?$/;
$name = $1;

$rtf = '{\rtf1 \mac{' . $name . ', page {\field {\*\fldinst {PAGE}}} of {\field {\*\fldinst {NUMPAGES}}}}}';

print $rtf;


2007-08-09 11:38:22
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 11 posts ] 

Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software