Same Name problem

Hi

I'm developing a component derived from TDateTimePicker, where is a Date property, but I'd like to assing the current Date, but the funcion name (date) matches the property name (date) and I cannot assign the current date. The same name problem also occured in a Grid Draw event, where a TREct passed as trect variable, and I wanted to use the TREct function. I coul'd not. So my question is, how can I invoke a procedure wich has the same name, as a property.

Thanks
SoftMan

Comments

  • : Hi
    :
    : I'm developing a component derived from TDateTimePicker, where is a Date property, but I'd like to assing the current Date, but the funcion name (date) matches the property name (date) and I cannot assign the current date. The same name problem also occured in a Grid Draw event, where a TREct passed as trect variable, and I wanted to use the TREct function. I coul'd not. So my question is, how can I invoke a procedure wich has the same name, as a property.
    :
    : Thanks
    : SoftMan
    :
    You cannot. Names of properties and methods must be different within the same object. Remember also that methods usually have a verb in them, so a function which returns the current date should be named: GetCurrentDate or GetSelectedDate. The property which holds the current date should simply be called: CurrentDate.
  • Hi. With the TRect function, you can use Windows.TRect() to identify the correct function you want to call. I don't know if your Date function can use the same solution. If it is defined in the same object, then it is not possible (as zibadian already said).

    hth, pritaeas

    : : I'm developing a component derived from TDateTimePicker, where is a
    : : Date property, but I'd like to assing the current Date, but the
    : : funcion name (date) matches the property name (date) and I cannot
    : : assign the current date. The same name problem also occured in a
    : : Grid Draw event, where a TREct passed as trect variable, and I
    : : wanted to use the TREct function. I coul'd not. So my question is,
    : : how can I invoke a procedure wich has the same name, as a property.

    : You cannot. Names of properties and methods must be different within
    : the same object. Remember also that methods usually have a verb in
    : them, so a function which returns the current date should be named:
    : GetCurrentDate or GetSelectedDate. The property which holds the
    : current date should simply be called: CurrentDate.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories