-
FlexPro
- At a Glance
- Features & Options
- Applications
- All Advantages
- What’s New in FlexPro 2021
- Try FlexPro For Free
- FlexPro View OEM Freeware
- Buying Guide
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
- Products
- News
- Support
- Company
- Contact
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
Using multiple custom functions
Home > Community > Automation and VBA > Using multiple custom functions
- This topic has 2 replies, 2 voices, and was last updated 8 years, 9 months ago by Peter Seitz.
-
AuthorPosts
-
February 4, 2016 at 8:18 am #12901Peter SeitzMember
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
' register the function With CustomFPScriptFunctions.Add("MyCustomFunction1") .Description = "Output Matrix" .Indeterministic = False With .Parameters.Add("Arg1") .Description = "First argument" .AllowedTypes = fpParameterTypeNumeric End With Set oMyFunction = New MyFunctionImplementationObject1 .Register oMyFunction End With ' register the function With CustomFPScriptFunctions.Add("MyCustomFunction2") .Description = "Output Matrix" .Indeterministic = False With .Parameters.Add("Arg1") .Description = "First argument" .AllowedTypes = fpParameterTypeNumeric End With Set oMyFunction = New MyFunctionImplementationObject2 .Register oMyFunction End With
And in my classmodule -> MyFunctionImplementationObject1
Option Explicit Implements ICustomFPScriptFunctionCalculate1 Private Function ICustomFPScriptFunctionCalculate_Calculate1(SafeArrayOfArguments() As Variant) ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments() End Function
And in my classmodule -> MyFunctionImplementationObject2
Option Explicit Implements ICustomFPScriptFunctionCalculate2 Private Function ICustomFPScriptFunctionCalculate_Calculate2(SafeArrayOfArguments() As Variant) ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments() End Function
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 ?
February 4, 2016 at 8:18 am #8561Peter SeitzMemberHello,
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
' register the function With CustomFPScriptFunctions.Add("MyCustomFunction1") .Description = "Output Matrix" .Indeterministic = False With .Parameters.Add("Arg1") .Description = "First argument" .AllowedTypes = fpParameterTypeNumeric End With Set oMyFunction = New MyFunctionImplementationObject1 .Register oMyFunction End With ' register the function With CustomFPScriptFunctions.Add("MyCustomFunction2") .Description = "Output Matrix" .Indeterministic = False With .Parameters.Add("Arg1") .Description = "First argument" .AllowedTypes = fpParameterTypeNumeric End With Set oMyFunction = New MyFunctionImplementationObject2 .Register oMyFunction End With
And in my classmodule -> MyFunctionImplementationObject1
Option Explicit Implements ICustomFPScriptFunctionCalculate1 Private Function ICustomFPScriptFunctionCalculate_Calculate1(SafeArrayOfArguments() As Variant) ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments() End Function
And in my classmodule -> MyFunctionImplementationObject2
Option Explicit Implements ICustomFPScriptFunctionCalculate2 Private Function ICustomFPScriptFunctionCalculate_Calculate2(SafeArrayOfArguments() As Variant) ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments() End Function
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 ?
February 5, 2016 at 9:38 am #9424Bernhard KantzParticipantIf you remove the numbers after Calculate in the Implements directive and the function definition, your code should work.
Option Explicit Implements ICustomFPScriptFunctionCalculate Private Function ICustomFPScriptFunctionCalculate_Calculate(SafeArrayOfArguments() As Variant) ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments() End Function
-
AuthorPosts
- You must be logged in to reply to this topic.