COBOL中变量声明右边的代码有什么意义?
What is the significance of the code at right of variable declaration in COBOL?
我在研究COBOL代码,没看懂代码行右边的数字:
007900 03 EXAMPLE-NAME PIC S9(17) COMP-3. EB813597
第一个数字是关于该行在代码中的位置,第二个是关于列的位置(比如你使用了多少'tabs'),第三个是变量类型,但是第四个(COMP-3) 主要是最后一个 (EB813597) 我没看懂。
这是什么意思?
>= 72 的列将被忽略。所以 EB813597 被忽略了。它可能是上次更改后的更改 ID,或者具有某些特定于站点的含义,例如EB可以是最后修改者姓名的首字母。
Comp-3 - 是数字类型。这有点像在 C/java 中使用 int 或 double。在 Comp-3(压缩十进制)中,123 存储为 x'123c'。 comp-3 的替代方案包括 comp - 通常为大端二进制整数,comp-5(如 C 中的 int / long)
007900 03 EXAMPLE-NAME PIC S9(17) COMP-3. EB813597
(a) (b) Field-Name (c) (d) Usage (numeric type)
a - line-number ignored by the compiler
b - level-number it provides a method of grouping fields together
01 Group.
03 Field-1 ...
03 Field-2 ...
field-1 and field-2 belong to group. it is a bit like struct in c
struct {
int field_1;
int field-2;
...
}
c) PIC (picture) tells us the field picture follows.
d) fields picture in this case it is a signed field with 17 decimal digits
Comp-3 - usage - how the field stored
所以总而言之,EXAMPLE-NAME 是一个 Signed 数字字段,带有 17 十进制数字它存储为 Comp-3(压缩十进制)。
我在研究COBOL代码,没看懂代码行右边的数字:
007900 03 EXAMPLE-NAME PIC S9(17) COMP-3. EB813597
第一个数字是关于该行在代码中的位置,第二个是关于列的位置(比如你使用了多少'tabs'),第三个是变量类型,但是第四个(COMP-3) 主要是最后一个 (EB813597) 我没看懂。
这是什么意思?
>= 72 的列将被忽略。所以 EB813597 被忽略了。它可能是上次更改后的更改 ID,或者具有某些特定于站点的含义,例如EB可以是最后修改者姓名的首字母。
Comp-3 - 是数字类型。这有点像在 C/java 中使用 int 或 double。在 Comp-3(压缩十进制)中,123 存储为 x'123c'。 comp-3 的替代方案包括 comp - 通常为大端二进制整数,comp-5(如 C 中的 int / long)
007900 03 EXAMPLE-NAME PIC S9(17) COMP-3. EB813597
(a) (b) Field-Name (c) (d) Usage (numeric type)
a - line-number ignored by the compiler
b - level-number it provides a method of grouping fields together
01 Group.
03 Field-1 ...
03 Field-2 ...
field-1 and field-2 belong to group. it is a bit like struct in c
struct {
int field_1;
int field-2;
...
}
c) PIC (picture) tells us the field picture follows.
d) fields picture in this case it is a signed field with 17 decimal digits
Comp-3 - usage - how the field stored
所以总而言之,EXAMPLE-NAME 是一个 Signed 数字字段,带有 17 十进制数字它存储为 Comp-3(压缩十进制)。