Solved

Illegal reference to function in Lotus Script

Posted on 2007-11-16
4
1,603 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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