PreviousCOBOL Source Information EditorNext"

Chapter 6: Directory Facility

The File Specification and Directory Facility (referred to in this manual simply as the Directory Facility) enables you to select files for processing within Object COBOL.

6.1 Overview

There are many places in the Object COBOL Development Environment where you are required to enter a filename. At each of these places, a similar file specification menu is displayed which includes the option to display a directory listing and select a file from within it by simply pointing with the cursor. The features which are common to all such menus are described in this chapter.

6.2 Operation

This section describes the menus of the Directory Facility and its two main functions: how to enter a filename efficiently, and how to obtain and tailor a directory listing.

UNIX :
Throughout this chapter, references to pressing keys such as function or status keys imply the logical pressing and releasing of these keys rather than the physical keystrokes. Some keys are symbolic key names which may not be present on your keyboard. See the appendix UNIX Key Usage Chart for details on the actual keystrokes required to achieve the documented function.

6.2.1 Accessing the Directory Facility

Whenever you have to load or save a file when you are using an Object COBOL component, you will do so by accessing the Directory Facility. The function you use to enter the Directory Facility may vary, but once you have entered it, a common menu, the File Specification menu, is displayed. The menu may have additional variable functions depending on which component you have invoked it from.

6.2.2 File Specification Menu Description

The general appearance of the File Specification menu is as shown in Figure 6-1.



Figure 6-1: File Specification Menu

If you have been working with a particular file during a session, its name will appear as the default at the File prompt; otherwise, the current drive and/or path are displayed.

The bottom line of the screen is used for temporary messages, which clear either when a key is pressed or after a short time has elapsed.

There are three common functions on the main menu: Help, Directory and Escape. Other functions shown on this menu depend upon the component you are using and are not described here; they will be described with that component. The Help function will also describe those options, and will again depend upon which component you are using.

In addition, there is a Control menu of functions, which is displayed when you press the Ctrl key. This menu is shown in Figure 6-2.



Figure 6-2: Control Menu

The Control menu also displays the File prompt; you can select and change the current default directory from this menu as well as from the main menu.

6.2.3 The File Prompt

You can change the displayed drive (for DOS, Windows or OS/2 systems), path and filename by typing over the displayed name. On initial display of this prompt, the cursor will be positioned at the start of the filename area within the file specification.

6.2.3.1 Special Keys

In addition to the keys that you would normally expect to use when typing in a filename, some special key actions are defined to reduce the number of keystrokes you have to make.

UNIX:
Because UNIX terminals vary widely, the keys documented in this chapter may not be available on your keyboard. See the appendix UNIX Key Usage Chart for details on the actual keystrokes required to achieve the documented functionality.

In all environments, the following keys are defined:

Key
Function
. (period) If entered in over-strike mode (Insert is off) all characters up to the next ".", "\" (for DOS, Windows and OS/2) or "/" (for UNIX systems) characters are erased.
Space Erases all characters up to the next ".", "\" (for DOS, Windows and OS/2) or "/" (for UNIX systems) characters.

DOS, Windows and OS/2:
On DOS, Windows and OS/2 the following keys are also defined:

Key
Function
: (colon) If preceded by a single alphabetic character this replaces the current drive specification.
\ (backslash) If entered after an existing "\", this character replaces the current path specification by the root directory; otherwise (if Insert is off), it erases characters up to the next "\".

If you wish to specify a file using the Universal Naming Convention (UNC), you can do so by entering two consecutive backslash characters plus the path-name, base-name, and extension, or file mask.

Entering a third consecutive backslash reverts to the root directory.

UNIX:
On UNIX the following key is also defined:

Key
Function
/ (slash) If entered after an existing "/", this character replaces the current path specification by the root directory; otherwise (if Insert is off), it erases characters up to the next "/".

You can also use the following cursor keys to move through the constituent fields of the file specification:

Key
Function
Tab Moves the cursor right one field.
Backtab Moves the cursor left one field.
<right-arrow> Moves the cursor right one character position.
<left-arrow> Moves the cursor left one character position.
Home Moves the cursor to the start of the current field then to the start of the file specification.
End Moves the cursor to the end of the current field then to the end of the file specification.
Ctrl+Home Erases all characters preceding the current cursor position.
Ctrl+End Erases all characters from the current cursor position onward.

You can specify the filename of a file which is a constituent member of a library file supplied with this COBOL system. Simply include the name of the library file as though it were the last part of the path-name.

Example

DOS, Windows and OS/2:
For example, to access myfile.cbl from within c:\path\mylib.lbr on DOS, Windows and OS/2, you could specify:

c:\path\mylib.lbr\myfile.cbl

UNIX:
To access myfile.cbl from within /path/mydir/mylib.lbr on UNIX, you could specify:

path/mydir/mylib.lbr/myfile.cbl

Once you have keyed in your File specification, the two main functions you can perform are the Enter function and the Directory function, described in the following sections.

6.2.3.2 Enter Function

