Dot Notation | ||
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 each incorrect RadioButton's Action event you could put: if me.value = true then Here the RadioButton's "value" property is checked to see 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 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 are setting 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. 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. | ||
![]() | ||
Think "OF" | ||