As explained in the discussion of OOP, objects such as buttons, windows, scrollbars, etc. each have properties that can be set in the Properties window. However, sometimes you will want to change an object’s properties while the program is running. In this case you can get and set properties using dot notation.

For example, suppose you want to put some text into an Editfield to give feedback to some action that the user has performed. Perhaps, in a quiz program, a user has chosen a correct answer to a quiz question.


Dot Notation and Properties

One way to do this would be to put the feedback text into the Editfield whenever the user clicks on one of the RadioButtons. In the incorrect RadioButton’s Action event you could put:

if me.value = true then
     Editfield1.text = “Sorry”
end if

Here the RadioButton’s “value” property is checked and if it is true (the button has been selected). If it is true then the Editfield’s text property is set to “Sorry”.

In the correct RadioButton’s Action event you would put:

if me.value = true then
     Editfield1.text = “Correct”
end if

Notice that in the first line of these blocks of code (“if me.value = true then”) we are getting the “value” property of the RadioButton while in the middle line (“Editfield!.text = “Correct”) we aresetting the “text” property of the EditField.

In these examples dot notation is used to refer to properties that belong to objects. It is important to remember that objects’ properties are of particular data types depending on the property. For example, a RadioButton’s width (RadioButton1.width) must be an integer while a RadioButton’s caption (RadioButton1.caption) must be a string (a group of characters).

RadioButton1.caption = “1812” is correct code. The quotes indicate that we are using 1812 as a string.
RadioButton1.caption = 
1812 is incorrect code. Without the quotes 1812 is an integer. If you tried to run a program with this code in it you would get an error message telling you that there is a “type mismatch”.

Dot Notation and Methods

Dot notation is also used to refer to an object’s methods. An object method performs an action when it is “called”. You call an object method using dot notation.
     EXAMPLE: Editfield1.setFocus
Calling the “setFocus” method of an EditField makes that EditField become the object with focus. In this case the fact that the EditField has focus would be indicated by a blue selection ring around EditField1.



Think “OF”
It may help in understanding dot notation to use the word “of“. For example Editfield1.text means “the text property of Editfield1″ and Editfield1.setFocus means “the setFocus method of Editfield1″.