HP 3000 Manuals

Operation (cont.) [ Micro Focus COBOL System Reference, Volume 1 ] MPE/iX 5.0 Documentation


Micro Focus COBOL System Reference, Volume 1

Operation (cont.) 

Work Phase Completion 

To complete the work phase, select command mode, press Space and then
Enter.  Space is the command to release the work screen for processing.

Forms-2 completes the work phase (depending on the file selections from
initialization screen I02) as follows:

   1.  If this is a variable data field definition work phase (options C
       or D from work phase screen W01), validation then occurs with the
       message:

       WORK SCREEN VALIDATION in progress - DO NOT press RETURN.

   2.  If you selected .DDS file generation from initialization screen
       I02, the source code produced is echoed to the screen as it is
       written to disk.  If you used the S9 command, processing stops
       after each line of code to enable you to make changes as required.
       This is recommended only if special requirements dictate its use.

   3.  If you requested a screen image file from initialization screen
       I02, the screen image is echoed to the screen as it is written to
       the disk file.  The name of the created file is displayed and you
       must press Enter to continue.

   4.  Work phase screen W01 is redisplayed so that you can terminate the
       run or continue.

       If any other character is encountered, an error is signaled by the
       validation routine by alternately displaying "?" and the offending
       character to give a flashing effect.  This error indication then
       ceases and Forms-2 returns to edit mode with the cursor positioned
       under the erroneous character.  You must repeat the Space command
       after making any corrections.

       Forms-2 allows editing characters but does not verify that the
       combinations of these are valid; Micro Focus COBOL editing rules
       must therefore be obeyed to ensure error free code.  Note that
       these fields should be separated by spaces.

       Only foreground data is output to the screen image file.

Data Descriptions 

This section describes the Micro Focus COBOL data descriptions that
Forms-2 generates in the .DDS file.  You need some knowledge of Micro
Focus COBOL to fully understand the topics in this section.

The Micro Focus COBOL extensions to the ACCEPT and DISPLAY verbs allow
comprehensive screen handling to be included in a user application (see
your Language Reference).  Programming the necessary data description
statements can be tedious and expensive in terms of programmer time,
particularly since it is very prone to simple errors.

Forms-2 simplifies the production of error-free data descriptions by
enabling you to specify screen layouts (forms) in the most convenient
way, namely by setting them up on the screen as described in the sections
Initialization Phase and Work Phase.  If you invoke the facility by
selecting an appropriate option from initialization screen I02 during the
initialization phase, Forms-2 automatically converts this input to the
necessary Micro Focus COBOL statements and outputs these to a data
description (.DDS) file.  You then simply incorporate these statements in
your application source code by means of the Micro Focus COBOL COPY verb
and use record-names consistent with those generated by Forms-2.

Record-name and Data-name Generation.   

Initialization screen I01 prompts you for a base-name.  This is a
six-character field into which you enter any name of your choice
consistent with COBOL data naming (see your Language Reference).  This
base is then used to generate the COBOL data and record-names as
described in the following sections.

Record Naming.   

The default record-name format generated by Forms-2 for inclusion in your
Micro Focus COBOL source program for screen formatting is as follows:

bbbbbb-rr (01 level)

where:

bbbbbb        is the 1-6 character base that you specified at
              initialization screen I01.

rr            is the record number, starting at 00, in the first work
              phase and increasing by one for each subsequent work phase.

If you use the window commands to define a window starting in a line
other than line 1, the record-name generated is:

bbbbbb-rr-ll 

where:

ll            is the line number.

This serves as a useful reminder when coding the appropriate
ACCEPT/DISPLAY statements.

Data Naming.   

The elementary data naming structure generated by Forms-2 for inclusion
in your Micro Focus COBOL source program for screen formatting is as
follows:

bbbbbb-rr-nnnn 

where:

nnnn          is the sequence of this field within the screen, starting
              at 0001.

Sometimes it might be more convenient to have the screen coordinates
incorporated in the data-name rather than a field sequence number.  You
can do this by using the G command during the work phase.  See the
section Programming Commands for a description of the G command.

Picture Generation.   

Generation of PICTURE clauses by Forms-2 depends on the type of text you
select at work phase screen W01 at the start of each work phase.  Forms-2
forces field boundaries at the end of each line in order to be compatible
with certain types of terminal.

Fixed Text.   

At the end of a fixed text work phase, Forms-2 generates only FILLER
areas or named alphanumeric fields with associated VALUE clauses.

The Micro Focus COBOL interactive ACCEPT and DISPLAY verbs operate only
on named fields; FILLER areas are left alone.  The time taken to display
a screen depends both on the size and also the number of constituent
fields.

