Condividi tramite


WITH ... ENDWITH Command

Specifies multiple properties for an object.

WITH ObjectName
   [.cStatements]
ENDWITH

Parameters

  • ObjectName
    Specifies the name of the object. ObjectName can be the name of the object or a reference to the object.
  • .cStatements
    cStatements can consist of any number of Microsoft Visual FoxPro commands used to specify properties for ObjectName. Place a period before cStatement to denote that it is a property of ObjectName.

Remarks

WITH ... ENDWITH provides a convenient way to specify a number of properties for a single object. Note that you can also execute methods from within a WITH ... ENDWITH structure.

Example

The following example creates a custom class name Employee. After the Employee class has been created with CREATEOBJECT( ), WITH ... ENDWITH is used to set multiple properties for the class. The properties values are then displayed.

moemployee = CREATEOBJECT('employee')

WITH moemployee
   .First_Name = 'John'
   .Last_Name = 'Smith'
   .Address = '16 Maple Lane'
   .HireDate = {^1998-02-16}
ENDWITH

CLEAR
? moemployee.First_Name + ' '
?? moemployee.Last_Name
? moemployee.Address
? moemployee.HireDate

DEFINE CLASS employee AS CUSTOM
      First_Name = SPACE(20)
      Last_Name = SPACE(20)
      Address = SPACE(30)
      HireDate = {  -  -  }
ENDDEFINE

See Also

:: Scope Resolution Operator | ADD CLASS | CREATE CLASS | CREATE CLASSLIB | CREATEOBJECT( ) | GETOBJECT( ) | MODIFY CLASS | RELEASE CLASSLIB | SET CLASSLIB