Script Library DUPLICATE problems! Help!

Hi All,

Imagine the following.

Scipt library (SLA) contains common functions. For example parsing query strings, replace substring routines, item comparisons, etc.

Script Library B (SLB) “uses” SLA.

Script Library C (SLC) also “uses” SLA.

Sometimes I want to use SLB and SLC together BOTH in the same agent. I ALSO have agents that need to use only one of them at a time on occasion. Both SLB and SLC need to make calls to the routines in SLA. And use common constants found in LSS files.

Problem is, when I “use” SLB and SLC in an agent, I get Duplicate symbol errors. I understand why. But the question is, how can I actually avoid this? It seems like a real problem when one wants to truly modularize code.

Any ideas? Do I really have to simply duplicate the functions with unique names for each of SLB and SLC? Doesn’t this defeat the whole value of Script libraries, if they can’t go any further than that?

Similar problems arise if both SLB and SLC need to access a common .LSS file. Duplicate symbol errors arise.

Would love a guru’s input! Thanks.

Subject: Script Library DUPLICATE problems! Help!!

Subject: Script Library DUPLICATE problems! Help!!

U may have to reorganize yr library.

Subject: RE: Script Library DUPLICATE problems! Help!!

I appreciate you taking a moment to respond but saying “you need to do it differently” isn’t exactly a great leap forward :-).

Of course, I realize I can merge libraries, rename routines, etc. But the bottom line is I want to have MODULAR RE-USABILITY. And frankly, LotusScript won’t allow it. No way. No how.

One more reason to write agents in Java!

Subject: RE: Script Library DUPLICATE problems! Help!!

If you prefer to write agents in Java, by all means do so. But I think there are some things you’re not realizing about LotusScript.

Here’s an example of a structure of script libraries such as you describe. There are no compile errors, and it works just fine:

Script Library: A

Option Public

Const ERR_OOPS = 21002

Function Pop

Msgbox "Pop!"

End Function

Script Library B

Option Public

Use “A”

Sub Be(x)

Pop

Print "Be " & x

End Sub

Script Library C

Option Public

Use “A”

Function See(ff As Integer) As Integer

Pop

See = ff + 7

End Function

Agent ABC

Option Public

Option Declare

Use “B”

Use “C”

Sub Initialize

Call Be(See(6))

Print ERR_OOPS

End Sub

Now, %Include doesn’t do anything that you couldn’t do with statements in the code. If you define a name in B, and you define the same name in C, then you’ll have a problem using B and C together in your agent. But if you define a name in A – as I have done – it’s available in B and C and in anything that “uses” them, no problem. LotusScript has no problem with your “using” A twice, indirectly – it realizes they are the same thing.

It only makes sense that LotusScript will complain in ABC if you define the same name in B and C, because then the name is ambiguous. When you refer to it, are you referring to the one in B, or the one in C? Yes, it would be nice if it recognized a Const as having the same value and didn’t bother to complain. But you can also use the Private keyword to keep things from escaping the scope of one library.

Java has a way to disambiguate matching names, because it forces you to create uniquely named classes to put everything into. There are no “naked” names as there are in LotusScript. But in LotusScript, it’s your choice whether to use classes. If you have functions with duplicate names in B and C, you could instead define them as members of differently named classes – then you could use the same name within the different classes, just like in Java. Don’t blame LotusScript for your bad choice of doing a non-object-oriented design!

I’m not saying that LotusScript is as nice a language as Java for OOP. I could list several annoying shortcomings off the top of my head, starting with the inability to create static methods and properties. But it is a quicker language to learn and, in my opinion, easier to use for simple tasks. It’s not nearly as bad as you seem to think; lots of high-quality production code has been written in LotusScript. I myself have written many script libraries which I reuse all the time – most of the good ones contain class definitions. So MODULAR REUSABILITY is by no means out of the question.

Subject: Script Library DUPLICATE problems! Help!!

Hi True :slight_smile:

Maybe I am missing something but what we always do is have a cascaded list of LS Libraries.

So in your case.

in SLC we have use “SLB”

in SLB we have use “SLA”

and obviously SLA does not have any use.

We actually have two lists of cascaded libraries the 1st one is always DB specific called - 0 ozConf.ozNotes.NET

0 ozConf.oznotes.net which uses “1 MemoControl”

1 MemoControl which uses “2 AuthorsandReaders”

2 AuthorsandReaders which uses “3 FormsandViewEvents”

etc. to library 9 which uses “A Agents.ozNotes.NET

Which is the start of the agent code ( non-UI )

“A Agents.ozNotes.NET” which uses “C Common”

So the numbered libraries 0-9 have UI elements, the Alpha A-Z have no UI.

Agents are using “A-Agent.ozNotes.NET”, everything else Views, Forms etc. use “0 ozConf.oznotes.net” so that they get everything & it does not matter in which library it is resolved.

WE have been using this processes for LS Libraries since libraries in 4.x, so about 10+ years & it works really well.

Hope that helps :slight_smile:

ozNotes.NET Team