When processing fixed text screens, Forms-2 by default generates FILLER
wherever multiple spaces appear.  You can alter this default by using the
J command described in the section Programming Commands.  Alternatively,
you can use the underscore character (_) to force inclusion of spaces
within a VALUE clause.  You can alter the default character used for this
purpose by using the M command described in the section Programming 
Commands.

Variable Data Fields.   

At the end of a variable data work phase Forms-2 generates alphanumeric,
numeric or numeric edited fields depending on the actual characters that
you keyed in (see the section Work Phase).  These are usually the Micro
Focus COBOL characters 9 and X, but note the additional use of 8 and Y as
alternatives to 9 and X.

Also note the exclusion of S, V and P as described under Variable Data in
the section Work Phase.

Editing a .DDS File.   

Normally the .DDS file output from Forms-2 should be all that you
require.  Where special circumstances dictate the use of particular
data-names or the disallowed picture characters, the S9 command (see the
section Programming Commands) enable you to edit lines in a .DDS file
prior to output.  Alternatively, you can use a conventional text editor
to edit the file.  However, note that this editing process must be
repeated if you ever change the form using Forms-2.

You can also completely suppress output of the .DDS file for a particular
work phase by using the S1 command (see the section Programming Commands.
If you use this command, the record number incorporated in data-names is
still incremented by 1 for the next work phase.

Including a .DDS File in Your Program.   

To incorporate the generated data descriptions into your application
program, all you need to do is copy the .DDS file using the COPY verb
available in Micro Focus COBOL. The COPY verb is described in your
Language Reference.

For example, the COPY statement to incorporate the demo1 sample forms
designed in the section Screen Generation Example would be:

      000000 COPY "demo1.DDS".

and should be included in the Data Division of your program.

This statement is included in all checkout or index programs generated.
Refer to any such program for an example.

The Checkout Program 

This section describes the checkout program that Forms-2 can generate
automatically while generating the created forms.  The checkout program
enables you to:

   *   Validate the .DDS file.

   *   Demonstrate the operation of the proposed application.

   *   Check the use of your forms for data entry.

   *   Check the use of your forms for data amendment.

The checkout source code, which is in Micro Focus COBOL, includes a COPY
statement for the .DDS file exactly as it would be coded in your
application.  It is therefore a true validation of the .DDS file when it
is submitted to your Micro Focus COBOL system.

If you include numeric edited fields in the variable data fields of a
form, error-free code is not guaranteed with standard Micro Focus COBOL.
To fully validate numeric edited fields you must submit your program to
the Micro Focus COBOL system.  If errors occur when you submit your
program, you can use the Forms-2 screen image facility to recall the
offending screen and alter the variable text numeric edited fields as
necessary.

Generating a Checkout Program.   

The checkout program logic is a sequence of DISPLAY or ACCEPT statements
for the screens that you defined in the Forms-2 run, in the order in
which they were created.  Therefore, by entering all required forms in a
single Forms-2 run, a demonstration program using all the forms can be
simply and rapidly created, with no programming necessary.

For a complex application the best method might be to create each form in
isolation, using screen image output only.  Forms-2 can then be run again
to produce the required checkout program, using the facility to re-input
screen images (the F command and the D option in the subsequent screen
display).  Use of this facility would also enable you to set up a complex
sequence of screens for demonstration purposes incorporating the same
screen more than once.

After passing through the sequence of screens, the checkout program gives
you the option of repeating the whole sequence.  On the second pass,
previously entered data is redisplayed, allowing you to check your forms
for both initial data entry and data amendment.

Compiling a Checkout Program.   

You submit your checkout program to the Micro Focus COBOL system in the
usual way, by entering the command:

cob -ik base-name.CHK

Running a Checkout Program.   

There are three stages to running the checkout program:  loading,
checkout processing and checkout completion.  These processes are
described in the following sections.

Loading.   

You can run the executable program produced when you submitted your
checkout program to the Micro Focus COBOL system, by entering the
following command:

cobrun base-name 

Checkout Processing.   

The basic function of the checkout program is to display the fixed text
fields of your form and enable data to be entered into the variable data
fields of the form in the sequence in which the screens were created.

However, the detailed logic is slightly more sophisticated.  The
following notes make references to the options taken for screen type at
work phase screen W01, and these are discussed in the section Work Phase 
Screen W01.

   *   Fixed Text Screens

       The fixed text of a form is displayed.  If there are two
       consecutive fixed text forms, the checkout program pauses after
       the first display until you press Enter.

          1.  Fixed text on a clear screen.

              If you selected option A from work phase screen W01 when
              you created the form, checkout clears the terminal before
              displaying the screen.

          2.  Fixed text on last screen.

              If you selected option B from work phase screen W01 when
              you created the screen, any text displayed remains on the
              terminal, except where it is overwritten by the text of the
              new screen.

   *   Variable Data Screens

       An ACCEPT statement is issued for a variable data screen, enabling
       you to enter data in the unprotected areas; that is, the fields
       specified by means of Xs and 9s, and so on.

       You can check the extents of the fields.  For numeric fields you
       can also check that only numeric characters can be entered, and
       the effect of entering the left zero fill character ".".

       On other than the first pass through the sequence of screens the
       previously entered data is redisplayed before the ACCEPT statement
       is issued.

       If the variable data screen includes numeric edited fields, the
       ACCEPT operation for the screen is followed by a corresponding
       DISPLAY operation to show the effect of the editing or
       normalization by the Micro Focus run-time system.  The normalized
       fields are not automatically echoed to the terminal.

Checkout Completion.   

After the entire sequence of screens has been passed, the checkout
program displays the following message:

      CHECK-OUT completed
     Repeat ? [N] (Y=Yes)

If you wish to repeat the sequence of screens, press Y followed by Enter.
Alternatively press Enter to take the default to terminate the program.

Screen Image Files 

This section describes the screen image files that Forms-2 can produce in
addition to, or instead of, the Micro Focus COBOL data description
statements described in the section Data Descriptions.  These files
contain exact text images of the forms that you have designed.

These form images have the following uses:

   *   Provide the basis for changes to the form.

   *   Yield printed copies of the form.

   *   A means of communication between the system designer and the
       applications programmer.

Screen Image File Generation.   

You invoke this facility by selecting option C, D, E or G from
initialization screen I02 during the initialization phase.  The default
option causes screen image output.

Screen images are output to files named base-name.Snn, where base-name is
the name that you entered at initialization screen I01, and nn is a
number 00 through 99.

You can override the default file-name by issuing the S3 command during
the work phase (see the section Programming Commands).  This causes
Forms-2 to request input of the required file-name during processing of
this work screen.

A separate screen image file is created at the end of each work phase,
with the numeric part of the name (nn) being incremented by 1 each time a
new file is created.  A screen image file is structured as a standard
line sequential file with a record for each line of the screen.  Each
screen image contains only text entered during the work phase in which it
is generated; that is, foreground data.  Consequently, for a variable
data work phase, the output screen image contains only Xs, 9s, Ys and 8s.

You can suppress the screen image output from any work phase by issuing
the S2 command during that phase (see the section Programming Commands).
If you use this command, the numeric part of the file-name extension is
still updated for the next phase to keep in line with the record
numbering within the generated .DDS files.

Maintenance 

Micro Focus COBOL data description statements that have been generated
from a user-designed form by Forms-2 are held in a .DDS file.  You might
need to make corrections and adjustments to maintain the form.  You can
maintain a .DDS file using a conventional text editor, but this involves
the high risk of simple but expensive errors, which Forms-2 eliminates. 

To avoid this, Forms-2 enables you to read a screen image file you have
previously saved.  You can do this by running Forms-2 and either issuing
the FF command (see the section Work Screen Manipulation Commands) or
selecting option F from the work phase screen W02 (see the section Work 
Phase Screen W02).  You are then prompted for the identity of the screen
image required.  Forms-2 reads the screen image file into the foreground
area of the work screen and returns you to edit mode.  The form is then
displayed as if it had just been entered and you can make any required
amendments before releasing the screen for processing by using the Space 
command.

When you use Forms-2 for maintenance in this way it overwrites the
existing files, but only after issuing warnings that the files already
exist, and asking you for confirmation to proceed.  For screen image
files Forms-2 offers you the facility of specifying an alternative
file-name if you wish to retain the old version.

Printed Forms 

The screen image files are created as line sequential files in accordance
with the conventions of the operating system.  Therefore you can use
standard software to print them, and the resulting hard copy is an exact
image of your form with no risk of transcription error.

Form Images in the Design Process.   

Form images can be used as a step within the applications design process,
providing a valuable part of the designer/programmer interface.

For interactive applications, design of the user interface; that is, the
screen layouts or forms, could take place well in advance of the actual
program being written, and the forms designer need not have any detailed
knowledge of COBOL.

Forms-2 enables a non-technical user to generate valid Micro Focus COBOL
statements.  An experienced COBOL programmer can then make use of
commands available to generate the most efficient code, for example, by
influencing the number of fields to be displayed.

Thus, it can sometimes be advantageous to use screen image output alone
as an intermediate stage in the design process, with the programmer using
the image files as input to Forms-2 to produce the final .DDS file.  If
you use Forms-2 in this way, both fixed text and variable areas can
conveniently be indicated on a single fixed text screen.  You can then
easily use this screen to generate a .DDS file, and the form designer
does not need to know any details of COBOL data field specifications.

Screen Generation Example 

In this example, you use Forms-2 to build the following data entry form:

        NAME       [                     ]
        ADDRESS    [                     ]
           [                     ]
           [                     ]
        TEL        [    -     ]

where NAME and ADDRESS are alphanumeric fields and TEL is a numeric
field.  You can then use the checkout program generated by Forms-2 to
experiment with data entry.  Then you change the ADDRESS field name to
ABODE. Afterwards, the screen appears as:

        NAME    [                     ]
        ABODE   [                     ]
        [                     ]
        [                     ]
        TEL     [    -     ]

To do this, perform the following steps:

   1.  Invoke Forms-2 with the command:

     forms2

   2.  Forms-2 displays initialization screen I01 requesting a six
       character base for file-names and data-names followed by four
       other questions.  If the terminal is standard (24 lines) no
       further questions need be answered for this screen.  Enter "demo1"
       and press Enter if the default screen size, 24, is correct.

   3.  Forms-2 displays initialization screen I02 to request the output
       file option type and device/directory prefix.  Press Enter to
       accept the default values.

   4.  Forms-2 displays screen W01 to request the screen type option.
       Note the default "A" and press Enter 

   5.  Forms-2 displays a blank screen.  Use the cursor control keys and
       the normal character keys to set up the following text on the
       screen:

         NAME     [                     ]
         ADDRESS  [                     ]
          [                     ]
          [                     ]
         TEL      [    -     ]

     Press Enter.

   6.  Forms-2 inserts "--" in the top left of the screen.  Press Space 
       and then Enter.

   7.  Forms-2 processes the screen to create a fixed text form.  Forms-2
       displays the .DDS source code as generated, followed by a
       redisplay of the fixed text as it is written to the screen image
       file.

       A message is then displayed giving the name of the fixed text
       screen image file created.  Press Enter as requested.

   8.  Forms-2 displays screen W01 to request the screen type option.
       Note the default "C" and press Enter.

   9.  Forms-2 displays the fixed text screen as background data.  Use
       the cursor control keys to enter Xs and 9s alone to set up the
       screen as follows:

            NAME     [XXXXXXXXXXXXXXXXXXXXX]
            ADDRESS  [XXXXXXXXXXXXXXXXXXXXX]
     [XXXXXXXXXXXXXXXXXXXXX]
     [XXXXXXXXXXXXXXXXXXXXX]
            TEL      [999 - 9999]

  10.  Press Enter 

  11.  Forms-2 displays "--" in the top left hand of the screen; press
       Space and then Enter.  There is a short pause while Forms-2
       validates the screen content, during which the following message
       is displayed:

       WORK SCREEN VALIDATION in progress - DO NOT press RETURN

  12.  Forms-2 processes the Xs and 9s to create a variable data form
       displaying the .DDS source code as generated, followed by a
       redisplay of the variable text as it is written to the screen
       image file.

       A message is then displayed giving the name of the variable data
       screen image file created.  Press Enter as requested.

  13.  Forms-2 displays work phase screen W01 again.  Press !  then Enter 
       to terminate the run.  Forms-2 displays the names of the .DDS and
       .CHK files created and displays an END OF RUN message.

  14.  Submit your checkout program to the Micro Focus COBOL system by
       entering:

       cob -iPk demo1.CHK -C copylist

       When you submit your program to the Micro Focus COBOL system, the
       COPYLIST directive ensures that the text of any COPY-files is
       included in your program listing.  See the appendix Directives for 
       Compiler for more information on the COPYLIST directive.

  15.  You can run the two screens produced when you submitted your
       checkout program to the Micro Focus COBOL system, by entering the
       following command:

       cobrun demo1

  16.  The demonstration program then runs.  The fixed data form is
       displayed on the screen.  The variable data form is used to accept
       data.

       Satisfy yourself that the cursor can only be placed in the
       variable fields, and that the data accepted into the fields
       depends on whether X or 9 was specified.  You may also test the
       effect of left fill character ".".

       When satisfied, press Enter to complete.  A message is displayed
       as follows:

       CHECK-OUT completed
       Repeat? [N] (Y=Yes)

       Press Enter to accept the No default and complete.

  17.  The checkout program displays:

       END OF Forms-2 CHECK-OUT

       The variable form is used in the demonstration for accepting data.
       In practice, the form can be used for displaying data as well as
       accepting it.  The demonstration shows the extent and type of each
       field, which is the same in DISPLAY as well as ACCEPT. A useful
       technique for clearing just the variable data fields on the screen
       is to move spaces to the ACCEPT record and then DISPLAY it.

  18.  You can now examine the disk files:

       demo1.DDS
       demo1.CHK
       demo1.S00
       demo1.S01
       demo1.int
       demo1.lst

       to check the output from Forms-2 during this run.

  19.  You have now learned how to use Forms-2 to create screens of fixed
       and variable data automatically for inclusion in your Micro Focus
       COBOL program.

       If you continue with steps 20 onward you can learn to update both
       the fixed and variable data screens already created by moving them
       from background onto foreground.

  20.  Reload Forms-2 by typing:

       forms2

  21.  Forms-2 displays initialization screen I01 requesting the
       six-character file and data-name base as at step 2.  Enter "demo1"
       and press Enter.

  22.  Forms-2 displays initialization screen I02 requesting the output
       file option type and directory; press Enter to accept the default
       values.

  23.  Forms-2 displays the message:

       File already exists:    demo1.DDS
       overwrite? [N] (Y=Yes)

       Press Y then Enter.

       If you enter the No default here, the run is abandoned.

  24.  Forms-2 displays the message:

       File already exists: demo1.CHK
       overwrite? [N] (Y=Yes)

       Press Y then Enter.

       If you enter the No default here, the run is abandoned.

  25.  Forms-2 displays work phase screen W01 again.  Press Enter to
       accept the default option A.

  26.  Forms-2 displays a blank screen in edit mode.  Press Enter to
       enter command mode, then F followed by Enter to invoke the
       foreground/background selection screen, as we want to update our
       form, so it must be in the foreground.

  27.  Forms-2 displays the foreground option screen.  Enter option F,
       then the file-name demo1.S00, then press Enter.

  28.  Forms-2 displays work phase screen W02 again.  Select option A to
       return to edit mode.

  29.  Forms-2 displays the fixed text screen (previously created at step
       5).  Move the cursor to the word ADDRESS and overtype it with
       ABODE. Remember to overtype the extra characters SS with spaces,
       and then press Enter.

  30.  Press Space then Enter.

  31.  Forms-2 displays the following message reminding you that your
       altered fixed text screen image is about to overwrite your
       previous screen image in the file:

       File already exists:    demo1.S00
       overwrite? [N] (Y=Yes)

       Press Y then Enter.

       If you enter the No default here, you are asked for a file
       identity for a new screen image.

  32.  Forms-2 displays the screen image and then displays the file-name
       as follows:

       File created = demo1.S00

  33.  Press Enter to continue.

  34.  Forms-2 displays screen W01 with option C as the default to enable
       specification of variable data fields.  Press Enter to accept the
       default.

  35.  Forms-2 displays the altered fixed text as follows to assist in
       defining the variable fields:

            NAME            [                     ]
            ABODE           [                     ]
            [                     ]
            [                     ]
            TEL             [    -     ]

       Press Enter to enter command mode, then F, then Enter.

  36.  Forms-2 displays work phase screen W02 again.  Enter the option F,
       then the file-name demo1.S01, then press Enter to retrieve your
       variable text created at step 9.

  37.  Forms-2 displays work phase screen W02 with option H as the
       default.  If you press Enter to accept this default, Forms-2
       displays the current foreground contents.  This is only the Xs and
       9s that define the variable data fields, the fixed text is in the
       background area.  Press Enter to re-invoke work phase screen W02.

  38.  Forms-2 displays work phase screen W02 with A as the default.
       Press Enter to accept this default.

  39.  Forms-2 displays the whole form again.  You could now alter the
       variable text fields, if required.

       You have now seen facilities to retrieve fixed text and variable
       text from previously created files.  With a small number of
       variable data fields such as in this example it would, in
       practice, be easier to re-key them.

  40.  Press Enter then Space, then Enter to process the altered form.
       Again, there is a pause while Forms-2 validates the variable
       fields.

  41.  Forms-2 produces the .DDS file then displays the message:

       File already exists: demo1.S01 overwrite? [N] (Y=Yes)

       As before, press Y then Enter.

  42.  A message is displayed as follows:

       File created = demo1.S01

  43.  Forms-2 displays work phase screen W01 again.  This time key !
       and press Enter to complete the run.

  44.  Repeat steps 14 through 17 if you wish to run the checkout program
       again to verify the changed form.

Index Program 

Forms-2 provides facilities to automatically generate a COBOL program to
create and maintain an indexed sequential file.  The input required to
generate the index program and use it to maintain files is supplied
interactively by you.

You can design a data entry screen using Forms-2 by specifying the fields
that comprise the indexed sequential file records in the usual fixed text
and variable text work phases described in the section Work Phase.

The user interface to the generated index program is simply the form
designed by you that reflects the desired record structure.  You need
give no thought to setting up specific command areas, but need only
consider the data requirements.

You must submit the source file of your index program to the Micro Focus
COBOL system, to produce an executable program.

The source file for the index program you generate is written to the file
file-name.GEN. This file provides you with the following facilities
required for the creation and maintenance of an indexed sequential file:

   *   Select records by key field for display (enquiry by key field).

   *   Select records sequentially for display (sequential entry).

   *   Amend existing records.

   *   Delete existing records.

   *   Insert new records.

The program has been developed so that you do not have to explicitly
state the facility to be invoked at any time; the program is able to
follow the logic from the way you manipulate the actual data and cursor
position.

You can see that only the variable text data is written to the file, and
the fixed text data is merely a template to enable each field to be
entered separately at data entry time.  A record in the indexed
sequential file is constructed by concatenating the variable fields of
the form, in the order in which they appear.

The record must include a key area by which it can be uniquely accessed.
The index program logic requires that this key area must be at the
beginning of the record, that is, must be the first integral field(s) in
the form, and must not exceed 32 characters in length.  This key area
constitutes part of the record data.  For convenience, the remaining
fields are known as the data fields.

The section Index Program Example shows the sample application used in
the section Screen Generation Example adapted to create and maintain a
file of names, addresses and telephone numbers.

Index Program Generation.   

You can generate an index program using Forms-2 as described in the
sections Initialization Phase and Work Phase.

All existing Forms-2 facilities are present, but logic is incorporated to
prevent the use of inappropriate features if you select the index program
option.  The steps involved are:

   1.  Initialization.

          a.  Screen I01.

              Specify file and name data base as normal.

          b.  Screen I02.

              Specify option G for index program generation.

   2.  Work Phase One.

          a.  Screen W01.

              Work screen selection:  the program forces the default
              option "A" for fixed text entry by refusing to accept
              anything else, except !  to abandon the run or ?  to
              display help screens.

          b.  Fixed Text Work Screen.

              A blank work screen is then displayed for input of the
              fixed text form.

              Forms-2 commands as described in the section Work Phase are
              available except:

              G : The generated program relies on the default data-name
              structure.  This command is rejected.

              S : It would be inappropriate to switch off .DDS file
              generation, and this command is rejected.

              W : This feature is not available, and the command is
              rejected.  However, the program reserves the bottom line
              for use in the generated program for system messages
              ("RECORD NOT FOUND", for example), and a delimiting line of
              hyphens marks this fact.

       You release the screen for processing by the sequence Enter,
       Space, Enter, when the fixed text screen has been completely
       entered.

       The work screen selection screen is again displayed.

   3.  Work Phase Two.

          a.  Screen W01.

          b.  This time the program forces the default option "C".

              Specify the variable fields as described in the section
              Work Phase; that is, X/Y/8/9 and editing characters.  At
              some time before releasing this screen you must define the
              end-of-key/start-of-data bound within the record.  You do
              this by positioning the cursor on the first data field,
              entering command mode and keying the * command; that is,
              the sequence Enter, *, Enter.

              A key field cannot exceed 32 characters.

              Release the screen by the usual Enter, Space, Enter 
              sequence.  If the program is not satisfied with the
              specification of the key/data boundary, it returns to edit
              mode.

       Upon completion of the variable text screen Forms-2 completes its
       processing and terminates automatically without any need for the
       termination (!)  command.

Files Generated.   

The following files are written to the disk by Forms-2 during index
program generation:

File               Description 

-------------------------------------------------------

base-name.S00      Screen image file

base-name.S01      Variable data

base-name.DDS      COBOL data description statement
                   file

base-name.GEN      Source file for the generated index
                   program

Producing an Executable Index Program.   

Submit your index program to the Micro Focus COBOL system by entering the
command:

cob -ik base-name.GEN

After submitting your index program to the Micro Focus COBOL system, you
can run the executable program produced (see the section Running Your 
Executable Index Program).

Running Your Executable Index Program.   

You can run your executable program by entering the following command:

cobrun base-name 

Data Processing Facilities.   

As soon as the index program is invoked, your form is displayed.

The form remains on the screen throughout the run, processing being
controlled by manipulation of the data in the variable fields.

A screen display reflects the structure of a single record.  You initiate
the required processing function by entering data and positioning the
cursor as described below, and then pressing Enter.  Index program
messages are displayed in an unused area of the screen as necessary.

The basic operator functions and index program messages are described
below, and are sufficient for general use.  Details of the index program
interpretation of data manipulation and cursor position follow this
description.

   *   Enquiry by key field.

       Amend the key fields only, and press Enter.  The required record
       is displayed.  If the record is not found; that is, the key cannot
       be found, the following message is displayed:

             RECORD NOT FOUND

   *   Sequential enquiry.

       Press Enter to show the next record.  If the end of the file is
       reached, the following message is displayed:

             END OF FILE REACHED - RETURN WILL TERMINATE

   *   Amend displayed record.

       Amend the data field only, and press Enter.  The following message
       is displayed:

             RECORD AMENDED

   *   Delete displayed record.

       Press the Home key and press Enter.  The following message is
       displayed:

             RECORD DELETED

   *   Insert new record.

       Amend the key and data fields as required and press Enter.  If the
       data fields currently displayed do not need changing; that is, it
       is required to enter the existing data fields under a new key,
       press Home before pressing Enter.

       The following message is displayed if insertion takes place:

             RECORD WRITTEN

       If a record already exists with the specified key, the current
       display is retained and the following warning is displayed:

             RECORD ALREADY EXISTS WITH THIS KEY

       The facilities available on the subsequent input are as follows:

          *   Force replacement of existing record:

              Press Home then press Enter.

              The record is replaced and the following message is
              displayed:

                            RECORD REPLACED

          *   Amend key field and retry the insertion:

              Amend key fields and press Enter (cursor position is
              unimportant).

          *   Abandon insertion attempt and display existing record:

              Press Enter only.

   *   Terminate Run

       Enquire up to the end-of-file by means of continual sequential
       enquiry or a combination of enquiry by key to a specific record,
       then sequential enquiry.

       When end-of-file is reached the following message is displayed:

             END OF FILE REACHED - RETURN WILL TERMINATE

       Press Enter to terminate the run.

Interpretation of User Requirements.   

The index program interprets your requirements according to the status of
key and data fields and the cursor position as follows:

   *   Key and data fields unchanged.

       The function performed depends on cursor position as follows:

          *   If an end-of-file condition has just been reported, a
              request to terminate the run is assumed regardless of
              cursor position.

          *   Otherwise if you have moved the cursor to the Home position
              and a record is currently displayed, a delete request is
              assumed.

          *   If neither of these conditions exists, a request to display
              the next record relative to the current position in the
              file is assumed.

   *   Key changed and data unchanged.

       The function performed depends on cursor position as follows:

          *   If you have moved the cursor to either the Home position or
              the last data character position, an attempt to insert a
              record is assumed, and processing is as described above for
              "Key and data changed".

          *   Otherwise an enquiry with respect to this key is assumed,
              and either the record is displayed or its absence is
              reported.

   *   Key unchanged and data changed.

       This is a request to update the file, and either a new record is
       written or the existing record amended as appropriate.

   *   Key and data changed.

       This is a request to insert a new record.  However, it is assumed
       that you should not overwrite a record without at least being
       informed of its presence.  Therefore, if a record exists with the
       specified key, a warning message is displayed, and one of the
       following three functions can be performed depending on the status
       of key and data fields and the cursor position:

          *   Key and data unchanged.

              The function required depends on cursor position as
              follows:

                 *   If you have moved the cursor to the Home position
                     (or the last data character position), insertion of
                     the new record is forced, and the existing record is
                     overwritten.

                 *   If the cursor is at any other position, a request to
                     abandon the insertion attempt and display the
                     existing record is assumed.

          *   Data unchanged and key changed.

              An attempt is made to insert the data under the new key
              regardless of cursor position.  If necessary, the warning
              message is repeated.

          *   Key and data changed.

              A normal insert request as described above is assumed.

Index Program Example 

In this example you generate an indexed sequential file that contains
records of names, addresses and telephone numbers with name as key field,
and process these records using the form as used in the section Screen 
Generation Example shown on the following page.

         NAME             [                     ]
         ADDRESS       [                     ]
          [                     ]
          [                     ]
          TEL                 [    -     ]

where NAME and ADDRESS are alphanumeric fields and TEL is a numeric
field.

If you then use the form for data entry and key in John Smith, 500
Chestnut St., Santa Cruz CA 95060, 425-7222, the form appears as:

         NAME             [John Smith           ]
         ADDRESS       [500 Chestnut St.     ]
          [Santa Cruz           ]
          [CA 95060             ]
         TEL                  [425 - 7222]

To do this, carry out the following steps:

   1.  Invoke Forms-2 with the command:

       forms2

   2.  Forms-2 displays initialization screen I01 requesting a six
       character base for file-names and data-names followed by four
       other questions.  If the terminal is standard (24 lines), no
       further questions need be answered for this screen.  Enter demo2
       and press Enter if the default screen size (24) is correct.

   3.  Forms-2 displays initialization screen I02 to request the output
       file option type and directory.  Press G then Enter to accept the
       option for the index program.

   4.  Forms-2 displays work phase screen W01 to request the screen type
       option.  Note the default "A" and press Enter.

   5.  Forms-2 displays a blank screen with the end of window one line up
       from the bottom of the screen and delimiters in the bottom line.
       Use the cursor control keys and the normal character keys to set
       up the following text on the screen:

               NAME              [                     ]
               ADDRESS        [                     ]
                 [                     ]
                 [                     ]
                TEL                  [    -     ]

       Press Enter 

   6.  Forms-2 inserts "--" in the top left hand of the screen.  Press
       Space then Enter.

   7.  Forms-2 processes the screen to create a fixed text form.  Forms-2
       displays on the terminal the .DDS source code as it is generated,
       followed by a redisplay of the fixed text as it is written to the
       screen image file.

       A message is then displayed giving the name of the fixed text
       screen image file created.  Press Enter as requested.

   8.  Forms-2 displays work phase screen W01 to request the screen type
       option.  Note the default is "C" and press Enter.

   9.  Forms-2 displays the fixed text screen as background data; now use
       the cursor control keys and key in Xs to fill in the NAME variable
       data field.  Move the cursor to the first character position in
       the address variable data field and then press Enter to enter
       command mode.  Enter &* to set the first character position in the
       ADDRESS variable data field as the start of data position and then
       press Enter.  Continue to enter Xs and 9s to fill the data fields
       as shown below:

               NAME              [XXXXXXXXXXXXXXXXXXXXX]
               ADDRESS        [XXXXXXXXXXXXXXXXXXXXX]
                 [XXXXXXXXXXXXXXXXXXXXX]
                 [XXXXXXXXXXXXXXXXXXXXX]
                TEL                  [999 - 9999]

       Press Enter.

       You have now specified the NAME variable data field as the key
       field.  Press Enter.

  10.  Forms-2 displays "--" in the top left hand of the screen; press
       Space and then Enter.  A message is displayed showing that
       validation is in progress.

  11.  Forms-2 processes the Xs and 9s to create a variable data form,
       and displays to the terminal the .DDS source code as generated,
       followed by a redisplay of the variable text as it is written to
       the screen image file.

  12.  Forms-2 terminates automatically after displaying the end of run
       screen:

            File created = demo2.DDS
            File created = demo2.GEN
            END OF FORMS2 RUN

  13.  Submit your index program to the Micro Focus COBOL system by
       entering:

       cob -C copylist -P -ik demo2.GEN

       When you submit your program to the Micro Focus COBOL system, the
       COPYLIST directive ensures that the text of any COPY-files is
       included in your program listing.  See the appendix Directives for 
       Compiler for information on the COPYLIST directive.

  14.  You can run the executable index program produced when you
       submitted your index program to the Micro Focus COBOL system, by
       entering:

       cobrun demo2

  15.  The executable index program then runs.  Your screen as designed
       in step 9 is displayed.  The fixed text form is displayed on the
       screen.  The variable data fields are used to accept data.

  16.  You are now ready to practice all the file maintenance commands.
       The next steps show all of these in use, but you can vary the
       sequence or add any steps to these once you have gained
       confidence.

  17.  To insert the first record into the new indexed sequential file,
       simply key names and addresses into the screen format, terminating
       each record by pressing Enter.  Remember to enter surname first
       before initials to keep the application feasible.

  18.  Enter two more complete records, overtyping all data from the
       previous record, because all displayed data is written to the
       file.

  19.  When you have inserted three records you can amend the second
       record as follows:

       Enter the name field as for the second record added, followed by
       Enter.  The whole record is displayed because the name is the key
       that finds that record.  You have now seen the enquiry facility in
       operation.  You can recall any record as easily as that.

  20.  Change the town field and press Enter.  The following message is
       displayed:

             RECORD AMENDED

  21.  Press Enter and the third record is displayed.  You can progress
       through a whole file in this way.

  22.  To delete the third record entered move the cursor to the Home
       position and press Enter.  The fields clear showing deletion of
       that record, and the following message is displayed:

             RECORD DELETED

  23.  Press Enter.  The index program attempts to show the next record,
       but one does not exist so the following message is displayed:

             END OF FILE REACHED - RETURN WILL TERMINATE.

  24.  Press Enter with end of file showing to terminate the program.

       You have now seen the record handling method demonstrated.

  25.  At this point the following files exist in your directory:

demo2.DDS           Data Description Statements for form
                    (COBOL source)
demo2.GEN           Source code of index program demo2.
demo2.int           Intermediate code of index program
demo2.lst           Listing of index program processed by the
                    Micro Focus COBOL system
demo2.DAT.idx       Index file
demo2.DAT           Data file

       The two files demo2.DAT.idx and demo2.DAT constitute the indexed
       sequential file created by the generated index program, and in any
       further runs of this program these two files are used.



MPE/iX 5.0 Documentation