NISUS Archives

March 2010

NISUS@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Mon, 15 Mar 2010 20:15:54 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (54 lines)
On Mar 15, 2010, at 5:01 AM, Žorvaršur Davķšsson wrote:

> How can I save a document on the desktop with a macro using a text selection from the document?
> 
> In Nisus Classic I used this:
> Copy
> Save
> Paste
> Enter [this would simulate the Enter or the Return key, I have forgotten how this macro command exactly looked like in Nisus Classic]

In NWP, you can use "Press Default Button" command but "Paste" and "Send Text" do not work for Save As dialog box. A bug or some limitation of the dialog box? Anyway, I think the following will do the job.

$doc = Document.active
if $doc == undefined
	exit  # no open document or no focus
end
$fileName = Read Selection
if $fileName == ''
	exit 'No selection, exiting...'
end
if $doc.filePath == undefined
	$ext = 'rtf'
else
	$ext = $doc.filePath.filePathExtension
end
$path = User Property 'home folder path'
$path &= '/Desktop/' & $fileName
$path &= '.' & $ext
Save As $path  # or: Save To $path
File.revealPathInFinder $path  # remove this command if you find it unnecessary


Attention: the macro overwrite a file of the same name in the same location without warning.

On Mar 15, 2010, at 4:56 PM, Žorvaršur Davķšsson wrote:

> Today I wanted to test the following lines:
> 
> $path = '/Users/meinewenigkeit/Desktop
> $name = Read Selection
> $name = $name &= ‘.rtf’
> Save to $path, $name
> 
> I actually intended to close the path with an apostrophe (') after the word "Desktop" , but it seems I forgot it.

You forgot also a slash / after "Desktop". And the syntax of "Save To" command is wrong. See the reference.

> The result was that the files and folders I had on the Desktop suddenly all disappeared and the Desktop folder itself is now a Nisus document

I don't know what happened. But, before running a new macro, you should do some testing, e.g. use "exit" command to verify the path composed by the macro, create a new folder and use /Users/you/Desktop/untitled folder/ instead of the Desktop folder to see if the macro really saves the file in it, etc.


Kino

ATOM RSS1 RSS2