I have a script library containing the following function:--------------Cut-Here---------------------
'PacaGeneral:
Option Public
Option Declare
%INCLUDE “LSCONST.LSS”
%INCLUDE “LSERR.LSS”
Function ReadConfigDocument As Variant
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
ReadConfigDocument = False
Set db = session.CurrentDatabase
Set doc = db.GetProfileDocument( "TEST", "TEST" )
ReadConfigDocument = True
Delete doc
Delete db
End Function
--------------Cut-Here---------------------
I have an agent that uses the script library. The agent code is…
--------------Cut-Here---------------------
'Change Supplier:
Option Public
Option Declare
Use “PacaGeneral”
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
'Read the configuration document
If Not ReadConfigDocument() Then
End If
If db Is Nothing Then
Messagebox "DB is Nothing"
Else
Messagebox "DB is SET"
End If
Print "Done."
Beep
End Sub
--------------Cut-Here---------------------
It is my understanding that the scope of a variable in a subroutine/function using the “Dim” statement is private.
However, when I excute the code above, the “db” object in the agent is deleted outside the scope of the ReadConfigDocument function upon the return from the function.
Shouldn’t the “db” and “doc” objects in the ReadConfigDocument function be local and private?
Should the “Delete” statements in the function affect the agent objects?
What did I do wrong? or what don’t I understand?
Help!