Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Pascal/HP-UX Programmer's Guide > Chapter 3 Input/Output

Associate Procedure

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

The predefined procedure associate associates a logical file with an open physical file, and puts the current position index at the first component.

Syntax

associate (logical_file, file_number, open_options)

Parameters

Title not available (Associate Procedure )

logical_file

The name of the logical file.

file_number

The file number of the open physical file. The physical file must have been opened with a direct call to an operating system routine or a non-Pascal routine. You cannot call the associate procedure with the file number of a closed file or a file that was opened with the Pascal procedure append, associate, open, reset, or rewrite.

open_options

One of the following options. It must be a string literal:

Title not available (Associate Procedure )

'READ'

Associate with sequential access file with read-only access.

'WRITE'

Associate with sequential access file with write-only access.

'READ,DIRECT'

Associate with direct access file with read-only access.

'WRITE,DIRECT'

Associate with direct access file with write-only access.

'READ,WRITE,DIRECT'

Associate with direct access file with read-write access.

'DIRECT'

Associate with direct access file with read-write access (same as 'READ, WRITE, DIRECT' ).

'NOREWIND'

Associates with a file without changing the current file position.

You must specify one of the above strings for open_options. The system-dependent open options listed in Appendix A “MPE/iX Dependencies ” (for MPE/iX) and Appendix B “HP-UX Dependencies ” (for HP-UX) apply to the file-opening procedures append, open, reset, and rewrite. Pascal ignores them when they are used with associate.

You cannot specify read access if the physical file is not open for read access, or to specify write access if it is not open for write access. If you associate a logical file with an empty physical file, for read access, the next read causes an error.

Table 3-3 “Characteristics of Associate Procedure” summarizes the characteristics of the predefined procedure associate.

Table 3-3 Characteristics of Associate Procedure

Type of File That it Can Open

Any.

State in Which it Opens File

Specified in open_options.

Manner in Which File Can Be Accessed

Either — Defined by characteristics of physical file.

Purpose for Which it Opens File

Input, output or both.

Where it Puts Current Position Index

Before first component.

Value of eof for File *

False unless opened for write, in which case eof returns true despite possible old data after the current component.

Erases Old file Contents

No.

File Buffer Variables *

First component for a textfile that is open for reading; undefined otherwise.

 

Title not available (Associate Procedure )

For a nonempty file. For an empty file, every file-opening procedure puts the current position index before the [nonexistent] first component, eof returns true, and the file buffer variable is undefined.

If the physical file is not empty, the first reference to its file buffer variable loads its file buffer with its first component. If the physical file is empty, the first reference to its file buffer variable causes an error.

Figure 3-5 “Effect of Associate Procedure on Open File” illustrates the effect of the associate procedure on the open file whose file number is file_num:

Condition of file:

Figure 3-4 Associate Procedure Example

Associate Procedure Example

After associate(examp_file,file_num,'READ'), the file is open in the read-only state and looks like this:

Figure 3-5 Effect of Associate Procedure on Open File

Effect of Associate Procedure on Open File

Now examp_file is open in the read-only state.

Figure 3-6 Effect of Associate Procedure on Open File

Effect of Associate Procedure on Open File

Example 1

This example applies to HP Pascal on the MPE/iX operating system only. For a description of the MPE/iX intrinsic FOPEN, refer to the MPE/iX Intrinsics Reference Manual.

List 1 Here.

Example 2

This example applies to HP Pascal on the HP-UX operating system only. For descriptions of the HP-UX routines tmpnam and open, refer to the HP-UX Reference manual.

List 2 Here.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.