Whats wrong in this code?

Hello,

I have referred one script from this forum.

which is copying only one document from one document from source database to destination database. whats wrong in the code

heres the code

==========================

Sub Initialize

Dim session As New notessession

Dim db As notesdatabase,srcdb As notesdatabase,dstdb As notesdatabase

Dim view As notesview,srcview As notesview,dstview As notesview

Dim doc As notesdocument,srcdoc As notesdocument,dstdoc As notesdocument,srcdocnext As notesdocument,srcdocroot As notesdocument

Dim srcuid As String

Dim delaymonths As Long

Dim todaydate As notesdatetime, srcdocdate As notesdatetime

Set db=session.currentdatabase

Set view=db.getview(“Settings”)

Set doc=view.getfirstdocument

delaymonths=Val(doc.delaymonths(0))

Set srcdb=New notesdatabase(db.server,doc.srcdb(0))

Set dstdb=New notesdatabase(db.server,doc.dstdb(0))

Set srcview=srcdb.getview(doc.srcview(0))

Set srcdoc=srcview.getfirstdocument

Set srcdocroot=srcdoc

Set srcdocdate=New notesdatetime(srcdoc.created)

Set todaydate=New notesdatetime(“Today”)

delaydiff=todaydate.timedifference(srcdocdate)

delaysecs=delaymonths30246060

If delaydiff<delaysecs Then Exit Sub

srcuid=srcdoc.universalid

Set dstdoc=srcdoc.copytodatabase(dstdb)

If dstdoc is Nothing then Exit Sub ’ abort here if the document could not be copied

Set srcdoc=srcview.getnextdocument(srcdoc) ’ get first response doc

While srcdoc.~$ref(0)=srcuid

Set dstdoc=srcdoc.copytodatabase(dstdb)

Set srcdocnext=srcview.getnextdocument(srcdoc)

srcdoc.remove True

Set srcdoc=srcdocnext

Wend

srcdocroot.remove True ’ remove the main doc only after all responses are removed

End Sub

=================

thanks for your advice and also i didnot understood this “srcdoc.~$ref(0)” in this, what is he refering to…

regards

Sanjay

Subject: Extended syntax of $REF

$REF is the name of a field on the Notes document - it’s a special field that lists the UID of the parent document to which a document responds. I have no idea why the ~ is in there.

But the idea is that it checks each new document to see if it is a response to srcdocroot - if it is, that gets copied over before the deletion of srcdocroot.

Hope this helps clarify things,

Dave

Chub Toad, LLC

Subject: why the ~ is there

The tilde is there because the $ char has another meaning in VB, and the tilde acts like an escape character for the itemname.

Subject: Ah

Another reason not to use extended syntax? hehe

Subject: RE: whats wrong in this code?

What makes you think something is wrong with the code?

Is this supposed to be a brain teaser?

If it’s doing something you don’t like, please tell exactly what that is.