DODEFAULT( ) Function

Executes the parent class event or method of the same name from within a subclass.

For example, if you place DODEFAULT( ) in the Click event of a subclass, Visual FoxPro executes the Click event of the parent class. The scope resolution operator (::), unlike DODEFAULT( ), executes a parent class event or method of a different name.

Note   You can place DODEFAULT( ) only within an event or method.

DODEFAULT( [ eParameter1 [, eParameter2] ...] )

Parameters

  • eParameter1 [, eParameter2] ...
    Specifies parameters that are passed to the parent class event or method.

Return Values

Character, Numeric, Currency, Date, DateTime, Logical, or Memo

Remarks

The value that DODEFAULT( ) returns is determined by the return value of the event or method.

In versions prior to Visual FoxPro 8.0, you could not call DODEFAULT( ) in a method that did not exist in the parent class without Visual FoxPro generating an error, "Property name is not found (Error 1734)", returning True (.T.), and disregarding DODEFAULT( ) and any passed parameters. However, Visual FoxPro now disregards this and does not generate an error, but the following results still occur:

  • Visual FoxPro disregards any parameters that are passed because no code is executed.
  • Visual FoxPro always returns True (.T.), which is the default behavior for any procedure without an explicit RETURN statement.

This behavior affects the following scenarios:

  • Custom methods that are defined in a class. For example, the line, x.Test(), generated an error prior to Visual FoxPro 8.0 but no longer does:

    CLEAR
    x=CREATEOBJECT("s1")
    x.ReadMethod("Init")      
    x.Test()                  
    
    DEFINE CLASS s1 AS Session
       PROCEDURE Test
          DODEFAULT()
       ENDPROC
       PROCEDURE ReadMethod(cMethod)
          DODEFAULT(cMethod)
       ENDPROC
       PROCEDURE Error(nError, cMethod, nLine)
          ? "Error:", nError, cMethod, nLine
       ENDPROC
    ENDDEFINE
    
  • Native methods that are marked with the HIDDEN key word in the parent class. For example:

    CLEAR
    x=CREATEOBJECT("s2")
    x.Test()
    
    DEFINE CLASS s2 AS s1
       PROCEDURE Test
          THIS.ReadMethod("Init")
       ENDPROC
       PROCEDURE ReadMethod(cMethod)
          DODEFAULT(cMethod)
       ENDPROC
    ENDDEFINE
    
    DEFINE CLASS s1 AS Session
       HIDDEN PROCEDURE ReadMethod(cMethod)
          DODEFAULT(cMethod)
       ENDPROC
       PROCEDURE Error(nError, cMethod, nLine)
          ? "Error:", nError, cMethod, nLine
       ENDPROC
    ENDDEFINE
    

Starting in Visual FoxPro 7.0, calling a native method in a base class that contains DODEFAULT( ) does not cause an error. For example:

CLEAR
x=CREATEOBJECT("s1")
x.ReadMethod("Init")

DEFINE CLASS s1 AS Session
   PROCEDURE ReadMethod(cMethod)
      DODEFAULT(cMethod)
   ENDPROC
   PROCEDURE Error(nError, cMethod, nLine)
      ? "Error:", nError, cMethod, nLine
   ENDPROC
ENDDEFINE

See Also

:: Scope Resolution Operator | ParentClass Property