Welcome! Log In Create A New Profile

Advanced

Class properties

Posted by John Marrone 
John Marrone
Class properties
April 11, 2009 01:59PM
Hi All
In a WD class you create a property. Does WD have set and gets internal methods. In VB or C# you create a property and you will also be able to declare a set and a get for the property. And when assign a value to the property the set would run automatically. So in the set method I could write code to change the value of what was assign to the variable. I didn't have to call the set method of the property. Anytime a new value was assigned to the property it would run. Anytime anything would read the value from the property the get method would run automatically. They are called the get and set of the property. WD has a Writes and Reads method you can create for the property but they do not run automatically when a value is read from or assign to the property. You can call these Writes and Reads manually. How do you get the Writes and Reads methods of the property to execute automatically. If this can not be done then these Writes and Reads are no more useful than just writing my own methods. Or am I not doing something right. Here is my code :

Entrie is class
myValis string
End

PROCEDURE Reads_myVal() <-- generated by WD I put the Upper function call in
RESULT Upper(:myVal)

PROCEDURE Writes_myVal(NewValue) <-- generated by WD I put the Upper function call in
:myVal=Upper(NewValue)

WD generated these 2 methods as access methods. And I just changed them to make the property upper case. So when I go:

var1 is object dynamic = new Entrie
var1:myVal = "john marrone"

and when I do => info(var1:myVal) I should get an info message box with the string "JOHN MARRONE".

Can WD do this like other programming languages do. Or is WD just writing template code to save us some effort. In WD when you right click on a property in the class panel in the code panel WD gives you a popup menu option to generate the access methods for the property. And when you select it WD generates the Writes and Reads methods like the code above.

I hope someone understands what I am saying here. Could someone let me know one way or the other. And if WD does have this feature what I am doing wrong. This is very important to me so if someone could, please help

DerekT
Re: Class properties
April 11, 2009 05:04PM
John

In the Couglof (Pane at the bottom) select Classes from the list in the Code view.

Highlight a member, right click and select 'Generate the access methods'.

As with all things, easy once you know were to look.

Regards

DerekT
John Marrone
Re: Class properties
April 11, 2009 05:19PM
DerekT
Hi derekT, Thats how I do it know. WD Inserts the Reads and Writes methods in my class code file. But when I use the property in my code these access methods are not being called. I can call them ie: myClass:Reads_myVar = "xxxx" and the code will execute but it should execute when I do ie: myClass:myVar = "xxx'. The reads_myVar method should fire transparently. But it doesn't. This is how it works in .net, delphi and all other languages. Or is it in WD you call these methods manually and WD is just inserting this code as a convinence?
Ruben Sanchez Peña
Re: Class properties
April 12, 2009 01:49AM

Hi John, until i know the "Setter and Getter methods" are a .NET invention. Java for example use getter and setter to assign values to member classes (Eclipse or Netbeans IDEs generate this methods for you), but isn't automatic invocation of the methods. It's like Windev approach. It's only a method to access to private members and check the value before assign the value to variable.

If you want simulate this behaviour you only must use the Readers and Writers methods to manipulate the member and put your code in these methods.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: