LotusScript.doc article draft is going back to The VIEW

I sent the article draft back to my editor at The VIEW yesterday and I must admit I was a little surprised as to the number of corrections she had made and that I had to look at. I ended up writing quite a lot of new content both clarifying existing points and making new ones.

It will be exciting to hear her thoughts on the added content.

LotusScript.doc release candidate 2

Release candidate 2 is just about to be released. The release contains a number of big improvements which include support for %INCLUDE files (also if nested), support for Page design elements and support for the Shared Actions design element.

Refer to to the changelog below for details on all improvements and bug fixes.

Thanks to all submitting comments, bug reports etc.

CHANGELOG – Release candidate 2

Fixes

  • Change how a REM-section is recognized to avoid problems with TAB-characters etc. efter the %REM / %END REM (Lukas Martin).
  • Added design element “namespace” handling to avoid generating the same key for different design elements with the same name (e.g. a form and an agent). (Chad Schelfhout)
  • Fix problem with page titles and generating four html documents per form, view, agent and script library.
  • Fix issue where name of function contained the returntype as well when the function didn’t contain any parentesis’ (e.g. Public Function MyFunction As Boolean)
  • Properly handle arguments to class properties (James White).

Improvements

  • Show known sub-classes for a particular class in the documentation.
  • Show icon in view for Configuration documents included in background run.
  • Provide action to go to the Documentation Index on the web.
  • Sort list of design elements alphabetically when selecting subset of design elements in Configuration document (Torben Bang).
  • Improved @-parameter parsing (tab/spaces)
  • Add support for @author parameter
  • Add support for Page design element.
  • Add support for Shared Actions design element.
  • Support for %INCLUDE files incl. nested %INCLUDE files (James White).

Known sub-classes in LotusScript.doc

When I wrote that I wouldn’t be adding more features before the release I must have been dreaming… I just couldn’t resist adding code that make it possible to see the known sub-classes of a particular class when browsing the documentation.

This makes it much easier to navigate to the sub-classes of an “interface-style” super-class as shown above where “SaveDecorator” is actually just describing the interface for the “NoAttachmentsSaveDecorator”- and “ReferencesSaveDecorator”-classes.

All this information in just 10 lines of added code – I love objects!!

LotusScript.doc Release Candidate 1

I just shot of an e-mail with LotusScript.doc release candidate 1 to the “beta” testers a few moments ago. This will hopefully be the last release for general release – changelog below.

Fixes

  • Make sure code isn’t parsed inside %REM-sections to avoid parse errors due to invalid code inside %REM-sections (Julian Buss).
  • Make sure the implicit datatype of Variant for arguments is set if an argument to a sub or function doesn’t have a datatype implicitly specified.
  • Fix issue with return type in functions having an array as an argument.

Improvements

  • Move all constants into “CLASS: LsDocConstants” script library (Alain Romedenne).
  • Make it possible to write the documentation block inside the function or sub if the function or sub is not inside a class. This allows you to keep the comment with the function or sub when copy/pasting code (Thomas Dufner).
  • Added sorting of method/function/property names in class detail pages.
  • Updated documentation.
  • Performance improvements when generating documentation in the background on the server.
  • Support for only outputting documented types (classes, subs, functions) in HTML documentation.
  • Support for ignoring private members when outputting the documentation.

I know there are some outstanding feature requests but I would rather get the tool out now than keep adding new features. I hope for your understanding.

Implementing a Bag in LotusScript

A Bag is a collection that keeps track of the number of times each element occurs in the collection. The name was inspired by the Bag implementation from the Apache Jakarta Commons Collections.

Please note that this is a quick implementation and it only handles simple datatypes – no support for objects at present.

The code is of cause documented using LotusScript.doc… 🙂

