propertyget语句
在
class块中,声明构成用来取得(返回)的值的属*过程的主体的名称、参数和代码。
[
public[
default]|
private]
propertygetname
[(arglist
)]
[statements]
[[
set]name=expression]
[
exitproperty]
[statements]
[[
set]name=expression]
endproperty
参数
public
表明
propertyget过程可以被所有脚本中的其他过程访问。
default
只与
public关键字一起使用,表明
propertyget过程中定义的属*为类的缺省属*。
private
表明
propertyget过程只对定义它的
class块中的其他过程是可以访问的。
name
propertyget过程的名称;遵守标准的变量命名规则,区别仅仅在于它可以与同一
class块中的
propertylet或
propertyset过程。
arglist
该变量列表代表了
propertyget过程被调用时传递给它的参数。多个参数之间用逗号分隔开。
propertyget过程中的每个参数的名称必须与
propertylet过程中的相应参数相同(如果有的话)。
statements
任意的一组语句,将在
propertyget过程的主体中执行。
set
在将对象作为
propertyget过程的返回值时使用的关键字。
expression
propertyget过程的返回值。
说明
如果未使用public或private明确声明,则
propertyget过程被缺省为公有的,即它们对于脚本中的其他所有过程都是可见的。
propertyget过程中的局部变量的值在不同的过程调用之间是不保存的。
在其他任何过程(例如function或propertylet)内部都不能定义propertyget过程。
exitproperty语句将导致立即从propertyget过程中退出。程序将继续执行调用propertyget过程的语句之后的程序。exitproperty语句可以出现在propertyget过程中的任何位置,次数不限。
与
sub和
propertylet过程类似,
propertyget过程是能够接受参数的过程,可以执行一系列的语句,以及改变参数的值。然而,与
sub和
propertylet不同的是,
propertyget过程可以被用于表达式的右侧,用与使用
function或属*名称相同的方式来返回属*的值。