HPlogo Accessing Files Programmer's Guide: HP 3000 MPE/iX Computer Systems > Chapter 14 Getting File Information

Retrieving Specific File Information

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The LISTFILE, LISTFILE...;TEMP and LISTEQ commands return formatted information to your job or session list device. If you need to retrieve specific information about a particular file, and you wish to place it in a variable available either to your CI or to your program, then you'll be interested in the the CI evaluator function and intrinsics described below.

You use:To obtain information about:
[CMD]FINFO,FFILEINFO,FGETINFOCharacteristics of a currently opened file
FLABELINFOCharacteristics of a disk file (opened or not)
FRELATEWhether files are interactive and/or duplicative

[:CMD] FINFO

You can use the FINFO evaluator function interactively to retrieve information about a specified file. FINFO is a function of the expression evaluator, a system procedure used by the IF, WHILE, SETVAR, and CALC commands of the command interpreter.

FINFO has two parameters. The first is the file name of the file about which you wish to obtain information; this is a string, and must be either a fully or partially qualified file name, or a FILE equation backreference. The second parameter is an integer or integer expression that indicates the nature of the information required. The options available are listed in Table 14-2 “FINFO Options”.

Table 14-2 FINFO Options

Specify:FINFO returns:
0True if rhw file exists; False if it does not
1Fully qualified file designator
4Name of file creator
6Date of file creation in format (day,mmm,dd,yyyy)
-6Date of file creation in format (yyyymmdd)
8Date of last modification in format (day,mmm,dd,yyyy)
-8Date of last modification in format (yyyymmdd)
9File code mnemonic or file code as string
-9File code as integer
12File limit
13FOPTIONS (same format as LISTFILE -3)
-13FOPTIONS
14Record size (negative value indicates bytes)
15Block size
19EOF marker location
24Last modified time in format (hh:mm am/pm)
-24Last modified time in format (hhmmss)
33Lockword

 

The example below shows the steps you can use to retrieve the following information about a file:

  • the fully qualified file designator of the specified file

  • the name of the file creator

  • file characteristics, returned in the decimal, hexadecimal, and octal equivalents of the foptions format described in the FOPEN intrinsic description located in the MPE/iX Intrinsics Reference Manual (32650-90028)

  • the file code, returned in decimal, hexadecimal, and octal equivalents

   CALC FINFO ('MYFILE',1)

    MYFILE.MYGROUP.MYACCT

   CALC FINFO ('MYFILE',4)

    SCOTT

   CALC FINFO ('MYFILE',-13)

    1029, $405, %2005

   CALC FINFO ('MYFILE',-9)

    0, $0, %0

FFILEINFO

Use this intrinsic to retrieve information about a specified file. The file can be on any device, but it must be opened by the calling process at the time of the FFILEINFO call. If you wish to return label information from a file that is not opened, use FLABELINFO instead. FFILEINFO has one required parameter, filenum. This is the file number, which is returned when you open a file using FOPEN or HPFOPEN. You can specify the information that you wish to be returned by using up to five itemnum,item pairs. Each itemnum designates a type of information (for example, logical device number, name of file creator, or volume ID), which is then returned in the item parameter. The itemnums can be specified in any order.

Here is an example of an FFILEINFO intrinsic call. The information returned in this example is the same information retrieved in theFINFO example above:

   HPFOPEN(FILENUM,STATUS);

   FORMALDESIGNATOR:= EMPTYARRAY;

   FILECODE:=0;

   FOPTIONS:=0;

   CREATOR:=EMPTYARRAY;

   FFILEINFO(FILENUM,1,FORMALDESIGNATOR,18,CREATOR,2,FOPTIONS,8,FILECODE);

Here is a description of the information returned in the parameters specified in the above FFILEINFO call:

FILENUMA variable of type 16-bit signed integer that returns the file number of the file about which information is requested.
FORMALDESIGNATORA variable of type character array that returns the actual file designator of the file, in the format filename/groupname/accountname.
CREATORA variable of type character array that returns the file creator name.
FOPTIONSA variable of type 16-bit unsigned integer that returns file characteristics in the format described in the FOPEN intrinsic description.
FILECODEA variable of type 16-bit signed integer that returns the file code.

A complete description of the information that you can obtain using FFILEINFO is given in the MPE/iX Intrinsics Reference Manual (32650-90028).

FGETINFO

This intrinsic, which returns some of the same information as FFILEINFO, is an MPE V/E-based intrinsic that is currently supported only for compatibility reasons. When you use a call to FGETINFO, MPE/iX now calls FFILEINFO to retrieve the file information. For this reason, it is advisable for you to call FFILEINFO directly; however, there is no need to rewrite existing programs that use FGETINFO unless there is a performance problem.

Here is an example of an FGETINFO intrinsic call that is the exact equivalent of the FFILEINFO example shown above:

   HPFOPEN(FILENUM,STATUS);

   FORMALDESIGNATOR:= EMPTYARRAY;

   FILECODE:=0;

   FOPTIONS:=0;

   CREATOR:=EMPTYARRAY;

   FGETINFO(FILENUM,FORMALDESIGNATOR,,FOPTIONS,,,,,FILECODE,,,,,,,,,,CREATOR);

A complete description of the information that you can obtain using FGETINFO is given in the MPE/iX Intrinsics Reference Manual (32650-90028).

FLABELINFO

The FLABELINFO intrinsic returns information from the file label of a disk file. The file need not be opened at the time of the intrinsic call. The information returned by this intrinsic is a subset of the information returned by FFILEINFO.

Here is an example of a FLABELINFO intrinsic call that returns the same information as the FFILEINFO and FGETINFO examples shown above:

   FORMALDESIGNATOR:='MYFILE.MYGROUP.MYACCT ';

   MODE:=0;

   FSERRORCODE:=0;

   ITEMNUMS[1]:=13;     {Bytes 1..2 return characteristics }

   ITEMNUMS[2]:=9;      {Bytes 3..4 return file code       }

   ITEMNUMS[3]:=1;      {Bytes 5..12 return file name      }

   ITEMNUMS[4]:=2;      {Bytes 13..20 return group name    }

   ITEMNUMS[5]:=3;      {Bytes 21..28 return account name  }

   ITEMNUMS[6]:=4;      {Bytes 29..36 return creator name  }

   ITEMNUMS[7]:=0;      {Zero indicates end of list        }

   INITIALIZE_ITEMS;    {Procedure initializes ITEMS fields}

   INITIALIZE_ITEMERRORS; {Procedure sets elements to zero }

   FLABELINFO(FORMALDESIGNATOR,MODE,

              FSERRORCODE,ITEMNUMS,ITEMS,ITEMERRORS);

The ITEMS parameter above is a record structure, exactly 36 bytes in length, that can be declared in the following manner:

   TYPE ITEMS_TYPE = RECORD

              FOPTIONS: 0..65565;    {2-byte unsigned integer}

              FILECODE: SHORTINT;    {2-byte signed integer  }

              FILENAME: PACKED ARRAY[1..8] OF CHAR;

              GROUPNAME: PACKED ARRAY[1..8] OF CHAR;

              ACCOUNTNAME: PACKED ARRAY[1..8] OF CHAR;

              CREATORNAME: PACKED ARRAY[1..8] OF CHAR;

          END;

A complete description of the information that you can obtain using FLABELINFO is given in the MPE/iX Intrinsics Reference Manual (32650-90028).

Feedback to webmaster