Aracılığıyla paylaş


WITH ... ENDWITH Command

Specifies multiple properties for an object.

WITH ObjectName [AS <Type> [OF <Class Library>]]
   [.cStatements]
ENDWITH

Parameters

  • ObjectName
    Specifies the name of the object. ObjectName can be the name of the object or a reference to the object.

  • Type
    A base class, class name, or type library. (For Intellisense only)

  • Class Library
    Class library containing the base class, class name, or type library specified with Type. (For Intellisense only.)

  • .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

Reference

:: Scope Resolution Operator

ADD CLASS Command

CREATE CLASS Command

CREATE CLASSLIB Command

CREATEOBJECT( ) Function

GETOBJECT( ) Function

MODIFY CLASS Command

RELEASE CLASSLIB Command

SET CLASSLIB Command

Other Resources

Commands (Visual FoxPro)

Language Reference (Visual FoxPro)