Format Editor

Use the Format Editor to interactively edit Fortran FORMAT statements and I/O edit descriptor lists embedded in strings.

You can start the Format editor from within Developer Studio or from the command line.

The editor shows you the FORMAT or descriptor code and a sample of the resulting data layout in a window that works like a dialog box. You can edit either the code or the display, and the Format Editor changes the other to match. After you view the result, you can iterate back and forth until you get the data display you want. When you finish editing the FORMAT statement or edit descriptors, the Format Editor writes a new copy of the source file containing the format syntax you have developed.

Note   With edit descriptors embedded in strings, anything on the line following the formatting, such as an I/O list, will be lost when the Format Editor writes the new formatting, so you should save or move the rest of the line you want to keep.

The Format Editor assumes that files with the extension .F90 are free form source, and assumes files with any other extension, including .FOR, are fixed form source. If you are not editing a file with the .F90 extension and you attempt to edit a FORMAT statement that begins before column 7, the Format Editor issues an error.

Format Editor Help contains the following topics:

•	Opening the Format Editor

•	Inserting a New FORMAT Statement

•	Inserting a New I/O Edit Descriptor

•	Setting a Value for the Field Descriptor

•	Running the Format Editor from the Command Line

•	Format Editor Dialog Box Controls

•	Keyboard Shortcuts

•	Common Problems with the Format Editor


Opening the Format Editor

To open the Format Editor

1	Open a Fortan source file that contains a FORMAT statement or an I/O edit descriptor.

2	Position the cursor on the first line of the FORMAT statement or on the line containing the edit descriptor.

3	From the Edit menu, choose Format Editor (or click the Format editor icon on the Fortran toolbar).

The Format Editor dialog box opens.

When you open the Format Editor in a line with an edit descriptor, the editor attempts to parse the first opening quote that precedes the cursor position. When you open the editor in a line containing a FORMAT statement, the editor attempts to parse the edit descriptors in the statement. If the editor is successful, it displays the edit descriptors in the upper-left box and a sample data display in the lower text box. If the editor cannot parse the descriptor string or FORMAT statement, you will get a parse error message. The Format Editor replaces tabs within both edit descriptors and FORMAT statements with an equivalent number of spaces.


Inserting a New FORMAT Statement

To insert a new FORMAT statement

1	Position the cursor on a blank line.

2	From the Edit menu, choose Format Editor.

The Format Editor appears.

3	Choose the New Field button.

4	Select the descriptor type you want.

5	Choose the Insert Before Current Field button to insert the new field before the current descriptor, or choose the Insert After Current Field button to insert the new field after the current descriptor.

The text "label FORMAT" is inserted into the source file.

6	Edit the FORMAT statement with the Microsoft Developer Studio text editor.


Inserting a New I/O Edit Descriptor

To insert a new I/O edit descriptor into an existing descriptor or FORMAT statement

1	Position the cursor on the existing descriptor or FORMAT statement.

2	From the Edit menu, choose Format Editor.

The Format Editor appears.

3	Choose the New Field button.

4	Select the descriptor type you want.

5	Choose the Insert Before Current Field button to insert the new field before the current descriptor, or choose the Insert After Current Field button to insert the new field after the current descriptor.

A default value is used for the descriptor you choose (for example, I5).

6	To change the descriptor value, select the value and type in the new value. For example, select 5 from I5 and type 8 to get an I8 format.


Format Editor Dialog Box Controls

Format Editor

Control	Description
Format statement display area	Edit either the format descriptor or the data value and the other will change correspondingly. Repeatable edit discriptors and most other descriptors are supported. Note that all lines of a formatted sample result are shown in a single line.
New Field	Displays the New Field dialog box.
Remove Field	Deletes the edit descriptor that the cursor is currently in.
Change Value	Displays the Change Value dialog box.
OK	Saves your changes to the file and exits.
Cancel	Exits the Format Editor without saving.
Help	Displays this help file.
New Field

Control	Description
Descriptor Type	Lists the descriptor types available.
Insert Before Current Field	Inserts the new field before the current field.
Insert After Current Field	Inserts the new field after the current field.
Change Value

Control	Description
Custom Value	Type a custom value.
Set to Default	Sets the custom value as the default value.


Keyboard Shortcuts

To	Press
Move between format descriptor box (upper) and the sample data display box (lower)	UP ARROW  DOWN ARROW CTRL+DOWN ARROW CTRL+UP ARROW
Move to the adjacent field	CTRL+LEFT ARROW CTRL+RIGHT ARROW
Move within the field	LEFT ARROW RIGHT ARROW
Move forward in order from the format descriptor box, the data display box, New Field button, Remove Field button, Change Value button, and the OK, Cancel and Help buttons	TAB
Move backward among the options	SHIFT+TAB


Descriptor Type

Select one of the following option buttons from the Descriptor Type group to insert a valid editor descriptor.

Option Button	Description
Character String	Outputs literal ASCII text. The text must be enclosed in single quotation marks. Use two adjacent single quotation marks to display a single quotation mark.
Character Variable (A10)	Displays character arrays. The field width defaults to 10. If it is not of the CHARACTER type, it is assumed to have one character per byte.
Logical (L2)	Displays logical type. Outputs are displayed as a literal T with n–1 leading blanks, where n is the width of the field. n defaults to 2.
Integer (I5)	Displays formatted integer output. Numbers are displayed beginning with one and then incremented.
Fixed-point (F7.3)	Displays floating-point data. It displays the data in decimal form.
Scientific Notation (E15.8)	Displays floating-point data. It displays the data in exponential form.
Custom	Specifies any valid Fortran edit descriptor. If an edit descriptor specified is not supported by the Format Editor, the Format Editor displays the following message box: "descriptor" is not a valid descriptor – Insertion aborted.


Setting a Value for the Field Descriptor

You can use the Change Value dialog box to set the value of the data displayed.

To set a value for the field descriptor

1	In the Format Editor, choose Change Value button.

2	In the Custom Value text box, type the new value for the descriptor.

For example, to see what .02 looks like when displayed through the descriptor E15.8, type .02 in the Custom Value box. The text in the lower control changes from 12.12345678E+12 to .20000000-001.

Note   Question marks (?) are displayed in the custom control's lower field whenever you specify an illegal value, and asterisks (*) are displayed in the custom control's lower field when the value specified is out of range.

You can also change the value by typing directly in the sample data display.


Common Problems with the Format Editor

•	You did not position the cursor on a line containing a FORMAT statement or I/O edit descriptor.

•	You did not position the cursor on the first line of a multiline FORMAT statement.

•	The FORMAT statement did not contain a label.


Running the Format Editor from the Command Line

To run the Format Editor from the command line

1	Go to the directory containing FRMTEDIT.EXE (...\COMMON\MSDEVxx\BIN by default).

2	Type FRMTEDIT followed by the source code filename, the line containing the FORMAT statement or edit descriptor, and the column in the line for the parser to begin. For example:

FRMTEDIT test.f90 5 18