Cobol 参考修改:"MOVE Variable(Variable +literal:literal) TO Variable" 到底做了什么?

Cobol Reference Modification: What exactly does "MOVE Variable(Variable +literal:literal) TO Variable" do?

关于 Cobol 中的引用修改,有一件事我不明白。

例子是这样的:

MOVE VARIABLE(VARIABLE2 +4:2) TO VARIABLE3

现在我不太明白“+4:2”指的是什么。是不是说目标移动后的前2个标志4个标志?这意味着如果例如 VARIABLE(第一个)填充为“123456789”并且 VARIABLE2 包含该变量中的第二个和第三个位置(因此“23”),则目标是“23 +4”,意思是“789”。然后将目标中的前两个位置(由“:2”表示)移动到 VARIABLE3。所以最终 VARIABLE3 将包含“78”。

我理解的是否正确,还是我对该指令做出了错误的假设?

(VARIABLE2 +4:2)是语法错误,因为起始位置必须是算术表达式。 + 之后必须有一个 space 才能使此 reference modification 有效。并且,VARIABLE2 必须是数字,表达式的计算结果应为整数。

更正后,将4添加到VARIABLE2的内容中。这是移动的 VARIABLE1 内的最左边(或起始位置)。 2 个字符移动到 VARIABLE3。如果VARIABLE3超过两个字符,则剩余位置用space填充。


来自 2002 COBOL 标准:

8.7.1 Arithmetic operators

There are five binary arithmetic operators and two unary arithmetic operators that may be used in arithmetic expressions. They are represented by specific COBOL characters that shall be preceded by a space and followed by a space except that no space is required between a left parenthesis and a unary operator or between a unary operator and a left parenthesis.

添加了重点。