Skip to main content

Dialog System: Use of the Vocabulary features?

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

Dialog System: Use of the Vocabulary features: using "EMBEDDED DIALOG SYSTEM functions " in a COBOL program

Resolution:

DS online help:

____________________________________________________________________________

1) Generate the Vocabulary Copybook.

( DS online help: Dialog System Vocabulary-> Using the vocabulary )

From the Dialog System main window, load a screenset, using the Open option from the File menu. Select the Generate option from the

File menu, and then select Vocabulary Copybook. This will generate a .cpy file with the same name as the loaded screenset.

The vocabulary copybook contains a list of all of the objects within a screenset. Each variable in the copybook is given the same name as the object in the screenset that it represents.

...

____________________________________________________________________________

2.

Add dslang.cpy to the program using the vocabulary.

The file dslang.cpy is provided in the source directory. You must add it before the IDENTIFICATION DIVISION in the program, using the vocabularies. This file provides the link between the vocabulary statements used and Dialog System.

____________________________________________________________________________

3.

Add the generated copybook to your COBOL program.

Add the vocabulary copybook in your WORKING-STORAGE SECTION.

____________________________________________________________________________

4.

Add the Dialog functions you require to your COBOL program.

____________________________________________________________________________

5.

Compile the program.

____________________________________________________________________________

Demo:

in the sample code below, the screenset used contains

---> a PUSH-BUTTON to ask the cobol program to fill the SELECTION-BOX

            ( Dialog of the of  sets EXIT-FLAG to 3)

---> a PUSH-BUTTON to ask the cobol program to insert an item in the SELECTION-BOX

            ( Dialog of the of  sets EXIT-FLAG to 4)

---> a PUSH-BUTTON to ask the cobol program to delete an item in the SELECTION-BOX

            ( Dialog of the of  sets EXIT-FLAG to 5)

---> a PUSH-BUTTON to ask the cobol program to update an item in the SELECTION-BOX

            ( Dialog of the of  sets EXIT-FLAG to 6)

From the Paste below, note the COBOL program managing the screenset uses "EMBEDDED Dialog System" calls ( = use of DS functions )

       COPY "dslang.cpy".

       IDENTIFICATION DIVISION.

       PROGRAM-ID. pselbox.

       ENVIRONMENT DIVISION.

       configuration section.

       special-names.

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       78  dialog-system               VALUE "DSGRUN".

       01 Display-Error.

          03 Display-Error-No             PIC 9(4) comp-5.

          03 Display-Details-1            PIC 9(4) comp-5.

          03 Display-Details-2            PIC 9(4) comp-5.

       COPY "DS-CNTRL.MF".

       COPY "selbox.CPB".

       COPY "SELBOXvoc.cpy".  *> DS File->Generate->Vocabulary copybook

       01 wrkpos                          PIC 9(8) COMP-X.

       PROCEDURE DIVISION.

      *---------------------------------------------------------------*

       Main-Process SECTION.

          PERFORM Program-Initialize

          PERFORM Program-Body UNTIL EXIT-FLAG-TRUE

          PERFORM Program-Terminate

          .

      *---------------------------------------------------------------*

       Program-Initialize SECTION.

          INITIALIZE Ds-Control-Block

          INITIALIZE Data-block

          MOVE Data-block-version-no

                                   TO Ds-Data-Block-Version-No

          MOVE Version-no TO Ds-Version-No

          MOVE Ds-New-Set TO Ds-Control

          MOVE "selbox" TO Ds-Set-Name

          .

      *---------------------------------------------------------------*

       Program-Body SECTION.

          PERFORM Call-Dialog-System

          *> fillup SB

          if exit-flag = 3

             initialize anItem item-selected wrkpos

             perform 5 times

                add 1 to wrkpos item-selected

                string "Item" item-selected  into anItem

                insert-list-item sb1 anItem wrkpos

                move anItem to GRelt(item-selected)

             end-perform

             refresh-object win1

          end-if

          *> insert-item

          if exit-flag = 4

               display

                   "*--> item to insert: " wrkitem

                   " at position: " item-selected

               move wrkitem to anitem

               move item-selected to wrkpos

               insert-list-item sb1 anitem wrkpos

               move anItem to GRelt(item-selected)

               refresh-object sb1

               refresh-object win1

          end-if

          *> delete-item

          if exit-flag = 5

               display

                   "*--> item to delete: " anitem

                   " at position: " item-selected

               move item-selected to wrkpos

               initialize anitem

               move anItem to GRelt(item-selected)

               delete-list-item sb1  wrkpos 1

               refresh-object sb1

               refresh-object win1

          end-if

          *> update-item

          if exit-flag = 6

               display

                   "*--> item to delete: " GRelt(item-selected)

                   " at position: " item-selected

               move item-selected to wrkpos

               initialize anitem

               delete-list-item sb1  wrkpos 1

               move wrkitem to anitem

               display

                   "*--> item to insert: " anitem

                   " at position: " item-selected

               move item-selected to wrkpos

               move anItem to GRelt(item-selected)

               insert-list-item sb1 anitem wrkpos

               refresh-object sb1

               refresh-object win1

          end-if

          if not exit-flag-true

               move 0 to exit-flag

          end-if

          .

      *---------------------------------------------------------------*

       Program-Terminate SECTION.

          STOP RUN

Old KB# 6554

0 replies

Be the first to reply!