HPlogo Asynchronous Serial Communications Programmer's Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 3 Common Device Control Functions

Closing Files

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

The FCLOSE intrinsic is used to terminate access to a file. It applies to files on all devices and frees any resources that were assigned at the time the file was opened. If more than one file is opened against a device, the device itself is not deallocated until an FCLOSE is issued against every file opened on that device by your program. The syntax of the FCLOSE call is as follows:

		        I16V      I16V		        I16V
FCLOSE(filenum,disposition,securitycode);

The filenum parameter contains the file number of the file to be closed. The disposition and securitycode parameters provide facilities for determining file disposition and security levels for files on devices other than terminals and printers. They are not meaningful for asynchronous devices and should be set to 0.

Some of the device settings that may have been altered by FCONTROL (or FDEVICECONTROL) calls issued by your program will be reset to their default settings at FCLOSE. However, this is not true for all device settings that may have been altered. You are responsible for making sure that your program does not adversely affect the way the device will act after your program terminates. It is good programming practice to reset any device characteristics your program alters and to issue an FCLOSE for every file your program opens.

Should your program fail to issue an FCLOSE for a file it has opened, the file system will automatically issue an FCLOSE for that file when the program terminates. When the last file opened against a device is closed, all device characteristics are returned to their configured settings. If there is a session associated with the device, the last file is not closed until the session is terminated.

In Figure 3-10 “Opening a Read Port and a Write Port”, two FCLOSE calls are issued to close ports previously opened for reading and writing to a terminal. Condition codes are checked after each FCLOSE call through the Pascal ccode function, which will return a value of CCE if no errors occur during the call, or of CCL or CCG if errors do occur.

Figure 3-10 Opening a Read Port and a Write Port

Opening a Read Port and a Write Port
Feedback to webmaster