Reply to topic  [ 4 posts ] 
Slug Lines 
Author Message

Joined: 2008-02-26 13:46:29
Posts: 18
I know it's a throwback to the days when type was formed from melted lead by guys named Harold with callused hands that could grab hot metal fresh from the Linotype machine and not be burned, but I still like to use "slug lines," a string of text at the top of a document that says information like FileName, Path, Etc. I see where I can have this data appear automatically. How about Character Counts? Is there a way to do a macro that will insert a new top line of text that is FileName, Path, Character Counts and a randomly generated Chuck Norris Joke?

Did you know his tears cure cancer?


2008-02-26 15:19:48
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
haha, that joke is new to me.

At the moment there aren't facilities to provide the automatically updating information you'd like. You can use certain macros (eg: Macro > Insert > Document Path) to insert the information, but you'd have to run it any time the information has changed.


2008-02-26 15:31:03
Profile WWW
User avatar

Joined: 2008-05-25 12:41:12
Posts: 37
Location: Germany
Would it be possible to write a macro that inserts this information (or calls another macro which does) and then sends the document to the printer?


2008-06-05 06:17:36
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
I don't see why not- here's a macro that searches the document for special bracketed templates and replaces them with the corresponding information:
Code:
# This macro duplicates the current document and replaces certain special fields with
# information about the document, then displays the print dialog. The fields take the
# form "[property]", where "property" is one of a few pre-defined information pieces.
# For the valid property names see the "Replace All" statements at the end of this macro.
$doc = Document.active

# gather some information about the document
$docPath = $doc.filePath
If $docPath
   $docName = $docPath.lastFilePathComponentWithoutExtension
Else
   # unsaved document, just use current display name, eg: "Untitled 2"
   $docName = $doc.displayName
   $docPath = '(unsaved)'
End

# format current date and time
$now = Date.now

$monthName = Date.nameOfMonth($now.month)
$day = $now.day
$year = $now.year
$hour = Date.zeroPad($now.hour)
$minute = Date.zeroPad($now.minute)
$second = Date.zeroPad($now.second)

$currentDate = "$monthName $day, $year"
$currentTime = "$hour:$minute"

# duplicate the document and replace any placeholders with the gathered data
$docCopy = $doc.copy
$docCopy.clearAndDisableUndoHistory      # we're working on a copy, so undo is not needed
If Find All '[file name]'
   Replace All '[file name]', $docName, 's'
End
If Find All ‘[file path]’
   Replace All ‘[file path]’, $docPath, 's'
End
If Find All ‘[current date]’
   Replace All ‘[current date]’, $currentDate, 's'
End
If Find All ‘[current time]’
   Replace All ‘[current time]’, $currentTime, 's'
End
If Find All ‘[current date and time]’
   Replace All ‘[current date and time]’, "$currentDate, $currentTime", 's'
End

# character count must be done last, after making replacements
$docCharCount = $docCopy.text.length
If Find All ‘[character count]’
   Replace All ‘[character count]’, $docCharCount, 's'
End

# print the prepared document
Print


So in a document your header could be:
Quote:
[File Name] @ [Current Date]

When you run the macro that might become:
Quote:
My Paper @ June 6, 2008


The Find/Replace All commands in the macro are a bit unusual because NWP seems to sometimes have issue with a direct Replace All involving the headers/footers.


2008-06-05 15:49:15
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 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