You're on the right track with NotesDocument. This is how it could work :
Code:
[COLOR=green]'step 1[/color]
dim session as new notessession
dim db as notesdatabase
dim view as notesview
dim doc as notesdocument
dim olddoc as notesdocument
dim delflag as boolean
dim movtype as integer
[COLOR=green]'step 2[/color]
set db = session.currentdatabase
dim view = db.getview("($All)")
dim doc = view.getfirstdocument
do while not(doc is nothing)
[COLOR=green]'step 3[/color]
delflag = false
movtype = checkdate(doc)
if movtype = 1 then
delflag = true
else
if movtype = 2 then
doc.archive = "Y"
call doc.save(false,false,false)
end if
end if
[COLOR=green]'step 4[/color]
set olddoc = doc
set doc = view.getnextdocument(olddoc)
if delflag then
call olddoc.remove(false)
else
delete olddoc
end if
loop
So what is going on here ?
I've divided the code into steps. Let's walk through them.
Step 1 : Declarations. Apart from the indispensable, you will notice that I have added a boolean flag and an integer. We will be using those later.
Step 2 : Setting up the objects and initialising the loop with the first doc in the view.
Step 3 : Gets interesting here. In this step I first set the deletion flag to false because we are starting the analysis of a new document. Then I call upon a function to check which operation I wish to do on the current document. I have left that function for you to write ;-).
Once we have the result of the function (1 = delete, 2 = archive, anything else is ignore), we can then act upon the result obtained, which is done in the test area.
Step 4 : Wrapping up by getting the next document in the view, and using the flag to check if the old one is to be removed.
For the checkdate function, do not forget that date/time comparisons in LScript are best done with the NotesDateTime object.
Have fun !
Pascal.