Property Declaration

Action

Within a window or window class declaration, declare a property.

Syntax

[gui-specifier] property property-id
  data-type Get ( ) 
    code-for-Get-routine
  void Set (data-type value) 
    code-for-Set-routine
Variable Description
gui-specifier Optional: Specifies the GUIs that the property applies to. See window declaration. If omitted, the property applies to all GUIs.
property-id An identifier that specifies the name of the property. Properties are in scope for the window class declaration only; this means that different classes can have properties with the same names.

Notes

See the winclass declaration for examples of declaring properties.

When you declare a property within a window class declaration, the property is available for use in all windows of that class.

When you declare a property within a window declaration, the property is available for use only by that window. The property declaration within a window overrides any property of the same name in the window’s class

Properties allow information associated with a window to be accessed as if it were stored in a variable.

  • When a property name appears to the right of an assignment (=) operator, Silk Test Classic calls the Get function for the property to get the information.
  • When a property name appears on the left side of the assignment operator, Silk Test Classic calls the property's Set function to change the information.

A Get function must take no arguments and must return a value whose type is not void.

A Set function must take one and only one argument and must be declared void.

A property need not have both a Get and a Set function. For example, a Caption property to access a window's caption would only have a Get function.

Referring to a Window with the Keyword "this"

When defining properties within a window class declaration, you use the keyword this to refer to the window that the method or property will refer to at runtime.