Tuesday, December 22, 2009

%INCLUDE Directive in Lotusscript

The purose of %Include directive is to inserts the contents of a text file into the module where the directive appears at compile time.

I have never used this in any of my projects, but still I feel that this could be a very useful tool when it comes to over coming certain size limitations of lotus notes.

Following are a few scenarios that I could think about,

(1) The 32/64k limit applies to all events within an object.
(2) An object is anything with its own events.
(3) Buttons, forms, fields, and agents are all separate objects and have their own 32/64k limits.

For example, if you have code in the QueryOpen, PostOpen and QuerySave events within one form, all these count toward the form's 32/64k limit because they are all events for the form object.

Following is a procedure that might help you to understand how you can use %INCLUDE directive to by pass the above mentioned limitations
1) Put the script in a text file and use the LotusScript %include command to load it. This script is not counted toward the memory limit. This is definitely the best workaround.
2) Put pieces of the script in entering events of hidden fields and use the LotusScript GotoField method to trigger the scripts.
3) Put additional scripts in subform events and embed the subforms in the form running into the memory limit. For example, if you're running out of space in the form object and wish to place more script in the PostOpen event, create a subform, place the desired code in its PostOpen event and insert the subform into the form.

The following is shall help you with a simple illustration, which will give you a more clear idea of %INCLUDE directive

1. Open a form in Lotus Notes Designer
2. Add a button to it
3. In the Options event add the following code
%INCLUDE "C:\customLss.dat"
4. In the onclick event add the following code
Call alert()
5. Open a notepad and put the following code in the same
Function alert()
Msgbox "this is from a text file called using %include directive"
End Function

6. Save the file as "C:\customLss.dat"
7. Preview the form in the Notes Client and click the button
8. You will get an alert displaying the following text "this is from a text file called using %include directive"
9. This indicates that the code fragment present in the text file, that you have put on the note pad had executed

No comments:

Post a Comment