Declaring the driving file for a report

!drive

Declare the driving file for the report


SYNTAX

!drive file_id [index = index_id] [temp]

Declare the Sculptor keyed file which is the main driving file for the report. Only one !drive declaration may be defined in each !report section.

The driving file is processed automatically by the program logic, each record from it being read in turn, and the main body of statements executed once for each record, unless it fails selection criteria (controlled by !select and !exclude statements).

file_id

The file_id of the driving file must be the identifier of a file declared in the main program (before the !report section) by ![o]file.

If the file is not already open when the report is called, it is automatically opened after the !init section (if any) has been executed.

The driving file is reopened automatically if it is found to be closed at the point where the driving logic requires a new record.

[index = index_id]

This clause may be used to specify a secondary index, rather than the main file, to be the driving file for the report. The index_id must be the name of a secondary index defined for the main file. The ddeditor program is used to define data dictionaries and their secondary indexes.

A pointer field can be used to supply the index name, as shown here:

!temp idxptr,,p
     idxptr = &STOCKFILE.nameind
     ...

!report NameList
!drive STOCKFILE index=idxptr

[temp]

A special File mode available for use within the report only.


File mode

The file mode (read|update|create) is initially specified in the file’s ![o]file declaration (defaulting to update), but the openfile command may be used at run time to reopen it in a new mode. If the file is closed when the report is run, Sculptor opens the file in whichever mode it was last opened in. If it has never been opened, the mode in the file’s ![o]file declaration is used, defaulting to update mode. The mode may not be overridden in the !drive declaration. However, a special temp mode is available for use within the report only. All these modes are summarised below.

read

The file is opened in read-only mode. Records may not be amended, deleted or inserted. Records are not locked out from other users.

update

The file is opened in update mode. Each record processed by the driving logic is available for update, and locked from other users.

create

A new, empty file is created when the program starts. The file may or may not exist already; if it does exist, any records contained in it are destroyed. The current file ownership and access permissions are preserved. The file is then open in update mode. The program must insert the records which are to drive the report during the initialisation phase.

temp

If temp mode is specified, a temporary file with a unique name is created, with the same data dictionary structure as the file defined by file_id. As with create mode, the program must insert records which are to drive the report during the initialisation phase. The temporary file is deleted when the report finishes. If the !drive declaration specifies temp mode, the file’s previous mode is restored when the report terminates.


Report mode

The run time report_mode property may be used to specify that !drive opens records in read-only mode even if the file is open in update mode.


EXAMPLES

!drive MainFile
!drive Codes index = descrip
!drive TechDesc temp

RELATED TOPICS

Reports

![o]file