This week on developerWorks!

On the This week on developerWorks! podcast for August 23rd Scott Laningham talks to Tara Hall about the release of Sametime 7.5 (shownotes). At only around 6 minutes in length the podcast is short but offer some nice information about the Sametime 7.5 SDK and links to an article on using the new SDK (Extending IBM Lotus Sametime Connect V7.5),

Be aware though! The Sametime 7.5 SDK weighs in at around 160 MB but it also contains 10 toolkits.

Changing domain names

I’m in the process of changing this blog from its old domain name at blog.lekkim.heisterberg.dk to its new domain name at lekkimworld.com so please update your bookmarks / aggregator accordingly. My Apache is currently setup to redirect the base blog URL and the RSS feed but at some point I will be removing that functionality. New URLS are as follows:

  • RSS: http://lekkimworld.com/rss.xml
  • Blog: http://lekkimworld.com

Thanks!

Suggestions for the GURUpalooza! Lotusphere session

Basically I think that with only one hour (or 90 minutes) set aside for the GURUpalooza! it would be nice and a better experience if attendees could submit the questions in advance. It was my understanding that many of the questions asked during the session…

  • should really have been asked during the week in the “ask the developers” lab (asked in the wrong forum)
  • was too specific (too many details which made the question impossible to answer without taking too much time)
  • was too unspecific (too few details which made the question impossible to answer without taking too much time)

Another point is that it seemed difficult for the “gurus” to decide who should answer the question. Posing the questions in advance would mean that questions could be assigned to the “guru” best suited for the question and questions could be (slightly) modified to make them more of less specific. The “gurus” would probably also like to combine some questions to make sure as many as possible got their question asked and answered. Answering as many questions as possible must be the main purpose of the session.

Another idea could be to hold more than one session – maybe even one per day like a returning BoF-type session. As I recall it, very few of the questions posed were actually related to any of the sessions presented during the event so having at least one more session earlier in the week wouldn’t be too much of a problem. Dividing up the “gurus” into smaller groups for a daily GURUpalooza! could also mean that more people could be “served” during the week without burdening the “gurus” too much. It would probably also take some of the pressure of that last session before the closing session.

Anyway – this is some ideas I have been playing around with. What did you think of the session?

Mark Ambler: Using LotusScript to import an image resource

I just saw that Mark Ambler wrote some code to import an image resource into a Notes database using DXL. It complements the code I wrote some time back to export an image resource from a database using DXL (Helping out a fellow blogger getting the actual bytes of an image resource – a lesson in the intricacies of DXL representation).

See the post for the complete code: Using LotusScript to import an image resource

Show ‘n Tell Thursday: Finding the “My Documents”-folder (17 August 2006)


Finding the correct path to write the file to when writing export routines or other routines that write files to the active users computer has always been a problem. Normally I have ended up using a path from a user profile document or by simply using the root of the C-drive. This has served me well but the optimal solution would be using the “My Documents”-folder of the user instead. This alliviates a number of problems that might otherwise occur:

  • The user may not have a C-drive
  • The user may not have permissions to write to the C-drive
  • The user may expect the file to go some place else than the root of the C-drive

Using the “My Documents”-folder is now the preferred way to doing it from my perspective. So how do we get at the actual path of the folder? You could use the HOMEDRIVE and HOMEPATH environment variables like this:

Dim export_path As String
export_path = Environ(|HOMEDRIVE|) + Environ(|HOMEPATH|) + "My Documents"

This will work for many users but not on my machine since I have remapped the location of the “My Documents”-folder to C:Data (the above will result in “C:Documents and Settingslekkim.HQMy Documents”). It also wouldn’t work if the users “My Documents”-folder has been mapped to a network location via Active Directory policies.

As it turns out it is a little difficult to get the location of the users “My Documents”-folder since there isn’t an environment variable that holds this piece of information. The solution is to use the SHGetFolderPath function of the Windows API.

Start by declaring the function in the Declarations section of your code. Also declare a number of constants for the “My Documents” and “My Pictures”-folders:

Declare Function SHGetFolderPath Lib "shfolder.dll" Alias "SHGetFolderPathA" (Byval hwndOwner As Long, Byval nFolder As Long, Byval hToken As Long, Byval dwReserved As Long, Byval lpszPath As String) As Long
Private Const MY_DOCUMENTS& = &H5
Private Const MY_PICTURES& = &H27
Private Const HWND_CURRENT_WINDOW& = &H0

Since the returned string will be 0-terminated as C-strings are we need a utility function to crop the returned result:

Private Function TrimNull(startstr As String) As String
   Dim i As Integer
   Dim char As String
   For i=Len(startstr) To 1 Step -1
      char = Mid$(startstr, i, 1)
      If Asc(char) = 0 Then
         TrimNull = Mid(startstr, 1, i-1)
      End If
   Next
End Function

Finally we need a utility function to make it easier to call the SHGetFolderPath function:

Private Function GetFolderPath(folder As Long) As String
   'declarations
   Dim buff As String

   'fill buffer with the specified folder item
   buff = Space$(256)
   If SHGetFolderPath(-1, folder, -1, &H27, buff) = 0    Then
      GetFolderPath = TrimNull(buff)
   End If
End Function

Putting it all together means that we can get the “My Documents” or “My Pictures” folder as easy as the following:

Dim export_path As String
export_path = GetFolderPath(MY_DOCUMENTS)
Msgbox "My Documents is at: " & export_path

export_path = GetFolderPath(MY_PICTURES)
Msgbox "My Pictures is at: " & export_path

That’s it! You can get more constants for the SHGetFolderPath function by looking up the function in a Windows API reference.

AutoPurge for OpenLog

We are using the OpenLog logging framework written by Julian extensively in our applications but in logging intensive applications or when running with our custom DEBUG-level enabled you can generate a lot of logging documents. Cleaning these up should preferably be done automatically on a scheduled basis so I wrote a small agent to purge log documents older than 6 months and thought I would share:

Sub Initialize
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim dc As NotesDocumentCollection
   Dim dt As NotesDateTime

   Set dt = New NotesDateTime(session.International.Today)
   Call dt.AdjustMonth(-6)
   Set db = session.CurrentDatabase
   Set dc = db.Search(|Form="LogEvent" & LogEventTime<@TextToTime("| + dt.DateOnly + |")|, Nothing, 0)

   Call dc.RemoveAll(True)
End Sub

Really simple and nothing much to it…

Google Analytics

The by-invitation-only entry to Google Analytics has been removed so anyone who wants an account may have one. For those who do not know what Google Analytics is, it’s a free, totally cool web statictics package from Google. Installing it takes 2 minutes and is done by copy/pasting some JavaScript into your page layout. I highly recommend it.

To read more stop by the Google Analytics blog.