fbpx
Welcome, Guest
Username: Password: Remember me
Welcome to the XSharp forum!

Tell us and our members who you are, what you like and why you became a member of this site.
We welcome all new members and hope to see you around a lot!
  • Page:
  • 1

TOPIC:

2.6a vs 2.8 Method or procedure calls. Error or behavior change? 03 May 2021 20:55 #18281

  • jpmoschi's Avatar

  • jpmoschi

  • Topic Author


  • Posts: 28
  • I have declared a method in a class
    public method say(fila as usual, columna as usual, ptext as usual, ppicture as usual, flgbold as usual, flgunderline as usual, flgreverse as usual) as void
    
    in 2.6a i can call them with less parameters like this
    oFormTest:Say(0,0,"Start  the Dbase III Plus look Test inputting a quantity of iterations ")
    in 2.8 this line produce an error and the solution was to put all the declared arguments. Is it necesary? Is it an error?
    oFormTest:Say(0,0,"Start  the Dbase III Plus look Test inputting a quantity of iterations ",,,, )

    Please Log in or Create an account to join the conversation.

    2.6a vs 2.8 Method or procedure calls. Error or behavior change? 03 May 2021 22:49 #18286

  • robert's Avatar

  • robert


  • Posts: 2174
  • Juan Pablo,
    How did you declare oFormTest ? And did you change that ?

    I guess that before you did not declare it as a specific type and now you declared it with a type.

    The difference is that without a specific type this was compiled into a "Late Bound" method call. The compiler then generates a call to a function in the runtime (Send) and this Send() function at runtime uses reflection to figure out what the right number of parameters is that the Say() method wants to have and will add default values for the missing arguments.

    If you declare the local variable as your type (MyForm) then the compiler checks the # of parameters and the type of the parameters passed to the method and makes sure that you do not forget an argument.

    If you want to omit arguments and still declare oFormTest then you can add default values for the arguments that you allow to skip like this (assuming the first 3 are mandatory):

    public method say(fila as usual, columna as usual, ptext as usual, ppicture := NIL as usual, flgbold := NIL as usual, flgunderline := NIL as usual, flgreverse := NIL as usual) as void

    or better, if you know the types that you are expecting then use:

    public method say(fila as LONG, columna as LONG, ptext as STRING, ppicture := "" as STRING, flgbold := FALSE as LOGIC, flgunderline := FALSE AS LOGIC, flgreverse := FALSE as LOGIC) as void

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1