수색…


비고

RETURN 문은 OUTPUT PROCEDURE 일부로 데이터가 내부 COBOL 정렬 알고리즘 작성기로 전송되는시기를 제어합니다. 포스트 정렬 데이터는 정렬 알고리즘에 의해 리턴되고 출력 파일에 쓰여지기 전에 프로그래머 제어하에 변환 될 수 있습니다.

RETURN 문 구문 다이어그램

레코드를 SORT OUTPUT PROCEDURE로 되 돌린다.

이것은 씨앗 샘플입니다. SORT OUTPUT PROCEDURE 는 정렬 된 레코드가 내부 COBOL 정렬 알고리즘의 쓰기 부분으로 리턴되기 전에 정렬 된 레코드를 조작 할 수 있습니다. 이 경우 변환이 수행되지 않고 work-recout-rec 로 직접 이동됩니다.

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.
      * Set up a sort order where lower and upper case stay together
       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-reader
           output procedure is sort-writer.

       display sort-return.
       goback.

      ******************************************************************
       sort-reader.
       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
       .

      ******************************************************************
       sort-writer.
       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