%Include in actions

I must admit that I have never been a big fan of using the built-in include files supplied with Notes e.g. lsconst.lss but recently I have started using them to make my code more readable. Using the include file you can write

Dim rc As Integer
rc = Msgbox("Should we continue deleting the contents of your harddrive?", MB_YESNO+MB_ICONQUESTION+MB_DEFBUTTON2, "Continue?")
If rc=IDNO Then
  Exit Sub
End If

which is much more readable than the same code without the constants but using magic numbers.

Dim rc As Integer
rc = Msgbox("Should we continue deleting the contents of your harddrive?", 4+32+256, "Continue?")
If rc=7 Then
  Exit Sub
End If

Today however I realized that you cannot use the include files in (form) actions since the compiler does not allow the use of the Public keyword. All constants in lsconst.lss is defined as Public so that’s a no go. Copying lsconst.lss to something like friendly_lsconst.lss, removing the use of Public and the reference at the bottom to lsprcval.lss and including the copy instead solves the problem. This restriction isn’t documented in Domino Designer help and severely limits the usability in my mind. Since the constants are inserted at compile time it shouldn’t be a problem.

Below is a screenshot of the compile error from Domino Designer. I’m running Notes 7.0.2 on Windows XP Prof. SP2.

3 thoughts on “%Include in actions”

  1. Personally, I always assume that you can’t rely on an external file being there. If I want to use lsconst.lss, I always import it into a script library, and “Use” it, rather than using “$Include”.

  2. I would recommend the use of one script library that includes all the constant libraries

    %INCLUDE “lsconst.lss”
    %INCLUDE “lsxbeerr.lss”
    %INCLUDE “lsxuierr.lss”
    %INCLUDE “lserr.lss”

    I did this because I was including the constants into multiple script libraries, forms and views. Domino would error when the include overlapped. Example: create two script libraries that both include the lsconst.lss, then use both script libraries in third and duplicate name error will appear.

Comments are closed.