Solved

Illegal reference to function in Lotus Script

Posted on 2007-11-16
4
1,613 Views
Last Modified: 2013-12-18
I am writing a Lotus Notes agent in Lotus Script and trying to call a function from a script library.

The library name is Trans4mRoutines.  The library saves with no errors.
Library Function
*****************************************************************
Function OpenT4m()
      Dim msgstr As String
      
      On Error Goto OpenT4mErr
      
      Set UDSession = CreateObject("Uniobjects.Session.1")
      UDSession.HostName = "Trans4m"
      UDSession.AccountPath = "/NTN/DATA/PRODUCTION"
      UDSession.UserName = "Micro"
      UDSession.Password = "Micro"
      
      Print "Connecting to Unidata.  Please wait."
      UDSession.Connect
      
      ' Make sure we have a connection
      If UDSession.IsActive Then
            OpenT4m = 0
      Else
            msgstr = "TRANS4M Connection Failed"
            Messagebox msgstr, MB_OK
            OpenT4m = -1
      End If
      On Error Goto 0
      Exit Function
      
OpenT4mErr:
      msgstr = "Error opening TRANS4M Connection at line # " +  Cstr(Erl) + Chr$(10) + Chr$(13)
      msgstr = msgstr + "Error Number " + Cstr(Err) + Chr$(10) + Chr$(13)
      msgstr = msgstr + Error + Chr$(10) + Chr$(13)
      Messagebox msgstr, MB_OK
      OpenT4m = -1
      On Error Goto 0
End Function

*************************************************************
Here is the use statement in the agent
*************************************************************
Option Public
Use "Trans4mRoutines"

**************************************************************
Here is the agent code that throws the error.
***************************************************************
Sub ExamineDocs()
      Set sNotes = New NotesSession
      Set dbNotes = s.CurrentDatabase
      Set vwNotes = dbNotes.GetView("($All)")
      Set docNotes = vwNotes.GetFirstDocument
      Dim Result As Integer
      
      ' Open TRANS4M Session      
      Result = OpenT4m()   **** This line throws the error ****
      If (Result = 0) Then
            If (OpenT4mFile("A_P-PAYMENT-HIST_MA")  = "") Then  *** No erroron this Function call ***
                  Call CloseT4m()   *** No error on this subroutine call ***
                  Goto EndProgram
            End If
      Else
            Goto EndProgram
      End If
.
.
.
.
End Sub

Can anyone tell me why the Call to OpenTrans4m throws an error?
0
Comment
Question by:NTNBower
  • 2
4 Comments
 
LVL 8

Expert Comment

by:behenderson
ID: 20302682
Function OpenT4m() as Integer
0
 
LVL 8

Accepted Solution

by:
behenderson earned 250 total points
ID: 20302727
Function OpenT4m() as Integer

The reason that the bad function declaration worked on the other statements is that you explicitly declared Result As Integer.  When no return type is specified (which is really not very good style) the default return type of variant is used.  When you do not declare variables they are also variants.  Good coding style would be to declare everything, other languages that you may use in the future will not be so flexible in allowing you to declare types when you like and not when you don't.  The consultant firm I worked for was real real rigid about declaring everything and capitalizing everything the same way.  This turned out to be helpful later.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 20306930
Just a suggestion: in the Designer, activate the option to always include an Option Declare in your code automatically.
0
 

Author Closing Comment

by:NTNBower
ID: 31409668
Thanks.  I knew better, but was in a hurry and missed it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

24 Experts available now in Live!

Get 1:1 Help Now