Results 1 to 10 of 18

Thread: 2 functions, same name, different parameters - what goes wrong here?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Rotterdam, Holland
    Posts
    1,953

    Default 2 functions, same name, different parameters - what goes wrong here?

    What are we doing wrong here?
    We noticed that DF has issues when 2 functions are defined with the same name, but with different parameters.
    I tested this in 18.1, 19.0 and 19.1: it all goes wrong.

    It's best explained by giving you a reproducable example in the Order Entry workspace.

    Add this to Vendor.DD:

    Code:
        
    // Parameter 1: integer, parameter 2: string
    Function GetTestParameters  Integer iParameterInteger String sParameterString Returns Integer
       Showln iParameterInteger " " sParameterString
            
       Function_Return 1
    End_Function
    
    This method has 2 parameters: an integer and a string.

    Then add this to the OrderHea.DD:

    Code:
       
    
    // Parameter 1: string, parameter 2: integer
    Function GetTestParameters String sParameterString Integer iParameterInteger Returns Integer Showln iParameterInteger " " sParameterString // Set Breakpoint here. Function_Return 1 End_Function Procedure DoTest String sDummy Move (GetTestParameters(Self, "TEST", 123)) to sDummy // This one goes wrong Get GetTestParameters "TEST" 123 to sDummy // This one works End_Procedure
    This will add a function with the same name, but with the parameters the other way round: First a string, then an integer.

    Next add a button to Order.vw:

    Code:
       Object oTestBtn is a Button
          Set Label to "Test"
          Set Location to 156 81
          Set peAnchors to anBottomLeft
          Set psToolTip to "Send test to DDO"
     
          Procedure OnClick
             Send DoTest of OrderHea_DD 
          End_Procedure  // OnClick
            
       End_Object    // oPrintBtn
    
    Set a breakpoint at the showln in GetTestParameters in OrderHea.dd.
    Then compile and run.
    Click the button.

    It first starts:
    Code:
    Move (GetTestParameters(Self, "TEST", 123)) to sDummy
    It stops at the breakpoint. Now look at the local variables:

    Click image for larger version. 

Name:	variables.png 
Views:	16 
Size:	2.7 KB 
ID:	13011

    Eventhough the first paramater is a string test, the variable
    sParameterString is 0.
    And the variable iParameterInteger contains a string "123".

    What happens here is that the method uses the parameters of the function that is defined in Vendor.DD instead of the one in OrderHea.DD, even though everything takes place in the OrderHea class.

    The next line
    Code:
    Get  GetTestParameters "TEST" 123 to sDummy
    goes well though.

    What are we doing wrong here?
    We should be able to use methods with the same name but different parameters imho.
    But somehow this goes wrong?


    Last edited by Pieter van Dieren; 14-Aug-2019 at 03:45 AM.
    Regards,

    Pieter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •