2nd Posting: Any lotuscript experts in the house?

I have attached script to be put for instance in a button and mailed to the Notes users after their Notes client have been upgraded to R6. When the users click on it, it will go through their local notes db’s and compact it to ODS 43.

The scripts works fine but when the local mail replica is still open (because the mail with the button is opened from the local mail replica) then the script will skip the compact of this db. But we need to compact this db also to make use of the new options in ODS43 like replication of unread marks.

Does anybody know another way of compacting these local db’s or know a way to close all open db’s first before launching the compact.

Thanks, Phuoc.

Hereby the code:

Dim dbcount As Long ’ number of databases encountered

Dim compacted_count% ’ how many were compacted

Dim amount_recovered As Double

Dim totalsize As Double ’ total size of all databases (not just those compacted)

Dim total_utilization As Double

Class Reporter

NormalTermination As Integer

Sub finish

NormalTermination = True

End Sub

Sub delete

Dim t$

If Not NormalTermination Then

t$ = |<< Process Terminated >>|

End If

Messagebox t$ & |Found | & dbcount & | Databases. These take = | & Format(totalsize, “0,0”) & | Bytes. Compacted | & compacted_count & | Databases, reduced | & Format(amount_recovered, “0,0”) & | Bytes.|

End Sub

End Class

Sub Click(Source As Button)

Dim dbs As notesdbdirectory, db As notesdatabase, cutoff As Double, tmp, delta As Long, ses As New notessession, thisdb As notesdatabase

Set thisdb = ses.currentdatabase

cutoff = 100

Set dbs = New notesdbdirectory(“”)

Set db = dbs.getfirstdatabase(DATABASE)

Dim report As New reporter

Do Until db Is Nothing

If db.filepath <> thisdb.filepath Or thisdb.server <> “” Then

db.open “”, “” ’ database must be open to read size and percent used.

If db.isopen Then

tmp = db.size

If db.percentused < cutoff Then

Print “Compacting " & db.title & " (” & db.filepath & “)”

delta = 0 ’ in case there’s an error when compacting

On Error Resume Next

delta = db.compact

On Error Goto 0

amount_recovered = amount_recovered + delta

compacted_count = compacted_count + 1

End If

totalsize = totalsize + tmp

total_utilization = total_utilization + db.percentused

dbcount = dbcount + 1

End If

End If

Set db = dbs.getnextdatabase()

Loop

report.finish

End Sub

Subject: 2nd Posting: Any lotuscript experts in the house?

sounds like a “catch-22” situation - that is to say, the button is attached to an open document (in the local mail file) - in order to close the database (the local mail file) you must close the document that is executing the code.

hmmmmm - this may have to be controlled somehow from the server side.

this is just an idea - but if the replica of the mail file that is on the mail server is compacted in advance, do any of those compacting properties get pushed with replication? I do not know enough about replication mechanics to amswer that. but maybe someone on here might.

I am just sharing an idea - I know I have not presented you with a solution.

chuc may man!

Subject: RE: 2nd Posting: Any lotuscript experts in the house?

Hi Jon,

thanks for your reply. No via a normal replication with the server the ODS of the local mail replica stays the same. That’s why I need to run a local compact of the mail replica.

Rgds, Phuoc.

Subject: RE: 2nd Posting: Any lotuscript experts in the house?

Then assuming you need to have every database on the local machine closed, then you need a method of executing lotusscript agent while no database is open…is that a correct assumption?

I actually encountered another case similar to this. It did not relate to upgrades, but it was related to executing lotusscript mailed out to all users in an email. The way we controlled it was to REQUIRE that user be connected to the server and execute the button from the server-based mail file only. It was more annoyance for users but necessary.

In your case you could simplify: Use two buttons - 1) mail file only: must be executed from server and then 2) all other databases, can be executed from local machine.- - minimizing the connection time.

I know this is more work, but it would accomplish. Just thinking of other options.

tam biet Phuoc