Are Global Declarations available in Script Libraries

As I understand this, a Global Declaration in a form should be available in all the Script Libraries used. If so, why isn’t this one:

Form’s Options: Use “LibUtil”

Form’s Global Declarations: Dim s As NotesSession

Form’s Queryopen: Set s = New NotesSession

LibUtil, Sub updateResource: Set resourcename = s.CreateName(res)

When this last line executes, I get Variant does not contain an object because s is not initialized.

s is not being declared anywhere else. (I lie, it’s declared in other Subs in the library, but that’s not relevant).

How can I reuse s, without getting that error which means I’m declaring duplicate names?

Thanks,

-Jeff

Subject: Are Global Declarations available in Script Libraries

s will not be visible to the functions declared in the script library - that has its own scope and you will have to declare it and initialize it in the script library. Mind you, if you do declare it Public (or default) in the script library’s Declaration section, you will essentially “export” it for use in whatever script uses that script library and thus save yourself the need to declare and initialize s in the Form.

Subject: RE: Are Global Declarations available in Script Libraries

Mind you, if you do declare it Public (or default) in the script >library’s Declaration section, you will essentially “export” it

for use in whatever script uses that script library

So it is global upwards, but not downwards (unless declared Private)?

That explains quite a few problems I’ve had in the past.

Subject: RE: Are Global Declarations available in Script Libraries

So it is global upwards, but not downwards (unless declared Private)?

Yes, I suppose you could put it that way. But it only works for Script Libraries.

For example, you can use a Subform within a Form but Script variables declared globally in either will be visible only in their own scope and not to each other.