Cascade Historian: Version 4.1
Prev |  | Next

# filebase

filebase -- associates the history with a file for data storage.

## Syntax

    (filebase history directory basename extension [numdigits])

## Parameters

`history`

  The name of a history, as defined by the history command.

`directory`

  A string containing the name of an existing directory, either absolute or relative to the directory in which histdb was started.

`basename`

  A string containing the base file name, without an extension or directory.

`extension`

  A string containing the file extension.

`numdigits`

  An integer that specifies how the filename is augmented for multiple files, described in detail below.

## Returns

`t` (true) if successful, otherwise

        (error "History history does not exist")

or

        (error "supplied command: Failed to access/create file filename (OS-dependent error)")

where `filename` is `directory`/`basename`*`extension` from the supplied arguments, and `OS-dependent error` is typically "`No such file or directory`" or "`Permission denied`".

## Description

This command associates a file with a history. Without an associated file, data received by the Cascade Historian will be lost when the buffer is full, or when the Cascade Historian is shut down. A history without a file (and with a sufficiently large buffer) could be used for temporary storage and analysis of data.

A history is potentially logged to multiple files. These can be numbered sequentially, or based on date, as specified by the `numdigits` parameter. The filename specified by the user is automatically augmented as each new file is opened, and the Cascade Historian understands that these files all belong together as a single history.

When filebase or `HI_FileBase` is first called for a history, it sets the pattern for all file names to be created for the history. Once this has been done, the Cascade Historian will be able to find the files relating to that history at any time, and will begin numbering from the next file number as necessary.

The possible values for the `numdigits` parameter, with their implications, are as follows:

- `< 0` : Use the date to generate the unique suffix.

- `= 0` : No sequential digits are added to the name. This is the default.

- `> 0` : Specifies the number of decimal digits to be added to the filebase.

The file name is computed as ``directory`/`basename``numdigits``extension``.

This command corresponds to the Cogent API function `HI_FileBase` and the `hist_filebase` dynamic library function.

## Example

The command:

        Hist> (filebase hist1 "/tmp/histories" "test." ".dat" 2)
        t

would create files of the form:

        /tmp/histories/test.01.dat
        /tmp/histories/test.02.dat
        /tmp/histories/test.03.dat
        ...

Prev | Home | Next
flag | Up | flush

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.