Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 15
Altering Unstructured-File Attributes
Altering Unstructured-File Attributes
As for any other file type, file attributes for an unstructured file are normally set when
the file is created. These attributes include, for example, an application-supplied file
code or an expiration time before which the file cannot be purged. You can, however,
change some attributes of an existing file by calling the FILE_ALTERLIST_ procedure.
The following example changes the file code for the file named MYFILE and sets TMF
auditing for the file. Here, a change of file code is requested by the item-list
parameter (code 42), and a change in TMF audit status by item-list code 66. The
new values are provided in the first and second items listed in the values parameter.
FILENAME ':=' "MYFILE";
NAME^LENGTH := 6;
ITEM^LIST ':=' [42,66];
NUMBER^OF^ITEMS := 2;
VALUES ':=' [125,1];
VALUES^LENGTH := 4;
ERROR := FILE_ALTERLIST_(FILENAME:NAME^LENGTH,
ITEM^LIST,
NUMBER^OF^ITEMS,
VALUES,
VALUES^LENGTH);
An alternate way of altering file attributes is to use the FUP ALTER command. This
command allows you to set attributes interactively through the TACL program instead
of programmatically using the FILE_ALTERLIST_ procedure.
See the Guardian Procedure Calls Reference Manual for complete details of every file
attribute that you can change with the FILE_ALTERLIST_ procedure. See the
Guardian Procedure Calls Reference Manual for details of the FUP ALTER command.
Using Relative Files
This subsection discusses how to create and access relative files. It outlines the
common file-system operations: create, open, position, read and write, lock, rename,
close, purge, and alter attributes. The discussion includes a complete program that
makes use of the major features of relative files, including the ability to randomly
access a file using the record number.
The discussion here is limited to primary-key access, that is, access by record number.
Relative files can also be accessed by alternate keys; for details, refer to Using
Alternate Keys later in this section.
Note. When you call FILE_ALTERLIST_ for a given file, the file must not be open otherwise
the procedure returns an error.