• Keine Ergebnisse gefunden

AfODULE3-7 Changing File Organization

Im Dokument APPLICATION PROGRAMMER HANDBOOK (Seite 69-73)

CP-6 file structures include keyed, indexed, consecutive, relative, random, IDS, and unit record. See the CP-6 Programmer Reference, CE40, for a detailed descript ion of these types. of fi les.

Perhaps the most commonly used types of files are keyed, consecutive, and indexed. Let's consider some examples in which it may be necessary for you to change the organization from one file type to another.

SETUP: You want to copy a file of error messages which exist in account :CENTRAL in a file named COBRA, and edit your copy. You decide to use EDIT.

!EDIT

EDIT B03 HERE

*E COBRA.:CENTRAL

*TY

!EDIT

File COBRA.:CENTRAL is not a keyed file - limited updating - RP mode set

EDIT has informed you that COBRA is not a keyed file. You request to see the file at your terminal:

1 XU1 is of type character. Illegal in a VIRTUAL statement.

2 XU1 is not an array or common block.

3 Common block XU1 exceeds previous allocation 4 Equivalenced scalar XU1. Too many subscripts.

EDIT has provided abbreviated line numbers because this is not a keyed file. You decide to make a keyed copy for your own account:

EDIT B03 HERE

*COPY COBRA.:CENTRAL OVER MYFILE

!PCL

PCL B03 here

By using the EDIT COpy command, you have asked EDIT to make a keyed copy of file COBRA. By default, your copy will start with line number 1.000, incremented by 1.

You can also make a keyed copy of a consecutive file using the PCL processor:

<COPY COBRA.:CENTRAL ON MYFILE (ORG=KEYED)

You have copied file COBRA on to your own file "MYFILE" as an EDIT keyed file. Or, if you you want to designate the beginning line number:

<COPY COBRA.:CENTRAL ON MYFILE (LN=4)

CESS-01

You have specified that the input file COBRA is to be copied as an EDIT keyed file with beginning line number 4.000, i.e.

MODULE 3-7

Changing File Organization

Page 47

4.000 %U1 is of type character. Illegal in a VIRTUAL statement.

5.000 %U1 is not an array or common block.

6.000 Common block XU1 exceeds previous allocation.

7.000 Equivalenced scalar XU1. Too many subscripts.

The options specified in parentheses in the above PCl commands are PCl output options. These options enable you to change file organization from one type to another. If you want to change file organization to indexed, you must use both the KEYlENGTH option to specify the number of characters for the key, and the KEYX option to specify the character position, as well as ORG = INDEXED.

When you build a file using the BUILD command, it will be an EDIT keyed file.

Suppose you want to build a consecutive file. You could build a keyed file and then use the PCl copy command to change the file organization to

consecutive, using either the NlN output option, or the ORG=CONSECUTIVE output option. You can also use ihe COPY ME command to build a consecutive file directly. See the module entitled Creating New Files (CESS) for an example of using the COPY ME command.

The principal benefit to the user of consecutive files over keyed files is a reduction in the amount of space required for the file, and a consequent

reduction in the time required to traverse the file. So, for very large files which will be used in a sequential manner only, the consecutive file has an advantage.

The type of file organization you select will affect the results you get when using the PCl COPY command. Suppose you have two files, ALTA and DENA.

<COpy ALTA INTO DENA

If the files are not keyed, the records in ALTA are appended at the end of file DENA.

If, however, the files are keyed, the records in ALTA are "woven" into

destination file DENA (perhaps replacing existing records). All keyed files always look like they have been sorted by keys.

CESS-01 MODULE 3-7

Changing File Organization

Page 48

AfODULE3-B Changing FII. Ace ••• Attrlbut ••

What is file access? In the CP-6 system, the term fid is used as a name to refer to both files on disk or tape, and to devices such as terminals and printers. File access is access to a fid.

It is possible for you to specify the type of file access available to other users for disk or tape files in your account. This may be done by:

• Specifying SHARE and FUN attributes through the IBEX SET command

• Establishing access to users holding specified accounts, also by means of the SET command (ACCESS SET option).

• Using a PCL command to specify the desired PCL output option.

Let's look at some examples of each of the above.

!SET MSSI MYFILE,SHARE=ALL

This command assigns MSSI DCB to disk file MYFILE, which can be opened by all qualified users while you have it open.

!SET MSSI MYFILE,SHARE=IN

specifies that qualified users can open MYFILE for input only (while you have it open).

!SET MSSI MYFILE,SHARE=NONE

specifies that no sharing users can open the file while you have it open.

These SET command options remain in effect for the duration of that job or session, unless reset by the RESET command. You can, for example, start a job by allowing input from other users, and then use RESET to change to

SHARE=NONE.

The SET command FUN option specifies whether an existing file is to be read or updated, or whether a new file is to be created.

!SET MSSI MYFILE,FUN=IN

The above means that MYFILE can only be read; no modification can be made to the file.

!SET MSSI MYFILE, FUN=UPDATE

means that MYFILE can both be read and modified.

!SET MSSI MYFILE,FUN=CREATE

means that a new file is to be created.

Now let's look at the SET command ACCESS option, which allows you to specify those accounts which may access your file:

CE55-01 MODULE 3-8 Page 49

Changing File Access Attributes

!SET M$SI MYFllE, ACCESS=(All,REAO)

means that any and all accounts may access MYFllE. You may also indicate a singLe account, or a number of

accounts (caLLed an accountList), or a range of accounts specified by the use of wiLdcard characters, i.e.,

!SET M$SI MYFllE, ACCESS=(477?,REAO)

means that any account beginning with 477 has access to MYFILE.

PCl output options may aLso be used to Limit access to a fide The PCl output options we are concerned with are ACCESS, ACSVEHIClES, READ, and WRITE.

ACCESS Specifies 'which accounts are permitted access to the fiLe, and what controL appLies to those accounts.

ACSVEHIClES Specifies which processors are permitted access to the fiLe, and which controLs apply to those processors. A processor is defined as any run unit with optional account specification.

If the account is not specified, :SYS is assumed (BASIC, EDIT, etc.)

READ Specifies which accounts can read records from a file.

WRITE Specifies which accounts can write records to a file.

Examples:

!PCl

<MOD MYFIlE TO (REAO=SAM)

means that MYFIlE may be read only by account SAM and the creating account.

<MOD MYFIlE TO (ACC=(?,NOlIST»

will make the file MYFIlE visible only to the creating account.

SETUP: You want a data file to be given READ and WRITE access, but want to prohibit the use of PCl to copy all or portions of the file.

SOLUTION: You use the following SET options:

!SET MYFIlE , ACCESS=(accountlist1,READ,EXEC),;

ACCESS=(accountlist2,WRITE,UPOATE,DElR,EXEC),;

ACSVEH=(PCl)

where acountlist1 is the READ accountlist, and accountlist2 is the WRITE accountlist. The use of EXEC implements the ACSVEH option, which is used to specify a processor or processors, (i.e., PCl), and the access permissions to be granted to them. In this case, PCl has been specified with no permissions.

Therefore, the use of the PCl processor by the accounts specified is prohibited for the designated file.

Additional information concerning PCl file access output options and SET options is available from the HELP facility.

CESS-01 MODULE 3-8 Page 50

Changing File Access Attributes

AfODULE3-8

Im Dokument APPLICATION PROGRAMMER HANDBOOK (Seite 69-73)