Call script from custom class - v8.0.1

Hello Experts

I have a custom class, and in the new operator I am calling an existing script to do some calculations. However, when I compile I get the following error:

Reference to a non-shared member requires an object reference

I guess this make sense since all the customer scripts reside in a separate class.

Question is: How can I access the functions (i.e. scripts) from within my custom class?

Thanks

Kin

Parents Reply
  • Got it, pasting the source code here - the key is to have a session member variable

    Class Test
    
    	Public _s As VI.DB.Entities.ISession
    	Dim _prop As String
    	
    	Public Property Prop() As String
    		Get
    			Return Me._prop
    		
    		End Get
    		
    		Set(ByVal t As String)
    			Dim runner = New VI.DB.Scripting.ScriptRunner(Me._s.Scripts()(VI.DB.Scripting.ScriptContext.Scripts), Me._s)
    			Dim result = runner.Eval("CCC_MyScript", {"John", "@company.com"})
    			Me._prop = CStr(result)
    		End Set
    		
    	End Property
    	
    End Class
    
    Public Function  CCC_Myfunc() As String
    
    		Dim p As New Test With {._s = Session, .Prop = "ha"}
    		Return p.Prop
    	
    End Function

Children
No Data