HP 3000 Manuals

Operation (cont.) [ COBOL/HP-UX Operating Guide for the Series 700 and 800 ] MPE/iX 5.0 Documentation


COBOL/HP-UX Operating Guide for the Series 700 and 800

Operation (cont.) 

Data Descriptions 

This section describes the Micro Focus COBOL data descriptions that
Forms-2 generates in the .DDS file.  You will need some knowledge of
Micro Focus COBOL.

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
allowing 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 at 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 merely 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 asks 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 names.

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
                      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 will be:

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 may 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.

Picture Generation.   

Generation of PICTURE clauses by Forms-2 depends on the type of text you
select at screen W01 at the start of each work phase.  Note that Forms-2
will force 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 "Work Phase" .  Alternatively, you
can use underline (_) 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 "Work Phase" .

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 the DDS File.   

Normally the DDS 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 "Work
Phase" ) will allow you to edit DDS lines 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
amend the form using Forms-2.

You can also completely suppress the DDS output for a particular work
phase by using the S1 command.  Note that if you use this, the record
number incorporated in data names will still be stepped up by 1 for the
next work phase.

Incorporation of DDS File Contents.   

All that you have to do to incorporate the generated data descriptions
into your application program is to copy in the DDS file using the COPY
statement available in Micro Focus COBOL. This is described in your
Language Reference.

The COPY statement to incorporate the demo1 sample forms designed in the
section "Forms-2 User Screen Generation Example"  would be:

     000000 COPY "demo1.DDS".

and would be coded within the DATA DIVISION.

This statement is included in all checkout or index programs generated,
and you can refer to any of these 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:

   1.  Validate the DDS file

   2.  Demonstrate the operation of the proposed application

   3.  Check the use of your forms for data entry

   4.  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.

Checkout Program Generation.   

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, checkout 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 Your 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 Your Checkout Program.   

There are three stages to running the checkout program:  loading,
checkout processing and checkout completion.

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
screen W01, and these are discussed in the section "Work Phase" .

   *   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 when you created the form,
              checkout clears the terminal before displaying the screen.

          2.  Fixed text on last screen

              If you selected option B 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, allowing
       you to enter data in the unprotected areas (that is, the fields
       specified by means of X's and 9's, and so on).

       You can check the extents of the fields.  For numeric fields you
       can also check that only numeric characters may 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 is
       issued.

       If the variable data screen includes numeric edited fields, the
       ACCEPT for the screen is followed by a corresponding DISPLAY to
       show the effect of the editing or normalization by the Micro Focus
       run-time system.  Note that 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:

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

If you wish to repeat the sequence of screens, key Y and press Enter.

Otherwise simply press Enter to take the default to terminate the
program.

Screen Image File 

This section describes the screen image file 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 can be:

   *   Used to provide the basis for amendments to the form

   *   Printed to yield printed copies of the form

   *   Used as a means of communication between the system designer and
       the applications programmer

Screen Image File Generation.   

You invoke this facility by selecting an appropriate option at screen I02
during the initialization phase.  Note that the default option will cause
screen image output.

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

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

A separate file is created at the end of each work phase, the numeric
part of the name (nn) is incremented by 1 each time.  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 - see
the section "Work Phase" ).  Consequently, for a variable data work
phase the output screen image contains only X's, 9's, Y's and 8's.

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

Forms-2 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 will
probably 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. 

Therefore, your form is output to a screen image file as an exact image,
and Forms-2 provides you with the facility to read screen images back
from disk to allow you to amend them.  You can do this by running Forms-2
and issuing the FF command once the first work screen is reached (see the
Fx work screen manipulation command in the section "Work Phase" ).
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 keyed 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 will overwrite 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 resultant hard copy will be 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) may 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 make use of commands
available to generate the most efficient code (for example, by
influencing the number of fields to be displayed).

Thus it may 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 could
conveniently be indicated on a single fixed text screen.  You can then
easily use this screen to generate the DDS file, and the form designer
does not need to know any details of COBOL data field specifications.

Forms-2 User Screen Generation Example 

In this example, you will use Forms-2 to build the 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 will change the ADDRESS field name
to ABODE. Afterwards, the screen will appear as:

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

To do this, you must follow these steps:

   1.  Invoke Forms-2 with the command:

            forms2

   2.  Forms-2 displays 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.  Key "demo1" and press Enter if the
       default screen size (24) is correct.

   3.  Forms-2 displays 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       [    -     ]

       Note that the underline characters are treated as spaces when the
       form is displayed by an applications program, and are provided
       only for your convenience for indicating the fields to be
       redefined as variable fields.

       Press Enter.

   6.  Forms-2 puts " " 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 and key in X's and 9's alone to set up the
       screen as follows:

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

                 Press Enter

  10.  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

  11.  Forms-2 processes the X's and 9's 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.

  12.  Forms-2 displays screen W01 again.  Key !  and press Enter to
       terminate the run.  Forms-2 displays the names of the DDS and CHK
       files created and displays an END OF RUN message.

  13.  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.

  14.  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

  15.  The demonstration program will then run.  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? [NO] (Y=Yes)

       Press Enter to accept the No default and complete.

  16.  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 will be 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.

  17.  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 use.

  18.  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 19 onward you will learn to update both
       the fixed and variable data screens already created by moving them
       from background onto foreground.

  19.  Reload Forms-2 by typing:

            forms2

  20.  Forms-2 displays screen I01 requesting the six-character file and
       data name base as at step 2.  Answer the questions as necessary at
       step 2 and press Enter.

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

  22.  Forms-2 displays the message:

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

       Key Y and press Enter.

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

  23.  Forms-2 displays the message:

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

       Key Y and press Enter.

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

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

  25.  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.  (We want to update our
       form, so it must be in foreground.)

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

  27.  Forms-2 displays screen W02 again.  Select option A to return to
       edit mode.

  28.  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.

  29.  Press Space then Enter.

  30.  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)

       Enter Y and press Enter.

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

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

            File created = demo1.S00

       Press Enter to continue.

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

  33.  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.

  34.  Forms-2 displays 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.

  35.  Forms-2 displays screen W02 with option H as default.  If you
       press Enter to accept this default, Forms-2 displays the current
       foreground contents.  Note that this is only the X's and 9's that
       define the variable data fields (the fixed text is in the
       background area).  Press Enter to re-invoke screen W02.

  36.  Forms-2 displays screen W02 with A as default.  Press Enter to
       accept this default.

  37.  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.  Note that with a small number
       of variable data fields such as in this example it would, in
       practice, be easier to re-key them.

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

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

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

       As before, enter Y and press Enter.

  40.  A message is displayed as follows:

            File created = demo1.S01

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

  42.  Repeat steps 15 through 17 if you wish to run the checkout program
       again to verify the altered form.

Index Program 

Forms-2 provides facilities for automatically generating 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 through the terminal.

You can design a data entry screen using Forms-2 by specifying the fields
that will 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.

Note that 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:

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

   2.  Select records sequentially for display (sequential entry)

   3.  Amend existing records

   4.  Delete existing records

   5.  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 "User Index Program Example"  shows the sample application
used in the section "Data Descriptions"  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 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 will return 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.  In fact the !  command is only used to
       abandon the run when generating the index program.

Files Generated.   

The following files are written to the disk by Forms-2:

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.

Running Your Index Program.   

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

cobrun base-name

Data Processing Facilities 

Immediately the 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 will suffice in general use.  Details of the index program
interpretation of data manipulation and cursor position follow this
description.

   *   Enquiry By Key Field

       Amend key fields only, and press Enter.  The required record is
       displayed.  If the record is not found (that is, key cannot be
       found) the message RECORD NOT FOUND is displayed.

   *   Sequential Enquiry

       Simply press Enter to show next record.  If the end of the file is
       reached, the message END OF FILE REACHED - RETURN WILL TERMINATE
       is displayed.

   *   Amend Displayed Record

       Amend data field only, and press Enter.  The message RECORD
       AMENDED is displayed.

   *   Delete Displayed Record

       Press the Home key and press Enter.  The message RECORD DELETED is
       displayed.

   *   Insert New Record

       Amend 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 message NEW RECORD WRITTEN is displayed if insertion takes
       place.  If a record already exists with the specified key, the
       current display is retained and the warning RECORD ALREADY EXISTS
       WITH THIS KEY is displayed.  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 message RECORD REPLACED is
              displayed.

          *   Amend key field and re-attempt the insertion:

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

          *   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 message END OF FILE REACHED -
       RETURN WILL TERMINATE is displayed.  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 irrespective 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 under 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:

          *   A Key and Data Unchanged

              The function required depends on cursor position as
              follows:

                 *   If you have moved the cursor to 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
              irrespective of cursor position.  If necessary, the warning
              message will be repeated.

          *   Key and Data Changed

              A normal insert request as described above is assumed.

User Index Program Example 

In this example you will 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 "Forms-2 User Screen Generation Example" :

     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 will appear as:

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

To do this, carry out the following steps:

   1.  Enter:

            forms2

   2.  Forms-2 displays 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.  Key "demo2" and press Enter if the
       default screen size (24) is correct.

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

   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 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 puts " " in the top left hand of the screen.  Press Space 
       and 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 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 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 X's 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 X's and 9's to
       fill the data fields as shown below:

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

                 Press Enter

       Note that 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 X's and 9's 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.

  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 will then run.  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 practise 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, overkeying 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 message RECORD AMENDED
       is displayed.

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

  22.  To delete the third record entered move the cursor to HOME
       position and press Enter.  The fields clear showing deletion of
       that record, and a message RECORD DELETED is displayed.

  23.  Press Enter.  The index program attempts to show the next record,
       but one does not exist so an end of file message is shown:  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 will 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 will be used.



MPE/iX 5.0 Documentation