IDENTIFICATION DIVISION. PROGRAM-ID. FILENAME-PROVIDER. AUTHOR. COBOLware Services Ltda. DATE-WRITTEN. 99/99/9999. SECURITY. ************************************************* * * * Exemplo de provedor de dados de lista * * * ************************************************* ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. INPUT-OUTPUT SECTION. FILE-CONTROL. COPY FileName-SL. DATA DIVISION. FILE SECTION. COPY FileName-FD. WORKING-STORAGE SECTION. 01 AREAS-DE-TRABALHO-1. 05 REGISTROS PIC 9(002) VALUE 0. COPY CWFSLB REPLACING ==(FileName)== BY FileName SPACES BY "FileName". LINKAGE SECTION. 01 USER-IO PIC X(001). 88 OPEN-FILE VALUE "O" "o". 88 CLOSE-FILE VALUE "C" "c". 88 BEGIN-FILE VALUE "B" "b". 88 END-FILE VALUE "E" "e". 88 AT-END VALUE "*". 88 READ-NEXT VALUE "N" "n". 88 READ-PREVIOUS VALUE "P" "p". 88 NOT-LESS VALUE ">". 88 NOT-GREATER VALUE "<". 88 EDIT-KEY VALUE "$". 01 ORDER-MODE PIC 9(001). 88 ORDER-BY-LEFT VALUE 1. 88 ORDER-BY-RIGHT VALUE 2. 01 LEFT-ITEM. 05 LIST-CODIGO PIC 9(005). 05 FILLER PIC X(075). 01 RIGHT-ITEM. 05 LIST-DESCRICAO PIC X(030). 05 FILLER PIC X(048). 05 FILLER PIC X(001). 88 ALERT VALUE X"01". 05 COLOR-ALERT COMP-X PIC 9(002). 01 HEIGHT PIC 9(002). 01 WORK-AREA PIC X(050). 01 BOXFILESELECT-EDIT PIC 9(003). COPY CWEDIT. 01 BOXFILESELECT-OPTION PIC X(076). PROCEDURE DIVISION USING USER-IO ORDER-MODE LEFT-ITEM RIGHT-ITEM HEIGHT WORK-AREA BOXFILESELECT-EDIT BOXFILESELECT-OPTION. 000-INICIO. EVALUATE TRUE WHEN EDIT-KEY CONTINUE *> Tecla de função em BOXFILESELECT-EDIT *> Item posicionado em BOXFILESELECT-OPTION WHEN OPEN-FILE OPEN INPUT FileName MOVE ZERO TO REGISTROS PERFORM TEST AFTER UNTIL NOT OK-FileName OR REGISTROS EQUAL HEIGHT READ FileName NEXT RECORD IGNORE LOCK IF OK-FileName ADD 1 TO REGISTROS END-IF END-PERFORM IF REGISTROS EQUAL ZERO MOVE 1 TO REGISTROS END-IF IF REGISTROS LESS HEIGHT MOVE REGISTROS TO HEIGHT END-IF WHEN CLOSE-FILE CLOSE FileName WHEN BEGIN-FILE INITIALIZE FileName-RECORD EVALUATE TRUE WHEN ORDER-BY-RIGHT START FileName KEY NOT LESS DESCRICAO WHEN OTHER START FileName KEY NOT LESS FileName-KEY END-EVALUATE WHEN END-FILE MOVE HIGH-VALUES TO FileName-RECORD EVALUATE TRUE WHEN ORDER-BY-RIGHT START FileName KEY NOT GREATER DESCRICAO WHEN OTHER START FileName KEY NOT GREATER FileName-KEY END-EVALUATE WHEN READ-NEXT READ FileName NEXT RECORD IGNORE LOCK IF NOT OK-FileName SET AT-END TO TRUE END-IF WHEN READ-PREVIOUS READ FileName PREVIOUS RECORD IGNORE LOCK IF NOT OK-FileName SET AT-END TO TRUE END-IF WHEN NOT-LESS EVALUATE TRUE WHEN ORDER-BY-RIGHT MOVE LIST-DESCRICAO TO DESCRICAO START FileName KEY NOT LESS DESCRICAO INVALID KEY SET AT-END TO TRUE END-START WHEN OTHER MOVE LIST-CODIGO TO CODIGO START FileName KEY NOT LESS FileName-KEY INVALID KEY SET AT-END TO TRUE END-START END-EVALUATE WHEN NOT-GREATER EVALUATE TRUE WHEN ORDER-BY-RIGHT MOVE LIST-DESCRICAO TO DESCRICAO START FileName KEY NOT GREATER DESCRICAO INVALID KEY SET AT-END TO TRUE END-START WHEN OTHER MOVE LIST-CODIGO TO CODIGO START FileName KEY NOT GREATER FileName-KEY INVALID KEY SET AT-END TO TRUE END-START END-EVALUATE END-EVALUATE MOVE SPACES TO LEFT-ITEM RIGHT-ITEM MOVE CODIGO TO LIST-CODIGO MOVE DESCRICAO TO LIST-DESCRICAO GOBACK. END PROGRAM FILENAME-PROVIDER.