[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index


Chapter 14
Using the REFORMAT Utility

The REFORMAT Utility converts source programs between terminal format and conventional ANSI format. Consider the two formats and their characteristics:

  • Terminal format eliminates the line-number and identification fields of ANSI format and allows horizontal tab characters and short lines. It saves disk space and decreases compile time.
  • Conventional ANSI format produces source programs compatible with the reference format as defined in the ANSI-85 COBOL Standard.

The HP COBOL Reference Manual describes both formats in detail.

On OpenVMS, REFORMAT is installed by the HP COBOL installation procedure (if you answered "yes" to the query during installation), and is placed in the following location:


  SYS$SYSTEM:REFORMAT.EXE  <>

This chapter provides the following information about using the REFORMAT utility:

14.1 Running the REFORMAT Utility

On OpenVMS, you can define REFORMAT as a foreign command as follows:


$ REFORMAT :== "$SYS$SYSTEM:REFORMAT.EXE"

Then you would type the following command:


$  reformat  <>

On Tru64 UNIX, type the following:


%  reformat  <>
The following example shows a typical session using the REFORMAT Utility (the command line prompt is omitted):


REFORMAT -
REFORMAT - Enter Y for ANSI-to-terminal conversion, or
REFORMAT - Enter N (default) for terminal-to-ANSI conversion.
REFORMAT - Enter ^Z to exit.
REFORMAT - ANSI-to-terminal format conversion mode [ Y / [N] ]?

n
REFORMAT - Terminal-to-ANSI format selected
REFORMAT - Terminal-format input file spec :

myprog.cob
REFORMAT -     ANSI-format output file spec:

myprog2.cob
REFORMAT - Columns 73 to 80:
REFORMAT -      42 Terminal source code records converted to ANSI format
REFORMAT -
REFORMAT - Enter Y for ANSI-to-terminal conversion, or
REFORMAT - Enter N (default) for terminal-to-ANSI conversion.
REFORMAT - Enter ^Z to exit.
REFORMAT - ANSI-to-terminal format conversion mode [ Y / [N] ]?

^Z
REFORMAT -

In the preceding example, the following events took place:

  1. The user typed n in response to the first prompt, indicating a desire to convert a file from Terminal to ANSI format (the user could have simply pressed Return, as the default direction is Terminal-to-ANSI).
  2. The user typed myprog.cob in response to the prompt for an input file spec.
  3. The user typed myprog2.cob in response to the prompt for an output file spec.
  4. The program next prompted for an identification entry in columns 73 to 80, and the user simply pressed Return.
  5. Ending that dialog, the program reported that it converted 42 source code records.
  6. The program then repeated the original prompts, to which the user replied with a Ctrl/Z.

The Ctrl/Z ends this reformatting session.

14.2 ANSI-to-Terminal Format Conversion

REFORMAT converts each ANSI format source line to terminal format by:

  • Removing the 6-character sequence field in the first six character positions of the ANSI format line
  • Moving any continuation symbol (-) or comment symbols (* or /) from character position 7 into character position 1
  • Moving the conditional compilation character (if any) from the ANSI format indicator area into character position 2 and inserting a backslash character (\) into character position 1 of the terminal format line
  • Removing the identification entry field in character positions 73 to 80 of the ANSI format line
  • Removing insignificant trailing spaces before character position 73 of the ANSI format line
  • Replacing every form-feed record with a line containing a slash (/) in character position 1
  • Placing the converted code in positions 1 to the end of the line, thereby creating a terminal format line

Note

When you convert programs that contain continued nonnumeric literals you should examine those literals to see if they require any changes. (This should occur only when going from ANSI format to terminal format.)

14.3 Terminal-to-ANSI Format Conversion

REFORMAT converts each terminal format source line to ANSI format by:

  • Placing a 6-character line number (000010) in the first six character positions of the first line and increasing it by 000010 for each subsequent line.
  • Moving any continuation symbol (-), or the comment symbols (* or /) from character position 1 into character position 7.
  • Removing the backslash character (\), if any, from character position 1 in terminal format and moving the following conditional compilation character into character position 7 of the ANSI format line.
  • Replacing horizontal tabs with space characters at every eighth character position, starting at character position 5 and ending at the end of the line.
  • Moving spaces into remaining character positions after the last character of code and before character position 73.
  • Expanding a terminal line with more than 65 characters into two or more ANSI format lines and right-justifying these lines at character position 72.
  • Placing either identification characters (if supplied at program initialization) or spaces into character positions 73 to 80.
  • Right-justifying (at position 72) the first line of a continued nonnumeric literal. This ensures that the literal remains the same length as it was in the default format.
  • Replacing every form-feed record with a line containing a slash (/) in position 7 and space characters in positions 8 to 72.
  • Placing the converted code in character positions 8 to 72, thereby creating one or more ANSI format lines.

Note that it is possible to construct a terminal format line that converts to an invalid ANSI formatted line. Consider the case of a conditional compilation line with a long nonnumeric literal:


\A   01   ART   PIC X(80)  VALUE "A ... A".

This statement cannot be reformatted to a valid ANSI statement. The literal is 80 characters long, which indicates that the literal must be continued on the next line by placing a continuation symbol (-) in the indicator area. The line is also a conditional compilation line, which indicates that the A is to be placed in the indicator area. Clearly both characters cannot be placed in the indicator area. HP COBOL continues the conditional compilation line by placing the A in the indicator area. This means the program remains valid if conditionals are not used in the compilation because the lines become comment lines. If conditionals are used, you must locate and correct these invalid lines. The reformat program is a text processor and does not perform the level of checking required by lines such as these. You detect this error during a compile operation.

14.4 REFORMAT Error Messages

If any of your responses to the prompts are incorrect, REFORMAT displays error messages. It replaces the parentheses and the parenthetical text with the appropriate format type you specified.


REFORMAT - Error in opening (ANSI or terminal) format input file:
REFORMAT -        (ANSI or terminal) format input file spec:

The system could not open the input file; either the file is not on the specified device or you typed the file name incorrectly.

The default device is SYS$DISK on OpenVMS systems; it is stdin on Tru64 UNIX systems.

To continue processing, examine the input file specification and type a corrected version. To process another file, type a new input file specification. To end execution, type Ctrl/Z (on OpenVMS systems) or CTRL/D (on Tru64 UNIX systems).


REFORMAT - Error in opening (ANSI or terminal) format output file:
REFORMAT -   (ANSI or terminal) format output file spec:

The system could not open the output file. An incorrectly typed file specification usually causes this error.

The default device is SYS$DISK on OpenVMS systems; it is ./ on Tru64 UNIX systems.

To continue, examine the output file specification and type a corrected version. To end execution, type Ctrl/Z (on OpenVMS systems) or CTRL/D (on Tru64 UNIX systems).


REFORMAT - (ANSI or terminal) format input file is empty
REFORMAT -     (ANSI or terminal) format input file spec:

The system opened an empty input file. To continue, type a new input file specification. To end execution, type Ctrl/Z (on OpenVMS systems) or CTRL/D (on Tru64 UNIX systems).


Previous Next Contents Index