?
Solved

Illegal reference to function in Lotus Script

Posted on 2007-11-16
4
Medium Priority
?
1,680 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 750 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

830 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