Solved

Lotus Script Libraries error messages

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

  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…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.

822 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