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:
Tue, 16 Mar 2010 02:42:05 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (40 lines)
On Mar 16, 2010, at 12:01 AM, Žorvaršur Davķšsson wrote:

> On 15.03.2010, at 12:15, Kino wrote:
> 
>> On Mar 15, 2010, at 5:01 AM, Žorvaršur Davķšsson wrote:

>> Attention: the macro overwrite a file of the same name in the same location without warning.
> 
> So I guess there is no way to include a warning in the macro?

There is. I did not add a routine for that because it was not included in your request ;-) and if a warning is useful or annoying depends on how you use the macro or your Mac. Personally I never put anything important in the Desktop folder and it stores only temporary things, e.g. an image file to be uploaded.

That said. This kind of small modification would be a good exercise for those who are learning NWP macro but, anyway, add the following lines just before "Save As $path" (or "Save To $path") near the end of the macro:

if File.existsAtPath $path
	Prompt 'A file of the same name already exists as', $path, 'Overwrite'
end

Then, you can cancel the operation by pushing "Stop Macro" button.

> I knew that something was wrong. I'm learning this (for me) new macro language slowly, slowly. But I must say – all in all – it is easier to learn and more powerful than the old macro language. Unfortunately the Nisus Macro Reference file does not contain enough examples to help the novice and illustrate how to use the commands. It's mostly pure grammar, which can be very frustrating for the beginner.

I agree with you. So I think I should explain the following portion of the macro.

if $doc.filePath == undefined
	$ext = 'rtf'
else
	$ext = $doc.filePath.filePathExtension
end

"If the document ($doc) does not have a path, the macro uses 'rtf' as file extension (because it is an unsaved new document). Otherwise (= if it has a path), the macro uses the same file extension, e.g. zrtf  if it is a zrtf file." This routine may be superfluous if you use the macro to save unsaved documents only.


> But considering the fact that this was a major catastrophe for me I would say that this should not have been able to happen. I sent a report to Manfred and asked him: "Would it be possible to write a code in NWP that would somehow protect the Desktop folder from being accidentally replaced, removed or deleted with a macro? I guess NWP is also able to play havoc with other important folders as well (the Home folder, the Library …), perhaps they should be protected from accidentally being replaced and turned into a Nisus document too." Perhaps the Home folder is protected by the System software, but I am not going to test it, I have had enough experiments today.

But the same thing occurs with any script language when you write a file to a wrong path. Something much worse may happen because, unlike NWP macros, you can run such a script as root. Or even without a script. I have heard a new Mac user trashed System Folder because one day he noticed it and thought he had never seen it since his getting his Mac. That was in OS 7 or so. Oh, and soon after I got my first Mac, I reinitialized the hard drive and reinstalled OS, thinking something was wrong because it made noise at times when I was doing nothing. Before MacOS, I had never used an OS of which background processes accessed a disk ;-)


Kino

ATOM RSS1 RSS2