Illegal Parentheized reference? Functions

I have written this function:

Function getRegionDocumentID(rname As String)As String

Dim s As New NotesSession

Dim thisdb As NotesDatabase

Dim Internaldb As NotesDatabase

Dim ndc As NotesDocumentCollection

Set thisdb = s.CurrentDatabase

Set Internaldb = s.GetDatabase(thisdb.Server, "Internal.nsf", False)

searchformula$ = {RegionName="}+country+{"}

Set ndc = internaldb.Search(searchformula$, Nothing, 0)

If ndc.Count<>1 Then

	Messagebox ( "An Error has occurred" )

	Goto jump

End If

getRegionDocumentID=ndc.GetFirstDocument.UNID

jump:

End Function

Now, as I understand it, this means that I should now be able to call this method with a simple String = getRegionDocumentID(String) and retrieve the value of the function. Hence this button:

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim regiondocid As String

Set uidoc = ws.CurrentDocument

Forall x In uidoc.Document.Regions

	regiondocid = getRegionDocumentID(x)

	Call uidoc.FieldAppendText("RegionUNIDs", regiondocid + "; ")

End Forall

End Sub

But it won’t compile, it tells me that there’s an illegal parenthesized reference, and points t the line with my function call on it! Any help appreciated!

Chris

Subject: Illegal Parentheized reference? Functions…

I think your function is out of scope. If you created your function in a script library then remeber to USE the script library.

Your code is compiling fine in my client but if I remove the function from my button then I get the same error as you do.

Regards Klaus Terman

Subject: RE: Illegal Parentheized reference? Functions…

The function is in the form, not a script library. Do I still need some sort of USE statement?

EDIT : I placed the function in a script library, called lib1, and the put this line in the (Options) section of the form:

USE “lib1”

Is this corect? Beause it results in exactly the same problem…

ANOTHER EDIT : Forget it, I just put the code in the button. I don’t have time for this! It works now, thanks for your help!

Subject: RE: Illegal Parentheized reference? Functions…

It is a matter of scope. The problem is that you defined your routine in the Form script of the form. You need to move it to the Globals script of the form, or else define it within the object that the “click” script is associated with.