01/19/2006

NSFDbOpen call from LotusScript - A GOTCHA

Category
Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 


For those of you who write LotusScript aand make calls to the Notes API, here's a little tip about a call that you'll use all the time.

I was trying to work out why some code I use to retreive the Usage Stats of some database ALWAYS caused my client to produce an NSD. When I looked at the FilePath of the databases it was clear what the possible problem was. The databases had been created on servers mostly used by French speakers (no, that's not the specific problem ) and so, they contained Extended ASCII characters ( i.e. non-English characters) such as é, è.  That is, characters with an ASCII value greater than 127.

The API declaration I had was

Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval dbName As String, hDb As Long) As Integer

which caused the NSD, but, when I changed the declartion to

Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval dbName As Lmbcs String, hDb As Long) As Integer

everything was OK.

Without making this subtle change and passing the FilePath of the database as a Double-Byte Character, the whole thing blows up, but, with the change, all is well.  

12/18/2004

Time to give something back.

QuickImage Category
Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 


Over the past few years I've gleaned a lot of useful information (and I'm talking about code snippets here) from many of the Domino Gurus. I'm talking specifically about:

1.        Ferdy Christant
2.        Joe Litton
3.        Julian Robichaux
4.        Rocky Oliver
5.        ...and all the others (sorry, I'll get 'round to linking to your site "as-soon-as-I-can")

It's about time I started contributing to these "gems of code information" myself. So, as a start.

For those of you who are continually writing LotusScript code to "fix up" some problem - developer generated or (God forbid) uses created - data problems where you set off a server scheduled agent to stroll through hundreds - no thousand - no tens of thousands - of documents and update just a few, and you're wondering how far through the process it's gone, well here's an alternative to using the Print statement in LotusScript (where the output is all prefixed with

10/12/2004 04:00:16 AMgr: Agent ('The name of this agent' in 'The full filepath of this agent' ) printing: The message you wanted displayed on the server console and in the log

you can use this simple API call to just write the text you want to the server console.

'Console log text
Declare Sub W32_LogConsoleMessage Lib "nnotes.dll" Alias "AddInLogErrorText" ( _
Byval strMessage As String , _
Byval intNoError As Integer )

Sub PrintToConsole ( strMessage As String )
    'Writes to the server console (and log)
    Dim intNoErrorReturned as Integer
    If Not ( Len ( strMessage ) = 0 ) Then
            Call W32_LogConsoleMessage ( strMessage , intNoErrorReturned )
    End If
End Sub

I know this is relatively simple but I wanted to start of this way in order to gauge the response! If it proves to be useful to others then I'll publish more. If not ......well, that means more time with my wife (I know she checks this blog every no-and-then so I'm not going to make the derisory comment that flashed across my befuddled and confused old brain) and the kids.

Oh, I don't think I mentioned but my eldest "kid" (she's almost 19 now) is back from University for the Christmas break! Oh, yet MORE joy (not)!