'/**
' * Implementation of a bag that is a collection that keeps track of the
' * number of times an element occurs in a collection.
' */
Public Class Bag
   'declarations
   Private pElements As Vector
   Private pElementCount List As Integer

   '/**
   ' * Constructor.
   ' */
   Public Sub New()
      Set Me.pElements = New Vector()
   End Sub

   '/**
   ' * Adds an element to the bag.
   ' * @param e The element to add.
   ' */
   Public Sub AddElement(e As Variant)
      'declarations
      Dim hash_e As Variant

      'add the element to the vector
      Call Me.pElements.AddElement(e)

      'do we have a count for this already
      If Not Iselement(Me.pElementCount(e)) Then
         'we do not have a count
         Me.pElementCount(e) = 1
      Else
         Me.pElementCount(e) = Me.pElementCount(e) + 1
      End If
   End Sub

   '/**
   ' * Get a count of the number of times an element occurs in the bag.
   ' *
   ' * @param e The element for look for.
   ' * @return Count of the times the element occurs (0 if it doesn't occur)
   ' */
   Public Function GetCount(e As Variant) As Long
      'declarations
      Dim hash_e As Variant
      If Not Iselement(Me.pElementCount(e)) Then
         GetCount = 0
      Else
         GetCount = Me.pElementCount(e)
      End If
   End Function

   '/**
   ' * Returns an array of the unique elements added.
   ' *
   ' * @return Array of unique elements added.
   ' */
   Public Function GetUnique() As Variant
      Dim v() As Variant
      Dim i As Integer
      Forall k In Me.pElementCount
         Redim Preserve v(i)
         v(i) = Listtag(k)
         i = i + 1
      End Forall
      GetUnique = v
   End Function

End Class

Small fix to Johans Vector class

Small fix to the removeElementAt(Integer) method – changes in bold.

Public Function removeElementAt(index As Integer)
   If index >= Me.size() Then Error 2000, "Array index [" & index & "] out of bounds [" & size & "]"
   Dim members As Variant
   Dim i As Integer
   Dim j As Integer
   Redim members(Me.size())
   j=0
   For i = 0 To Me.size-1
      If (i  index) And (Not j > Me.size()) Then
         If Isobject(array(i)) Then
            Set members(j) = array(i)
         Else
            members(j) = array(i)
         End If
         j = j + 1
      End If
   Next i
   elementLength = elementLength - 1
   array = members
End Function

Programmatically detecting AutoSave

The below excerpt is from the article “All about AutoSave in Lotus Notes/Domino 7” on Lotus Developer Domain:


Only documents created from forms with Allow AutoSave selected can be autosaved. This is the only way to ensure that the document can be recovered after it has been autosaved. Many Notes/Domino applications have code in their Save and Post Save events that create items, or perform validations that are checked at load time. Because we can’t execute these events while autosaving the document, none of this will take place, and the autosaved document will be in a “bad” state. This could lead to failing to load the document after recovery.


If your application does write items on save events, and it’s dependant upon these item, you may need to add code in your Query Open event to put defaults for those items. You can even do special handling only for documents that are recovered by looking for an item called $AutoSaveRecovered. This item will only be available for recovered documents up until the Post Open event, and will be deleted after that.


Another way to programmatically disable AutoSave on individual documents is by adding the item $DontAutosave. This item prevents AutoSave on that document. If you remove $DontAutosave, the document can again be autosaved.


NOTE: In Notes/Domino 7.0, the only shipping template form that is enabled for AutoSave is the Memo form.

Nice to know that fields has been added to detect whether a document is being recovered via AutoSave.

Sorting document collections in LotusScript

Another option to the function in NotesDatabase was to use the FTSearch() method in NotesView but this method behaves different depending on whether the database is full-text indexed or not. Apparently the sorting of the view is only honored for the search results if the database is NOT full-text indexed. Why this distinction? Why not give me the option?

Anyways… The solution was to use the FTSearch() method in NotesDatabase as I started out doing and then using a function I found via Lotus Developer Domain that can sort a NotesDocumentCollection based on field names.

The function is written by Max Flodén and is available from http://www.tjitjing.com.