수색…


비고

RELEASE 문은 프로그래머가 제어하는 ​​조건에서 COBOL SORT 알고리즘에 레코드를 제공하는 데 사용됩니다.

RELEASE 문 구문 다이어그램

SORT INPUT PROCEDURE로 레코드를 풀어 라.

이것은 인위적인 샘플입니다. 대소 문자가 함께있는 ALPHABET 을 기준으로 레코드를 정렬합니다. Aa 는 다른 문자와 비교하여 바뀝니다. 이것은 가능성을 입증하기 위해 의도적으로 수행되었습니다. SORT 알고리즘 판독기는 INPUT PROCEDURE 에서 RELEASE 를 사용하여 레코드를 검색합니다. OUTPUT PROCEDURESORT 알고리즘 작성기에 RETURN 을 사용합니다.

GCobol >>SOURCE FORMAT IS FIXED
      ******************************************************************
      * Purpose:   A GnuCOBOL SORT verb example
      * Tectonics: cobc -x sorting.cob
      *     ./sorting <input >output
      *   or simply
      *     ./sorting
      *   for keyboard and screen demos
      ******************************************************************
       identification division.
       program-id. sorting.

       environment division.
       configuration section.
      * This sets up a sort order lower/upper except for "A" and "a"
       special-names.
           alphabet mixed is " AabBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTu
      -"UvVwWxXyYzZ0123456789".

       input-output section.
       file-control.
           select sort-in
               assign keyboard
               organization is line sequential.
           select sort-out
               assign display
               organization is line sequential.
           select sort-work
               assign "sortwork".

       data division.
       file section.
       fd sort-in.
          01 in-rec        pic x(255).
       fd sort-out.
          01 out-rec       pic x(255).
       sd sort-work.
          01 work-rec      pic x(255).

       working-storage section.
       01 loop-flag        pic x value low-value.

       procedure division.
       sort sort-work
           on descending key work-rec
           collating sequence is mixed
           input procedure is sort-transform
           output procedure is output-uppercase.

       display sort-return.
       goback.

      ******************************************************************
       sort-transform.
       move low-value to loop-flag
       open input sort-in
       read sort-in
           at end move high-value to loop-flag
       end-read
       perform
           until loop-flag = high-value
               move in-rec to work-rec
               RELEASE work-rec
               read sort-in
                   at end move high-value to loop-flag
               end-read
       end-perform
       close sort-in
       .

      ******************************************************************
       output-uppercase.
       move low-value to loop-flag
       open output sort-out
       return sort-work
           at end move high-value to loop-flag
       end-return
       perform
           until loop-flag = high-value
               move work-rec to out-rec
               write out-rec end-write
               return sort-work
                   at end move high-value to loop-flag
               end-return
       end-perform
       close sort-out
       .

       exit program.
       end program sorting.


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow