Beware of object scoping in Visual Basic

I’m doing some Visual Basic programming in Microsoft Word at the moment and spent some time on Friday trying to find out why all my objects (based on a Visual Basic class module) apparently had the same values. Apparently the following doesn’t work:

Dim col As New Collection
Dim i As Integer

For i=0 To 10
  Dim obj As New Person
  obj.Firstname = "Firstname" & i
  obj.Lastname = "Lastname" & i
  Call col.Add(obj)
Next

If you run the above code all the objects will hold Firstname10 and Lastname10 in their class variables. The solution is to do this instead:

Dim col As New Collection
Dim obj As Person
Dim i As Integer

For i=0 To 10
  Set obj = New Person
  obj.Firstname = "Firstname" & i
  obj.Lastname = "Lastname" & i
  Call col.Add(obj)
Next

The difference is that in the latter example the definition of the Person reference is done outside the loop while both the definition and the instantiation is done inside the loop in the first example. While both of the above cases are quite okay in LotusScript, and works as you would expect, you apparently have to define the reference outside the loop in Visual Basic for it to work. Why that would be the case is unclear to me…

Oh well… ๐Ÿ™‚

Microsoft Exchange protocol has been opened up

As you might have heard a number of Microsoft proprietary protocols has been opened up (incl. the protocol used for Microsoft Exchange Server) as reported on Slashdot and on Redmond Developer News. This would make it possible, as actually mentioned in a Notes 8 session at Lotusphere 2007, to make Notes 8 a client for Exchange since the Notes 8 client (read Lotus Expeditor) is actually very generic.

But then again who would want to run against Exchange Server? ๐Ÿ˜‰

Via the Java Posse episode 110.

Anyone who have used the Deftype statement in LotusScript?

While looking for something completely else in the Domino Designer 7 Help I stumbled over the Deftype keyword. I find it hard to find any usage for it but then again I always code with Options Explicit/Declare and type all my variables but still… Anyone who have actually used it and can give an example?

Deftype Statements
Set the default data type for variables, functions, and properties whose names begin with one of a specified group of letters.
.

Problem managing your feeds? Look to the dinasaur report!

At the blogger BOF at Lotusphere 2007 a question was asked as to how one keeps up with all the blogs. The first part of the answer is to use a feed reader such as FeedDemon and the other part is to clean up regularly. Since it can be a problem to know which feeds aren’t updating you need some kind of tool. Again FeedDemon comes to the rescue.

I just upgraded to FeedDemon 2.5 Beta 1 for one feature, and one feature alone – the Dinosaur report. I installed the beta over my existing FeedDemon installation and loaded up the report and man have I been waiting for this! The report shows you all the feeds that haven’t been updated in a certain period of time and lets you easily unsubscribe from them. The report can be adjusted to show feeds that haven’t updated in 10, 30, 60, 90 or 120 days. This simple, yet powerful, feature allowed me to quickly unsubscribe from 76 feeds that haven’t been updating in 90 days. Nice!

TCP connection leakage with Corba sessions?

Saw an interesting post (how to close lotus.domino.Session in Java application?) on notes.net from a developer who is wondering how to avoid TCP connection leakage with a lotus.domino.Session pool. Only thing I could come up with is recycle() and nullifying. I haven’t had problems with connection leakage in similar situations but I guess it is possible.

Does anyone know of a way to force closure of the TCP connection?