[comp.sys.mac.apps] Nisus Macros: Question and Call for Distribution

pv9y@vax5.cit.cornell.edu (09/24/90)

I have a question about Nisus Macros and the Programming Dialect. I
want to create a macro that will delete all of my secondary
automatically
backups from the Backups folder in which they alone are stored. I have
a macro in the Macro Dialect which does what I want, open the Catalog
at the right place, select the first file, choose Delete, and hit
return to confirm the deletion. It looks like the following...

Catalog "Perseus:Nisus:Backups" "C"
Catalog
Select All
Delete
Key

Not too difficult, really. However, as soon as I try to make it loop
using a labelname and a Goto labelname command from the Programming
Dialect, it fails. I also tried another version which copied the list
of files from the Catalog, added quotes around each name, the Delete
command at the beginning of the line, and a Key (hit return) command
on the next line. It put all this in a new file, selected it, and then
Executed Selection. It too only worked with a single file and wouldn't
confirm any of them if there were more than one. Ideally I would like
to enhance this at some point to delete all the backups that are more
than a week old and have it do that at startup each day. Otherwise I
have to remember to manually delete the 500K or so that builds up
every few weeks.

Any ideas on how this can be made to work? Thanks ...

I would also like (and I have no idea if this is even possible in the
Programming Dialect) a table tool for the odd occasions when I want to
create a table. It's pretty easy with graphics and tabs since Nisus is
better about those than most programs, but it's still harder than in
WordPerfect 2.0 and MathWriter 2.0 and even (horrors) Word 4.0. I
suppose that tables would make more sense to build in when columns
were built-in for editing, but I do like the idea of adding features
by way of Programming Dialect Macros so those who don't want the
feature don't have to get it.

By the way, I do intend to distribute this macro if I ever get it working
because it seems to me to be a general purpose macro that many people 
could use. If you have created any macros that are of general utility,
I strongly encourage you to send them in for distribution. If that's too
hard, send things to me and I'll bundle them up and send them for 
posting on comp.sys.mac.binaries as well as America Online. Heck, if I
get a of good macros, I may even do a special issue/version of TidBITS
for them since they are only text and easily distributable.

So send me what you've got and maybe you'll become famous. You might
even become famous if you don't send me anything, I sort of doubt the
two acts are related :-).

...Adam

-- 
Adam C. Engst                         pv9y@vax5.cit.cornell.edu   
---------------------------------------------------------------          
Editor of TidBITS, the weekly electronic Macintosh news journal

jon@weber.ucsd.edu (Jon Matousek) (09/27/90)

In article <1990Sep24.113353.121@vax5.cit.cornell.edu> pv9y@vax5.cit.cornell.edu writes:
]I have a question about Nisus Macros and the Programming Dialect. I
]want to create a macro that will delete all of my secondary
]automatically
]backups from the Backups folder in which they alone are stored. I have
]a macro in the Macro Dialect which does what I want, open the Catalog
]at the right place, select the first file, choose Delete, and hit
]return to confirm the deletion. It looks like the following...
]
]Catalog "Perseus:Nisus:Backups" "C"
]Catalog
]Select All
]Delete
]Key
]
]Not too difficult, really. However, as soon as I try to make it loop
]using a labelname and a Goto labelname command from the Programming
]Dialect, it fails. I also tried another version which copied the list
]of files from the Catalog, added quotes around each name, the Delete
]command at the beginning of the line, and a Key (hit return) command
]on the next line. It put all this in a new file, selected it, and then
]Executed Selection. It too only worked with a single file and wouldn't
]confirm any of them if there were more than one. Ideally I would like
]to enhance this at some point to delete all the backups that are more
]than a week old and have it do that at startup each day. Otherwise I
]have to remember to manually delete the 500K or so that builds up
]every few weeks.
]
]Any ideas on how this can be made to work? Thanks ...

Is the "Nisus Programming Dialect" module in the same folder as Nisus,
if not you will have to load it manually.

Here is something I quickly worked out to delete files that are older
than 1 week old. I'll leave it up to you to test it.

Catalog "Perseus:Nisus:Backups" "C"
Catalog
Select All

// calculate when one week ago from now is (all in seconds).
oneWeekAgo = date - (3600 * 24 * 7)

// save all of the file names on a stack named "s".
s -> push (strings)

// loop over every filename in the stack, exit when the stack is empty.
loop:
if (!s -> size) exit

// open the file so we can get the date when saved.
clipboard = s -> pop
open '\CC'
dateSaved = LastDateSaved
close

// compare the dateSaved to one week ago, do nothing if newer than a week.
if (dateSaved > oneWeekAgo) goto loop

// else delete this file, it's older than a week. (Its Key<space> below.)
Find Next '\CC' "-goW"
Delete
Key 
goto loop

]
]...Adam
]
]-- 
]Adam C. Engst                         pv9y@vax5.cit.cornell.edu   
]---------------------------------------------------------------          
]Editor of TidBITS, the weekly electronic Macintosh news journal


Hope this helps,

-jOn

--------------------------------------------------------------------------
%%
SoftwareEngineer: jOn mAtOUsEk;      Internet:  jon@weber.ucsd.edu
%%                                   AppleLink: D0405
Paragon Concepts, Inc.                     FAX: (619)481-6154
990 Highland Drive, #312
Solana Beach, Ca. 92075
(619)481-1477
==========================================================================