Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Lotus Script Libraries error messages

Posted on 2007-04-04
Medium Priority
Last Modified: 2013-12-18
I have a lotus script program that uses an dll file, this is referenced with the command
Uselsx "*RFC"

This works fine, but if the users are either missing in the registry entry or dll file, then they get a generic message. Is it possible to find a way to create a new error message explaining to the user how go solve this issues. Or is their a way to check for this file.
Question by:PETAdmin
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 22

Accepted Solution

Bill-Hanson earned 500 total points
ID: 18850034
Does the library load at all for the users that are missing the file?  What is the error message?

If you just need to check for the existance of a file, that is easy.  Here's a simple function that will test for a file:

Public Function FileExists(fileName As String) As Boolean
      On Error Goto NO_FILE
      FileExists = False
      If (Trim(fileName) = "") Then Exit Function
      If (Dir$(fileName, 0) <> "") Then FileExists = True
      Exit Function
      FileExists = False
      Exit Function
End Function

Author Comment

ID: 18850182
I don't believe that the library does load when the file is missing. The exact error message is Error Loading USE or USELSX module: *RFC.

But I certainly like your solution for checking for the file, since it should be located in the same place for all users, something perhaps I can run on database open.

But it would be nice if their was a way to error trap the message, and to give to the user a more useful error message, that tell them how to solve this issue. But since the USE command is based in the options section I guess this might not be possible?
LVL 22

Expert Comment

ID: 18850435
Sorry, it's not possible to detect when a library won't load, but there may be a work-around.

You could split your operation into two stages.  One stage checks for the existance of the required components and the other does the work if the first stage passes successfully.

Here's one way to accomplish this.

1.  Create 2 agents.
2.  In one agent, check for the existance of the file and write the status to an environment variable.
3.  In the other agent, do your operation.
4.  Assuming that you're using an action button to start the operation, you can use an @Formula like this:

@Command([RunAgent]; "CheckRequirements");
bProceed := @If(@Environment("REQUIREMENT_STATUS") != "PROCEED"; @False; @True);
@Environment("REQUIREMENT_STATUS"; "");
@If(bProceed; @True; @Return(0));
@Command([RunAgent]; "YourAgent");
LVL 22

Expert Comment

ID: 18850595
Another thought:  If your code is in a class, you might be able to use a dynamically loaded class.

This is a bit advanced and causes your code to be late-bound which can be a bit slower, but might solve your problem in a more elegant manner.

I use classes for just about everything complicated.  Here's how I instantiate a class in one LotusScript library from another one without using a Use statement in the Options event:

1.  Declare a global variable (Declarations) in the same library that contains the LoadClass function below.

Public objFactoryClass As Variant ' Temporary storage for dynamically-loaded classes.

2.  Here's the function I use to load a class at run time:

Public Function LoadClass(Byval className As String, Byval libraryName As String) As Variant
      ' * Dynamically loads a class.
      ' * <p></p>
      ' * Use this function to get a class instance when the class you
      ' * need is not defined in the current library.<b>
      ' * Note: The class's constructor cannot accept any parameters.
      ' * @param className The name of the class to load.
      ' * @param libraryName The name of the library where the class is defined.
      ' * @return A new instance of the specified class.
      ' */
      Dim code As String
      code = |Use "| & libraryName & |"
              Set objFactoryClass = New | & className
      Execute code
      Set LoadClass = objFactoryClass
      objFactoryClass = V_EMPTY
End Function

3.  I have not tested this, but you might be able to trap the error (On Error ... Goto) when the library is loaded on the "Execute" line.

Come to think of it, you could use this technique in conjunction with the first workaround instead of testing for the actual file. In agent 1, you could try this:

Sub Initialize
      On Error Goto CATCH
      Dim sess As New NotesSession()      
      Call sess.SetEnvironmentVar("REQUIREMENT_STATUS", "")
      Execute {Use "YourLibraryName"}
      Call sess.SetEnvironmentVar("REQUIREMENT_STATUS", "PROCEED")
      Call sess.SetEnvironmentVar("REQUIREMENT_STATUS", "STOP")
      Exit Sub
End Sub

Again, I have not tested the ability of the LotusScript engine to trap this type of error.  If this works, you will have a function that tests whether a library can be loaded.

Author Comment

ID: 18851035
Fantastic thanks for you help, I went for the simplist solution in the end, which was just to check for the file, and if it doesn't exists give a suitable error message. When I have some more time I think I will also at the last solution as a possibillty which is certainly a nice way of doing this.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here:
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question