Topic
Using multiple custom functions
Startseite ' Community ' Automation and VBA ' Using multiple custom functions
- Dieses Thema hat 2 Antworten sowie 2 Teilnehmer und wurde zuletzt vor vor 9 Jahren, 3 Monaten von Peter Seitz aktualisiert.
-
AutorBeiträge
-
04.02.2016 um 08:18 Uhr #35221Peter SeitzTeilnehmer
Hello,
I’m using a custom function for an analysis like in your example “CustomFunction.FPD”.
Now I’d like to implement a second custom function, so I was going to expand my code like the following example:
In Module -> AutoFunctions
[code] ‘ register the function
With CustomFPScriptFunctions.Add(“MyCustomFunction1”)
.Description = “Output Matrix”
.Indeterministic = FalseWith .Parameters.Add(“Arg1”)
.Description = “First argument”
.AllowedTypes = fpParameterTypeNumeric
End WithSet oMyFunction = New MyFunctionImplementationObject1
.Register oMyFunction
End With‘ register the function
With CustomFPScriptFunctions.Add(“MyCustomFunction2”)
.Description = “Output Matrix”
.Indeterministic = FalseWith .Parameters.Add(“Arg1”)
.Description = “First argument”
.AllowedTypes = fpParameterTypeNumeric
End WithSet oMyFunction = New MyFunctionImplementationObject2
.Register oMyFunction
End With[/code]And in my classmodule -> MyFunctionImplementationObject1
[code]Option Explicit
Implements ICustomFPScriptFunctionCalculate1
Private Function ICustomFPScriptFunctionCalculate_Calculate1(SafeArrayOfArguments() As Variant)
ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments()
End Function[/code]
And in my classmodule -> MyFunctionImplementationObject2
[code]Option Explicit
Implements ICustomFPScriptFunctionCalculate2
Private Function ICustomFPScriptFunctionCalculate_Calculate2(SafeArrayOfArguments() As Variant)
ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments()
End Function
[/code]But as soon as I add another function in my AutoFunctions neither of the two added functions is working. I get the error message “The referred function does not exist”
Can you tell me what I’m doing wrong ?
04.02.2016 um 08:18 Uhr #35223Peter SeitzTeilnehmerHello,
I’m using a custom function for an analysis like in your example “CustomFunction.FPD”.
Now I’d like to implement a second custom function, so I was going to expand my code like the following example:
In Module -> AutoFunctions
[code] ‘ register the function
With CustomFPScriptFunctions.Add(“MyCustomFunction1”)
.Description = “Output Matrix”
.Indeterministic = FalseWith .Parameters.Add(“Arg1”)
.Description = “First argument”
.AllowedTypes = fpParameterTypeNumeric
End WithSet oMyFunction = New MyFunctionImplementationObject1
.Register oMyFunction
End With‘ register the function
With CustomFPScriptFunctions.Add(“MyCustomFunction2”)
.Description = “Output Matrix”
.Indeterministic = FalseWith .Parameters.Add(“Arg1”)
.Description = “First argument”
.AllowedTypes = fpParameterTypeNumeric
End WithSet oMyFunction = New MyFunctionImplementationObject2
.Register oMyFunction
End With[/code]And in my classmodule -> MyFunctionImplementationObject1
[code]Option Explicit
Implements ICustomFPScriptFunctionCalculate1
Private Function ICustomFPScriptFunctionCalculate_Calculate1(SafeArrayOfArguments() As Variant)
ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments()
End Function[/code]
And in my classmodule -> MyFunctionImplementationObject2
[code]Option Explicit
Implements ICustomFPScriptFunctionCalculate2
Private Function ICustomFPScriptFunctionCalculate_Calculate2(SafeArrayOfArguments() As Variant)
ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments()
End Function
[/code]But as soon as I add another function in my AutoFunctions neither of the two added functions is working. I get the error message “The referred function does not exist”
Can you tell me what I’m doing wrong ?
05.02.2016 um 09:38 Uhr #35222Bernhard KantzTeilnehmerIf you remove the numbers after Calculate in the Implements directive and the function definition, your code should work.
[code]
Option ExplicitImplements ICustomFPScriptFunctionCalculate
Private Function ICustomFPScriptFunctionCalculate_Calculate(SafeArrayOfArguments() As Variant)
ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments()
End Function
[/code] -
AutorBeiträge
- Du musst angemeldet sein, um auf dieses Thema antworten zu können.