|
|
|
|
|
|
|
|
|
|
|
|
|
|
Build your own Domino hit counter (continued)
Take it a stage further. You know what the current values of all your counters are. Therefore, you also know what the next 10, 50 or 100 required numbers will be. The DominoCounter has a separate scheduled agent that prebuilds GIF images for the next so many counter images, so that when a Web client asks for a page counter image, odds are that it already exists, ready to be immediately served up.
Two other specific optimizations are made to enhance performance. Typical Perl agents decode a GIF image of the numbers 0 to 9, then encode a new GIF for the required hit number every time the script is called. The Domino Counter does the GIF decode only once, when you load a new digit style, and stores each decoded digit within a Notes document. Also, GIF is typically a compressed graphic format--but for small images the saving of a few dozen bytes is simply not worth the extra time taken to compress an image, so DominoCounter sends out uncompressed GIFs.
Debugging Web agent development can be a tricky process, as can the implementation of another person's agent. To track what an agent is doing, it's good practice to add support for a &debug parameter on the URL command line. In the example of DominoCounter, &debug triggers the full text of any error messages (line numbers for Web agents are even less meaningful than for Notes agents!), and will also return timing information to ease agent tuning. Such support is especially important for a byte-serving agent, since otherwise the user will only receive a graphic image.
Don't forget to wrap some HTML around the debug and error information or it'll all come out jumbled on a single line. And consider, at least for the development cycle, adding in some extra debug fields--for example, set a variable to the name of each module within the code and report that variable in the error handling, so that you can track where the code is halting.
Calling an agent from another database In order to use the page counter from a Notes client under the same conditions as the Web (meaning no write access to the page being counted, and statistics for all clients maintained in the same database) it is essential to call an agent in the DominoCounter database from any other.
There's no direct way either of calling another agent, or to pass parameters and results between one database and another.
The solution is to use the trusty old environment variables beloved by old Notes v2 and v3 programmers, together with some LotusScript. Here's how it's done for DominoCounter.
First, create a text field of type Computed for Display on the form, with a value of:
@Environment( "PageCount")
|
In the QueryOpen event of the form, call the NotesCounter agent using the LotusScript below:
' QueryOpen Code
Sub QueryOpen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Dim session As New NotesSession
Dim DomCount As NotesDatabase
Set DomCount=New NotesDatabase("YourServerName","DomCount.nsf")
PageRef$="MyPageIdentifier"
Forall agent In DomCount.agents
If agent.name="NotesCounter" Then
Call session.SetEnvironmentVar( "AccountRef",PageRef$)
Call agent.Run
PageCount = session.GetEnvironmentString( "PageCount" )
End If
End Forall
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Sophisticated Meets Simple For Document Management
Share. Control. Manage.
Documents, emails, and content in the context of how work is done.
Native to Lotus Domino. The User Experience unseen for Lotus Domino.
Do more with less. Really.
See the possibilities Docova unleashes for Lotus Domino. |
-- Advertisement --
Teamstudio Edition 25 has shipped
It's finally here! Now that Teamstudio Edition 25 has shipped, listen to our latest Tool Time audio program to find out what's changed. Updates to all your favorite Teamstudio tools will be discussed.
Plus, you'll get an introduction to Teamstudio Undo (formerly known as Teamstudio Snapper).
Tap here to get started! |
|
|
|
|
|
|
|
|
|
|