Solved

Lotus Script Libraries error messages

Posted on 2007-04-04
5
1,124 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now