FlexPro
HistoryBase
Ingénierie
Formation
Téléchargements
Assistance FlexPro
Connaissance
Communauté
À propos de nous
Références
Emplois
Contact général
Liste des revendeurs
Assistance FlexPro
FR
DE
EN
Porte-plaquette
Produits et solutions
Support et téléchargements
Entreprise
Magazine
Contact
Langue
MyWeisang

Paramètres du compte.

Topic

Using multiple custom functions

Page d'accueil ' Communauté ' Automation et VBA ' Utilisation de multiples fonctions personnalisées

Voir les messages de 3 - 1 à 3 (sur un total de 3)
  • Auteur
    Messages
  • #35221
    Peter Seitz
    Participant

    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 = 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[/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 ?

    #35223
    Peter Seitz
    Participant

    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 = 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[/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 ?

    #35222
    Bernhard Kantz
    Participant

    If you remove the numbers after Calculate in the Implements directive and the function definition, your code should work.

    [code]
    Option Explicit

    Implements ICustomFPScriptFunctionCalculate

    Private Function ICustomFPScriptFunctionCalculate_Calculate(SafeArrayOfArguments() As Variant)

    ICustomFPScriptFunctionCalculate_Calculate = SafeArrayOfArguments()

    End Function
    [/code]

Voir les messages de 3 - 1 à 3 (sur un total de 3)
  • Vous devez être connecté pour répondre à ce sujet.