我们有一个COBOL程序,我们在其中将值填充到COBOL内部表中,然后搜索此表以找出某个值。在此搜索之前,我们初始化表索引变量。
SET PAF-IDX TO 1.
任何人都可以澄清一下,如果在COBOL中允许初始化索引变量,则可以这样做。
INITIALIZE PAF-IDX.
答案 0 :(得分:3)
没有。你为什么要“初始化”呢?
这来自IBM Enterprise Cobol手册:
identifier-1
Receiving areas.
identifier-1 must reference one of the following:
v An alphanumeric group item
v A national group item
v An elementary data item of one of the following categories:
Alphabetic
Alphanumeric
Alphanumeric-edited
DBCS
External floating-point
Internal floating-point
National
National-edited
Numeric
Numeric-edited
v A special register that is valid as a receiving operand in a MOVE
statement with identifer-2 or literal-1 as the sending operand.
When identifier-1 re
编辑:
OpenCobol程序员指南专门记录了它:
The list of data items eligible to be set to new values by this statement is:
Every elementary item specified as identifier-1 ..., PLUS...
Every elementary item defined subordinate to every group item specified as dentifier-1
..., with the following exceptions:
USAGE INDEX items are excluded.
Items with a REDEFINES as part of their definition are excluded; this means that
tems subordinate to them are excluded as well.
Cobol标准草案不太明确,但在INITIALIZE中使用时这些项目是通过生成SET而不是MOVE来处理的:DATA-POINTER,FUNCTION-POINTER,OBJECT-REFERENCE或PROGRAM-POINTER。
编辑:
看到OpenCobol引用并不像我想象的那样“具体”:在IBM Cobol中,目前,作为MOVE目标无法操纵的任何东西都可以是INITIALIZEd。对于当前的OpenCobol,这是相同的。 Cobol草案列出了一些例外,但既不包括INDEXED BY(它们不是表本身的一部分,而是编译器本身定义存储的单独项目),也不包括USAGE INDEX。