Sandbox question

Hi, I am a novice at both Notes and JS, I don’t know if I should post here or in the sandbox, but I really want a quick response for that.

I found a very good sample on Notes Address popup in Web, it is in the sandbox:

http://www-10.lotus.com/ldd/sandbox.nsf/Threads/EFE6B2307D3CD5C985256D9C0062B0D7?OpenDocument

This sample triggers an agent called AddressBook and it builds a dialog box or popup on Notes Address Book (NAB). It’s logic is to read the NAB and write the records to DSO first in Initialize section. Then BuildForm subroutine will read up the record and list out the addresses on the dialog box.

However I just can’t figure out some of the codings under Initialize. As indicated by (??? Qx) in the coding supplied

Sub Initialize

(Declarations ..)

Dim nabDB As NotesDatabase

.....

nabName = "names.nsf"

nabView = "($People)"

.....

Set DB = Session.CurrentDatabase

Set Doc = Session.DocumentContext



(???  Query 1)

If Doc Is Nothing Then       

	' For testing only.

	Set Doc = DB.CreateDocument

	doc.query_string = "OpenAgent&data"

End If



(???  Query 2)

If Instr( Lcase(Doc.Query_String(0)), "&data") Then

	' read the view and product a comma separated file

	Print "Content-Type: text/plain"  ' needed to make this a plain file

	

	'Open the NAB

	Set nabDB = Session.GetDatabase( DB.Server, nabName)

	Set View = nabDB.GetView( nabView )

	

	' Output the header 

	Print "Name,lastName,returnValue"

	Set ViewDoc = View.GetFirstDocument

	While Not ViewDoc Is Nothing

		(Output records to the file) 

		(Get next Document)

	Wend

	

Else



	(???  Query 3)

	Call BuildForm

	

End If

End Sub

Sub BuildForm

(Access DSO to output the NAB dialog box)

End Sub

Q1. Is Doc always nothing on first call to the agent?

Q2. If doc.query_string = “OpenAgent&data” is set after query 1, this inst statement should always be true.

Q3. How come the BuildForm execute? Will the Initialize procedure be executed more than once?

I just don’t understand the trick, could anyone helps?

Subject: Sandbox question on LotusScript web agent

Anyone can help?

It seems that the code can be entered in both if and else condition.


Sandbox question

Posted by Harry Kuolarie on 5.Oct.06 at 11:37 PM using a Web browser

Category: Domino DesignerRelease: 6.5.4Platform: Windows XP

Hi, I am a novice at both Notes and JS, I don’t know if I should post here or in the sandbox, but I really want a quick response for that.

I found a very good sample on Notes Address popup in Web, it is in the sandbox:

http://www-10.lotus.com/ldd/sandbox.nsf/Threads/EFE6B2307D3CD5C985256D9C0062B0D7?OpenDocument

This sample triggers an agent called AddressBook and it builds a dialog box or popup on Notes Address Book (NAB). It’s logic is to read the NAB and write the records to DSO first in Initialize section. Then BuildForm subroutine will read up the record and list out the addresses on the dialog box.

However I just can’t figure out some of the codings under Initialize. As indicated by (??? Qx) in the coding supplied

Sub Initialize

(Declarations …)

Dim nabDB As NotesDatabase

…

nabName = “names.nsf”

nabView = “($People)”

…

Set DB = Session.CurrentDatabase

Set Doc = Session.DocumentContext

(??? Query 1)

If Doc Is Nothing Then

’ For testing only.

Set Doc = DB.CreateDocument

doc.query_string = “OpenAgent&data”

End If

(??? Query 2)

If Instr( Lcase(Doc.Query_String(0)), “&data”) Then

’ read the view and product a comma separated file

Print “Content-Type: text/plain” ’ needed to make this a plain file

'Open the NAB

Set nabDB = Session.GetDatabase( DB.Server, nabName)

Set View = nabDB.GetView( nabView )

’ Output the header

Print “Name,lastName,returnValue”

Set ViewDoc = View.GetFirstDocument

While Not ViewDoc Is Nothing

(Output records to the file)

(Get next Document)

Wend

Else

(??? Query 3)

Call BuildForm

End If

End Sub

Sub BuildForm

(Access DSO to output the NAB dialog box)

End Sub

Q1. Is Doc always nothing on first call to the agent?

Q2. If doc.query_string = “OpenAgent&data” is set after query 1, this inst statement should always be true.

Q3. How come the BuildForm execute? Will the Initialize procedure be executed more than once?

I just don’t understand the trick, could anyone helps?