Read-Only and Write-Only

sterlingy

Active Member
Licensed User
Longtime User
I noticed that some classes have properties that are read-only or write only, such as panel.Color is write only and panel.height is read-only.

How is this defined when coding the variables or methods within the class?

Cheers,

Sterling
 

tonyp

Member
Licensed User
Longtime User
Getting the around ReadOnly WriteOnly "problem"

I recently had the same problem. I wanted a ReadOnly attribute.

Until language support is added, a simple solution is to use public routines that access a private variable. For example,

B4X:
private _error_ as string
...
public sub Error as string
  return _error_
end sub
 
Upvote 0

tonyp

Member
Licensed User
Longtime User
OK, thanks. (Your previous message of 15/4/2013 said there wasn't support for properties, yet!)

I tried it, but it took me while to figure out that you can't use an existing private variable Name as the getName. There were no errors but the property simply didn't appear. It seems you must use a different name, a bit strange...

But, anyway, it works as long as the property name (after the get/set) doesn't collide with a class variable name!!!
 
Upvote 0
Top