If the file specification at the File prompt contains wild-cards, or it has an extension with no associated name, Enter invokes the Directory function (described below); otherwise, it executes the function that caused display of the file prompt (for example, load-file or save-file).

6.2.3.3 Directory Function

This function lists files for the drive (DOS, Windows and OS/2 only) and path specified by the File prompt. If a file extension is specified, all files with that extension are listed; otherwise, extensions appropriate to the current function are listed.

For example, for the Edit Load-file menu the defaults are .cbl, .CBL, .cpy, .CPY, .cob, .COB, and files with no extension. You can also include the wild-card characters "?" and "*", in which case filename as well as extension is used as one of the directory search criteria. If a filename is selected from the directory (by using the Enter function), that filename replaces the one currently displayed at the File prompt.

If you just specify a path-name with no filename following, you should include a terminating backslash (\) in the Professional COBOL Environment or a terminating slash (/) in the Object COBOL Development Environment.

You can include a library name in your path-name if you want to list the members of a library.

Example

DOS, Windows and OS/2:
For example, if you want to see the members of the library mylib.lbr, on DOS, Windows and OS/2 you could specify:

c:\path\mylib.lbr\*

UNIX:
On UNIX, you would specify:

/path/mylib.lbr/*

6.2.4 List Files/Directories Menu

The directory function lists files for the drive and/or path specified in the file prompt as described above.

Once you select the Directory function, you have access to another series of functions that enable you to change the display order of files within a directory, change and list directories, delete files and, for DOS, Windows and OS/2 systems, change the current disk drive designation. These functions are presented on the List Files menu (which incorporates a Control menu).

Once you are in this menu, F3=list-dirs gives you access to a similar menu called the List Directories menu, which provides additional functions for manipulating directories.

The top line of the menu identifies the drive and/or path of the directory listed. The four lines shown in Figure 6-3 appear at the bottom of your screen.



Figure 6-3: List Files Menu

The first line is the information line. It displays the current default drive and/or path, the current setting of certain menu options, and the Ins, Caps, Num, and Scroll indicators.


Note: Num Lock is not recognized by UNIX.


To select a file from the displayed directory, position the cursor on the desired filename using the cursor keys (described below). If the cursor is positioned on a Micro Focus library name, the F2 option changes to F2=list-lbr-catalog. Press Enter. This returns you to the File Specification menu and enters the specified filename at the filename prompt.

DOS, Windows and OS/2:
The last line on the screen (the message line) displays statistics (in bytes) relating to total capacity, available space and space used by the files.

Some of the functions are presented on a Control menu - to see this menu, press the Ctrl key (see Figure 6-4).



Figure 6-4: List Files Control Menu

6.2.4.1 Cursor Movement Keys

In addition to the cursor movement keys available as menu options, you can use the following keyboard keys and combinations to move through the directory listing.

UNIX:
Because UNIX terminals vary widely, the keys documented in this chapter may not be available on your keyboard. See the appendix UNIX Key Usage Chart for details on the actual keystrokes required to achieve the documented functionality.

Key
Function
Page-Up Moves the cursor to the top of the previous screen of the listing.
Page-Down Moves the cursor to the top of the next screen of the listing.
Home Moves the cursor to the first file/directory listed on the current screen.
End Moves the cursor to the last file/directory listed on the current screen.
Ctrl+Home Moves the cursor to the first file/directory listed.
Ctrl+End Moves the cursor to the last file/directory listed.
<up-arrow> Moves the cursor up one line.
<down-arrow> Moves the cursor down one line.

6.3 Functions

This section describes all the functions available on the menus. The functions in this facility fall naturally into two groups:

File Specification functions are available from the Main menu (or the File Specification menu) and its Control menu. Directory functions are available (after you have entered the Directory function) from the List Files (or List Directories) menu.

6.3.1 File Specification Functions

These functions are available from the File Specification menu.

Browse File

brs displays the contents of a file. You must have a complete filename specified at the File prompt for this function to operate. You can scroll down the file but not up. The Browse menu lets you use four keys:

Key
Function
<down-arrow> Scrolls the text up one line (moves the view down one line).
Enter Same as <down-arrow>.
Page-Down Scrolls the text up one page minus one line (moves the view down one page minus one line).
Escape Returns to the invoking menu.

Call Library

call-lbr loads the library catalogue specified by the library name currently displayed at the file prompt.


Note: This function is not available under UNIX.


Cancel Library

cancl-lbr unloads the library catalogue specified by the library name currently displayed at the file prompt.


Note: This function is not available under UNIX.


Default Dir

Show

This function displays the current default directory and drive on the bottom line of the screen.

Use

This function replaces the displayed drive and path by the current default.

Set

This function changes the current default directory and drive to the path-name specified at the file prompt. If concurrency is in use, a warning is issued and a confirmation (Y/N prompt) required before continuing.

Delete File

This function deletes the file(s) specified by the File prompt. Wild-card characters can be used to specify multiple files. You are prompted to confirm the deletion of each individual file which matches the file specification. If either filename or extension is unspecified, "*" is assumed. However, if the filename is terminated by a period with no following extension, this is assumed to mean an explicit extension of spaces.


Warning: You must not delete or rename a file that is loaded into the COBOL Editor: this includes its backup files (.bak) and any temporary files (.$$?). The COBOL Editor may not function correctly if any of its active files are renamed or deleted.


Directory

This function displays a list of files according to the contents of the File prompt and the List Files menu.

Rename

This renames a file. When a filename is entered at the file prompt, this function displays a second file prompt containing the same filename for editing. You can type a new name or edit the original one. The Rename menu has the options Help, Directory, and Escape.

Press Enter or repeat the rename function to rename the file with the new name.

You can move a file from one directory to another using the rename function. Edit the new filename with a different path-name for the new directory. When you complete the function, the file will be moved to the new directory.

Both the Delete and Rename functions can be used on library members. When renaming a library member, the new library name must not be longer than the original library name.

6.3.2 Directory Functions

These functions are available on the List Files menu and its Control menu and on the List Directories menu.

Browse

brs displays the contents of the currently highlighted file.

You can scroll down the file but not up. The Browse menu lets you use four keys:

Key
Function
<down-arrow> Scrolls the text up one line (moves the view down one line).
Enter Same as <down-arrow>
Page-Down Scrolls the text up one page minus one line (moves the view down one page minus one line).
Escape Returns to the invoking menu.

Delete

This function deletes the file at the current cursor position. You are prompted to confirm the deletion of the file.


Warning: You must not delete a file that is loaded into the COBOL Editor: this includes its backup files (.bak) and any temporary files (.$$?). The COBOL Editor may not function correctly if any of its active files are renamed or deleted.


Drive

DOS, Windows and OS/2:
This function lists the files or directories on the specified DOS, Windows or OS/2 drive. The system prompts you to enter the new drive letter. Make sure a disk is present in the relevant drive. An error message is displayed if no disk is present in the drive.


Note: This function is not available under UNIX.


Escape

Escape exits from the List Files menu.

List Asc/Desc

This is a toggle that lists the files in ascending or descending order according to the selected sort option (name, time, size, extension or unsorted). The state of this option appears on the information line.

List Directories

list-dirs displays the List Directories menu and a listing of subdirectories.

List Files

This function redisplays the list of files in this directory. This option appears if the selected filename has any extension except .lbr.

List-catalogue appears if the selected filename is a library (extension .lbr) and displays a list of the files in the library catalogue.

For more information on libraries, see your Object COBOL User Guide.

Select Dir (Enter)

From the List Directories menu, Select-dir, or pressing Enter returns to the File Specification menu and causes the highlighted directory to appear at the File prompt.

Set Default Dir

This function changes the current default drive and directory to the highlighted directory.

Select File (Enter)

Pressing Enter returns to the File Specification menu and causes the highlighted filename to appear at the file prompt.

There is one place in the Object COBOL menu system where the behavior of this option is different. In the directory invoked from the Library Load-file menu, the select-file option immediately loads the selected file and the List-files menu remains active.

Sort Ext

This function sorts the listing in alphabetical order by extension. For entries with the same extension, it sorts within that list alphabetically by filename. The state of this option appears on the information line.

Sort Name

sort-name sorts the listing in alphabetical order. The state of this option appears on the information line.

Sort Size

sort-size sorts the listing in size order. The state of this option appears on the information line.

Sort Time

sort-time sorts the listing in chronological order. The state of this option appears on the information line.

Unsort

This displays the listing in an unsorted order. The state of this option appears on the information line.

6.4 The d Program

This program is a specific implementation of the Name program, which enables you to invoke the Directory functions using a simple command.


Note: Where you specify the command line depends upon the operating system you are running in. For example, in Windows and OS/2, if you have created a group for COBOL, then you double click on the appropriate program icon to invoke the component. Full details on the alternative methods of invoking system tools in your environment are provided in the chapter Introduction.


To invoke the directory facility from the operating system command line, enter:

[trigger] d [filespec]

where the parameters are::

trigger If specified, is an executable file to run the component in one of the available development environments, in this case the Run-time Environment:

DOS and OS/2
Windows
UNIX
run runw cobrun
filespec Similar to that specified for the operating system dir command, except that d allows multiple file extensions to be specified, separated by commas. If filespec is omitted, *.* is assumed for DOS, Windows and OS/2 and * is assumed for UNIX systems.

DOS, Windows and OS/2:
The detailed format of filespec on DOS, Windows and OS/2 is as follows:

[drive]:[path-name][filename][.extension[,extension]...]

UNIX:
The detailed format of filespec on UNIX is as follows:

[path-name][filename][.extension[,extension]...]

You can also use the d program to list the contents of a library file. Enter:

DOS, Windows and OS/2: 
d lbrname.lbr\
UNIX: 
d lbrname.lbr/

If lbrname.lbr is in the current directory, d displays the library catalog.


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousCOBOL Source Information EditorNext"