0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gnu-COBOL 集合項目

0
Last updated at Posted at 2020-09-01

集合項目

  • 違う種類のデータをまとめて扱う
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.

DATA DIVISION.
  WORKING-STORAGE SECTION.
    01 PARENT.                    *> レベル番号「01」は「03」の親要素になる
      03 CHILD1 PIC X(5).         *> レベル番号「03」は「01」の子要素になる
      03 CHILD2.                  *> レベル番号「05」は「03」の子要素になる
        05 GRAND-CHILD PIC X(15).  *> 親要素になる変数は「PIC」を定義することはできない
                                  *> 基本的には「01」「03」「05」など2飛ばしや5飛ばしで付けられる

PROCEDURE DIVISION.
  MAIN SECTION.
    MOVE "PARENT" TO PARENT.
    MOVE 12345 TO CHILD1.
    MOVE "GRAND-CHILD" TO GRAND-CHILD.
    DISPLAY PARENT.
    DISPLAY CHILD1.
    DISPLAY CHILD2.
    DISPLAY GRAND-CHILD.
    STOP RUN.

コンパイル/実行

コンパイル

USER-no-MacBook-Air:COBOL user$ cobc -x --free hello.cob

実行

USER-no-MacBook-Air:COBOL user$ ./hello
12345GRAND-CHILD    
12345
GRAND-CHILD    
GRAND-CHILD 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?