Solved

Illegal reference to function in Lotus Script

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

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…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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