PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
New WINDEV, WEBDEV, WINDEV Mobile 25 feature!
  • Overview
  • Creating a custom property
  • How to proceed?
  • Example
  • Tip
  • Access rights to a custom property
  • Passing custom properties as a parameter to a WLanguage function or procedure
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
A custom property is a code element with two events:
  • an event for retrieving the value,
  • an event for assigning the value.
A custom property can be used like a variable or a member (direct value retrieval, assignment with the '=' symbol, etc.). At runtime:
  • Any operation that requires reading the property runs the event for retrieving the value. This event must return a value.
  • Any operation that requires writing the property runs the event for assigning the value. This event must process a parameter.
You can create custom properties on the following elements:
  • control templates.
  • window templates.
  • windows.
  • internal windows.
  • pages.
  • internal pages.
  • page templates.
Creating a custom property

How to proceed?

To create a custom property:
  1. Open the "Project explorer" pane, if necessary (on the "Home" pane, in the "Environment" group, expand "Panes" and select "Project explorer").
  2. In the "Project Explorer" pane, display the element on which you want to add a custom property.
  3. Select the desired element. Open the popup menu of the element and select "New property".
  4. In the window that appears, enter the name of the property and validate.
  5. The code editor shows the events related to the property :
    • Event "Retrieving the property". This event must contain the "RESULT" keyword (or "RETURN =") to allow returning the value of the property.
    • Event "Assigning the property". This event is used to give a value to the property. This value is passed as parameter. This event must not return a result.
  6. Enter the code of your property.
  7. Enter the code to call the custom property in the desired element.

Example

  1. Creating a custom property for a control template that returns the duration:
    PROCEDURE PUBLIC Duration()
    RESULT DateDifference(EDT_Start_date, EDT_End_date)
  2. This property of the template will be called in the code of the window:
    Info("The number of days selected is: " + CTPL_Duration..Duration)

Tip

You can override an existing WLanguage property. In this case, the code of the custom property will be run .
You can still access the original property in the code of the custom property, using the following syntax:
MySefl..<Original property>
Example: Assigning the ToolTip property:
PROCEDURE ToolTip(Value)
 
MySelf..ToolTip = "Number of days: " + Value
Access rights to a custom property
Caution: The custom property is read and/or write accessible depending on the associated events that have been defined:
  • If the event "Retrieving the property" is empty, the property cannot be read. If a read operation is performed, a compilation error is displayed in the code editor. An error will occur at runtime as well.
  • If the event "Assigning the property" is empty, it will not be possible to write on the property. If a write operation is performed, a compilation error is displayed in the code editor. An error will occur at runtime as well.
Passing custom properties as a parameter to a WLanguage function or procedure
These are the different cases.
If the parameter is passed by reference (default case) and untyped :
  • the custom property is passed as a parameter.
  • no events associated with the custom property are run during the call.
  • reading the formal parameter triggers the event "Retrieving the property".
  • writing the formal parameter triggers the event "Assigning the property".
If the parameter is by passed value (LOCAL) and untyped :
  • the value of the custom property is passed as a parameter.
  • the code for retrieving the value is run during the call.
  • the reading of the formal parameter accesses the value passed during the call and does not run the event "Retrieving the property".
  • the writing of the formal parameter modifies the value passed during the call and does not run the event "Assigning the property".
If the parameter is passed by reference (default case) and typed :
  • the custom property is passed as a parameter.
  • the type of the property must be correct. Otherwise, a WLanguage error occurs.
  • no events associated with the property are run during the call.
  • reading the formal parameter triggers the event "Retrieving the property".
  • writing the formal parameter triggers the event "Assigning the property".
If the parameter is by passed value (LOCAL) and with specific type :
  • the value of the custom property is passed as a parameter.
  • the event "Retrieving the property" is run during the call.
  • if necessary, the value of the property is converted into the type of the parameter.
  • the reading of the formal parameter accesses the value passed during the call and does not run the event "Retrieving the property".
  • the writing of the formal parameter modifies the value passed during the call and does not run the event "Assigning the property".
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment