Reply to topic  [ 3 posts ] 
[updated] Preserving view when switching between doc windows 
Author Message

Joined: 2010-02-22 15:06:48
Posts: 98
[Edit: I had copied the wrong macro code into the post initially, it now has the correct code]

Hello all,

I have a macro that I use to automatically cut and paste material from the document I'm currently editing to a scrap document. The macro then switches back to the original document so I can continue my editing. The macro uses the command "Document.setActive $doc" to switch back to the original file.

All works perfectly if the document I'm currently editing is in Page or Draft view. However, if the original document is in Full Screen mode, when the macro switches back to it, the document reverts to Page or Draft depending on what it last was in.

So, finally, here is the question: how can I have the macro switch back to the document I'm currently editing and return it to Full Screen mode?

Thanks in advance,
Josh

For what it is worth, here is the current macro:
Code:
#Get name and path or document being edited.
$doc = Document.active
$path = $doc.filePath
$name = $doc.displayName

#Assemble path and name of Scrap file (always “X -- ” + edited document); always in same folder
$xpath = $path.filePathByRemovingLastComponent
$xname = ‘X -- ’
$xname &= $name
$xpath = $xpath.filePathByAppendingComponent ($xname)

$text = Read Selection # copy current document's selected text
Menu ':Edit:Delete'

# See if X-file Exists: Open it or create it.
If File.existsAtPath($xpath)
   Open $xpath
Else
   New
   Save As $xpath
End

$xdoc = Document.active
Select Document End # move to end of x-document
Type Text "******\n"
$xdoc.insertText( $text, 'm' ) # insert text
Type Text "\n\n"
Save
Document.setActive $doc


2011-06-09 10:07:20
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
goldste4 wrote:
So, finally, here is the question: how can I have the macro switch back to the document I'm currently editing and return it to Full Screen mode?

This isn't too hard- the trick is restoring Full Screen only if that was the active view mode. But you can test that using the "Menu State" command. So your code will look something like this:
Code:
#Get name and path or document being edited.
$doc = Document.active
$isFullScreen = Menu State ':View:Full Screen'
...
Document.setActive $doc
If $isFullScreen
   Menu 'Full Screen'
End

Let me know if you have any troubles.


2011-06-09 12:26:55
Profile WWW

Joined: 2010-02-22 15:06:48
Posts: 98
Hi Martin,
Perfect! I feel bad for not thinking of it myself, although knowing the quickness and quality of the responses on the Macro forum can make one who isn't very versed in NWP's macro language, like me, a bit lazy . . .
Thanks again,
Josh


2011-06-09 17:35:00
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software