Solved - Trouble with "include" function - probably a simple error but I can't see it

I’m using multiple .rvb script files and trying to ensure that my script for common functions and subs is loaded when starting other scripts.

Since there is no “include” function in Rhinoscript I’m trying to use Dale’s example from here

' ---------------------------------------------------------------------------
' Subroutine:  Include
' Purpose:     Includes, or loads, other RhinoScript files
' Argument:    A script file name to include
' Example:     Call Include("C:\Scripts\MyScriptFile.rvb")
' ---------------------------------------------------------------------------
Sub Include(strScriptName)
  Dim objFSO, objFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(strScriptName)
  ExecuteGlobal objFile.ReadAll()
  objFile.Close
End Sub

My include script is as follows but it generates a “Cannot use parentheses when calling a Sub” error at the beginning of the “ExecuteGlobal” code line:

Function IncludeAtaraxiaScripts()
   'Test Ataraxia Scripts Loaded
	If Not Rhino.IsCommand("AtaraxiaScriptsLoaded") Then
		Rhino.Print "BodyCuts:IncludeAtaraxiaScripts"
		
		'Load Ataraxia Scripts
		Dim strFilePath
		strFilePath = Rhino.FindFile(sstrAtaraxiaScripts)
		Dim objFileSystemObject
		Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
		Dim objScriptFile
		Set objScriptFile = objFileSystemObject.OpenTextFile(strFilePath)
		ExecuteGlobal objScriptFile.ReadAll()
		objScriptFile.Close
		
		If Not AtaraxiaScriptsLoaded Then 
			'Return Error
			Rhino.Print sstrAtaraxiaScripts & " failed to load."
			IncludeAtaraxiaScripts = False
			Exit Function
		End If
		
		Rhino.Print "IncludeAtaraxiaScripts Done." : Rhino.Print

	End If
	'Return Success
		IncludeAtaraxiaScripts = True
End Function

I’m hoping someone might be able to point me in the right direction :slight_smile:

Whoops!
I found the problem. The error message was referring to an incorrect parentheses in the file being included, not the include code itself.

Fixed.