Solved

Lotus Script Libraries error messages

Posted on 2007-04-04
5
1,142 Views
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.
0
Comment
Question by:PETAdmin
[X]
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
5 Comments
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 125 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
      
NO_FILE:
      
      FileExists = False
      Exit Function
      
End Function
0
 

Author Comment

by:PETAdmin
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?
0
 
LVL 22

Expert Comment

by:Bill-Hanson
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");
0
 
LVL 22

Expert Comment

by:Bill-Hanson
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")
      
      
CATCH:
      
      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.
0
 

Author Comment

by:PETAdmin
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating a bat file fo Note.ini 4 234
Peculiar IBM Lotus Notes / Cisco VPN Issue 21 938
Inconsistent date field in Lotus Notes 6 101
Domino Website - Redirection 12 98
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

756 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