Search This Blog

Thursday, January 23, 2014

Always do recompile of all lotusscripts after change of any lotusscript constant

Hello guys

At first I wanted to write a post about new issue in LotusScript I found today but after double check with documentation I had to calm down :-) Really, RTFM first.

The case is about using of constants in lotusscript.

Let's imagine that you have two Script Libraries. The first SL has some constant in (Declarations) and the second SL uses the first SL. If you change the constant in the first SL you NEED to resave/recompile the second SL, otherwise the second SL will remember the old value.

Check my screen shots below


1) Two Script Libraries

2) SL "1" contains Const in (Declarations)

3) SL "2" Uses "1" and prints "A"

4) TestAgent for check the value of A 

5) Let's check what agent returns right now. It is "1" - correct

6) Let's change constant A in the "1" SL to something else - do not resave SL "2" after that.

7) Run TestAgent again - still "1" - WRONG!

 This is not a bug. It works by design. If you check native documentation you may find the following remark about using of constants in lotusscript:

...
The value of a constant is actually compiled into the object code. If you want to change the value of a particular constant, all modules that use that constant must be recompiled.
...

The funny thing regarding my example is that when I completely removed SL "1" my TestAgent worked anyway. I think the reason of that is that any public constants are saved in object code of EVERY design element that has any references to the SL with constant definition.

No comments:

Post a Comment