STATICS

STATICS

Syntax

STATICS stat [options].

Effect

Declaration of static variables stat. The statementSTATICS for declaring static variables can only be used insubroutines, function modules, and static methods.

The naming conventions apply to the stat name. The syntax for the additionsoptions is used for declaring normal variables as with the statementDATA. Only the additionREAD-ONLY is not possible.

As with normal local variables, one with STATICS declared variables can only be viewed in itsprocedure. The life of a variable with STATICS declared variables corresponds to the same one of a global data object. The variable is generated once when loading theframework program in the internal mode, and the contents set to thestart value of the VALUE addition. Calling and ending the procedure have no effect on the life and content.

Note

In instance methods, the statement STATICS is not allowed. Instead, you can usestatic attributes of the class, declared withCLASS-DATA.

Example

The subroutine add_1 gets the same result for the variablelocal for each call as this is instanced again each time. The static variablestatic is already available and its value increased by 1 during each call.

DO 10 TIMES.
  PERFORM add_one.
ENDDO.

FORM add_one.
  DATA    local  TYPE i VALUE 10.
  STATICS static TYPE i VALUE 10.
  local  = local  + 1.
  static = static + 1.
  WRITE: / local, static.
ENDFORM.


Test

        11          11
        11          12
        11          13
        11          14
        11          15
        11          16
        11          17
        11          18
        11          19
        11          20

效果
统计静态变量声明。声明静态变量的声明静力学只能用于子程序,功能模块和静态方法。

命名约定适用于的STAT名称。为增加选项的语法是用于报表数据的正常变量声明。只有另外只读是不可能的。

与正常的本地变量,一个与静力学声明的变量只能在其程序中查看。生活的一个静态的变量声明变量对应一个全局数据对象的同一个。变量生成一次装载在内部模式的框架方案时,内容设置起始值附加值。调用和结束程序的生命和内容没有影响。



注意
在实例方法中,声明静力学是不允许的。相反,你可以使用类的静态属性,声明类数据。



例子
子程序add_1得到相同的结果,因为这是每次实例再次为每个调用的局部变量。静态静态变量是已经提供,并在每次调用它的值增加1。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值