Most Notes/Domino developers have probably been in this situation: you are creating an agent that is running both on the server as a scheduled agent, and manually launched on the client. On the server you want to displaysome information on the console, using the Print statement.Butsincemost regular users do not look at the status bar and read the output of print statements, youwant to display the informationto the user usinga message box. This way,when the agent is launched manually, the userhave time to read it.
Here is my solution. Nothing fancy, but it works for me. I simply create a small function that check if the code is running on the server or not, and execute slightly different code. I also use Getthreadinfo() to get the name of the calling procedure to display in the title.
Sub PrintMsg(text As String)
Dim session as New NotesSession
If session.IsOnServer() Then
Msgbox text,,Getthreadinfo( LSI_THREAD_CALLPROC )
Note: You need to include LSCONST.LSS for the constant LSI_THREAD_CALLPROC to be available.