Using the ..Note Property

I was going through some of the WD unit examples this morning looking for inspiration. I really suggest you do this from time to time, there are lots of great examples there, and as you knowledge of WinDev grows, more and more of the examples will apply to you.

Here’s a cool tip I found looking at the Handling the Indirections example.

Use the ..Note property to store the original content of a control.

No need to create extra variables. Traditionally anytime I need the original value of a control, I would create a local procedure variable and during the initialization of the window I would do something like:

HoldQuantity = EDT_Quantity

But with WinDev we have a ..Note property on the controls and we can just use that and not create any additional variables. We can even make our code generic by placing it In the Initialization event of the control

Myself..Note = Myself

Since that code is 100% generic, it is a prime canidate for a Code Brick! Now we have some code to return it to the original value if it fails validation. We could put something like this in Exit event for the control.

IF QuanityCheck(Myself) THEN
   Myself  = Myself..Note

Or, if we have some special code we need to fire whenever the record is Saved and the value has changed.  Some code similar to this as part of the save button will do the trick.

 IF EDT_Quantity..Note <> EDT_Quantity THEN

Side Note: Another way I accomplish this without creating extra variables is by taking advantage of WinDev’s loosely bound control. As long as the record buffer isn’t getting changed anywhere else, then the original value is in in File.Variable and that can be compared to the control. But if there is any code that could change the contents of the record buffer that would cause problems. The above method ties both sides of the logic to the control.

Now, back to your regular schedule program….

One thought on “Using the ..Note Property

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s