PermaLink Option Declare12/29/2005 10:14 PM
None

Option Declare is a great thing. It helps to keep you from making stupid mistakes and makes you think about the code you write and the variables you use rather than just using variants everywhere. Even better is the option introduced in Notes 6 where Designer will automatically put "Option Declare" in for you for all the new script you create.


There seems to be an bug, however, in ND6 and 7...... "Option Declare" doesn't seem to have any effect on shared actions......


I discovered this problem while trying to get to the bottom of a performance issue regarding a set of views. The issue was that a couple of views were taking an extremely long time to load. When I say extremely, I'm talking 5-10 minutes. There was nothing really special about these views except that they had a large number of LotusScript shared actions on them. After a little investigation, I noticed that the actions weren't compiled correctly...
Actually, the actions were not compiled at all! Turns out, each of these actions was a single line of script which called a general purpose function in a script library:

Sub
Click (Source As Button)
     
UICreateActionDocument "actACL", ""
End Sub


There are about 15 actions that all do the same thing, but pass a different string in as the first parameter. Consequently each of the actions is just a copy of the original action shown above. The problem was that I forgot the
Use "UITools" statement in the Options section. However, this fact went unnoticed for weeks because the views that these actions are used on all have the Use statement in the View Global script section. This allowed the action to work because Notes recompiles script on the fly if the compiled code is missing. The performance issue came in due to the fact that for each action, Notes reloaded and recompiled each one. Because of the other libraries that the UITools library depends on, recompiling a single action takes a bit of time. Doing it 15 times over takes forever....( well maybe just 5 minutes, but still.... ).

It turns out that, even though each of the actions had Option Declare specified, Designer didn't let me know it couldn't resolve the symbol name. This goes for any of the common issues that Option Declare is supposed to catch. The code:

Sub
Click (Source As Button)
      Print
x
End Sub

Doesn't trigger any warnings either.


Discovering the problem isn't really that easy. Using the "Recompile All LotusScript" function in Designer 6 doesn't help, you have to actually know there is a problem. In my case, it took longer to discover because the functions are so short. If they were longer there would have been a greater chance of a typo or somethign [;)] that would have caused the runtime compiler to throw an error.


So, to help identify the problem actions better I created a small little utility that will scan your database and identify all the LotusScript actions that are not compiled. You can get it
here or the left side under the 'Free Tools' section.

This page has been accessed 1171 times. .
Comments :v

1. Duffbert12/30/2005 06:05:39 AM
Homepage: http://www.twduff.com


You flat-out rock! :)

Thanks!




2. Craig12/30/2005 10:39:28 AM
Homepage: http://blogs.teamstudio.com


Thank you, Mr. Duff!
Does that mean this is something you have run into also? I'm wondering how prevalent this is?




3. Lars Berntrop-Bos12/30/2005 07:44:48 PM


Also, if you specify Option Declare and set the theoption in the designer, then add Action hotspots to a form =>
1 - no option declare inserted
2 - no error checking ala above either...




4. Joe Litton12/31/2005 03:52:06 PM
Homepage: http://joelitton.net/


I've noticed this bug all over the place - not just shared actions. I've had Designer set to automatically insert Option Declare ever since that selection was available. I've not determined just when it does/doesn't insert Option Declare ...so I always check. I know that in form actions and events I've had to (at least at times) explicitly add Option Declare. I'll try and pay better attention to when this error pops up and document it.




5. Wild Bill01/02/2006 09:05:11 AM
Homepage: http://www.billbuchan.com


Wow - nice one!

---* Bill




6. Sjef Bosman01/02/2006 12:16:36 PM


Same misery here. Usually though, the Compile all LotusScript action does wonders.

I don't know if it's the same problem, but if I need a quick solution, I change the name of the Script library, move one line up, one down, and change the name back again. The designer "knows" the line has changed and will re-evaluate the scriptlibrary. Seems to me the designer cache that has some flaws.

There's another intersting issue with shared actions:
http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_21541870.html




7. Chris Doig01/03/2006 06:52:01 PM
Homepage: http://chrisdoig.net


A few years ago at Lotusphere I asked one of the Notes development team about this problem. He confirmed the observation, and supplied a fairly reasonable reason why Lotus had done it that way. But I'm sorry, I can't recall the reason...




8. Jens01/07/2006 12:04:40 PM
Homepage: http://www.ligonet.ch


Chris is right.

This issue came up sometimes in the Business Partner Forum and there someone from development (maybe it was even Maureen herself) explained it. And Craig gave the example just in the main posting: For shared actions the scope of variables is not defined during development time. As Craig has correctly seen, if you put the shared action inside something other, there may be Global Variables declared, which may be available inside the scope of the shared action at runtime, and thats why the Option Declare is by purpose disabled for Shared Actions. That makes sense. Unfortunately, they have not documented that adequately. In fact, I think, Designer should not accept "Option Declare" at all inside a shared action to account for the situation.




9. Dallas Gimpel01/12/2006 11:24:39 AM


@Jens -- I got a similar explanation from Wai-Ki Yip at the Lotusphere Labs. Makes sense, but I agree that it should be more clearly documented.




10. Craig01/16/2006 08:32:24 AM
Homepage: http://blogs.teamstudio.com


I agree that there could be valid uses for this, but I still have issues with the implementation. Breaking an existing feature to implement a different one doesn't seem to be the right choice... The answers some of you have gotten from IBM/Lotus sounds like an excuse to me.




Contact Me
Free tools!
The BlogRoll
Lotus Domino ND6 RSS News Feed netcraft Lotus Geek Chris. A. Brandlehner CoComment Integrated
Monthly Archive
Photo Albums