Skip to main content

STATUS

Provides file status information.

Synopsis

STATUS dynarray FROM filevar [THEN statements] [ELSE statements]

Arguments

dynarray A dynamic array used by STATUS to hold file information as Field elements.
filevar A file variable name specifying the file from which status information is to be returned. This filevar is obtained from OPEN or OPENSEQ.

Description

The STATUS statement is used to return status information about a file. This information is returned as Field Mark delimited elements of a dynamic array. You must open the file, using the OPEN or OPENSEQ statement, to obtain the filevar required to invoke STATUS.

You can optionally specify a THEN clause, an ELSE clause, or both a THEN and an ELSE clause. If file status information is obtained, the THEN clause is executed. If file status information could not be obtained, the ELSE clause is executed. The statements argument can be the NULL keyword, a single statement, or a block of statements terminated by the END keyword. A block of statements has specific line break requirements: each statement must be on its own line and cannot follow a THEN, ELSE, or END keyword on that line.

To display individual status fields, use angle bracket syntax. The following example displays the 20th field, which is the full file path:

STATUS statdyn FROM filevar
PRINT statdyn<20>

Field 1 of dynarray contains the current position of the sequential file pointer, counting from 0. This count includes the two-character newline (carriage return + line feed) that appears at the end of each line of data in a sequential file. The same file pointer is used by WRITESEQ and READSEQ. You can reposition this pointer using the SEEK statement.

Field 20 of dynarray contains the full file path of the open file.

Field 21 of dynarray contains a numeric code for the file type, as follows: -2 sequential file; -1 dir-type file; 0 global with the full record in a single node; 1 global with each attribute in a separate subnode.

Examples

The following example opens a sequential file on a Windows system and determines its status. It prints out two status fields: the full pathname and the file type (in this case, -2):

myfile='c:\InterSystems\Cache\Dev\mv\samples\CommandExample'
OPENSEQ myfile TO filevar ELSE STOP 201,myfile
STATUS statdyn FROM filevar
   PRINT statdyn<20>
   PRINT statdyn<21>
CLOSESEQ filevar

The following example opens the VOC file and determines its status. It prints out two status fields: the file pathname (in this case, a global variable) and the file type (in this case, 0):

OPEN 'VOC' TO myvoc ELSE STOP 201,'VOC'
STATUS statdyn FROM myvoc
   PRINT statdyn<20>
   PRINT statdyn<21>
CLOSE myvoc

See Also

FeedbackOpens in a new tab