Sage-ST ä

Loglib

Documentation

CloseLogFile CreateLogFile FlushBlockFields GatherLogFile
GetCurrent GetFirst GetLast GetNext
GetPrevious GetRecNum LoadBlockFields LoadMemoryRecord
OpenLogFile PostErrorMessage PresentLog PrintLogReport
ProcessLogFile RepairLogFile SetMessageStatus SortFilteredLog
TransferLogEntries UpdateDataBase VerifiedLogFile




  PROCEDURE SetMessageStatus
             (CONST messageON : BOOLEAN);




  PROCEDURE CloseLogFile
             (VAR   LogFile : FileLG;
              VAR   state   : Files.FileState);

  (**
      CloseLogFile - Close log file, discontinue processing.


      CloseLogFile closes the log file access.

      CALLING SEQUENCE -

        CloseLogFile (LogFile, state)

      EXIT -

        LogFile : FileLG
          The handle to the log file.

        state : Files.FileState
          The state of the file after attempting to close.

      EXAMPLE -

        CloseLogFile (LogFile, State);
  *)




  PROCEDURE CreateLogFile
             (VAR   LogFile  : FileLG;
              CONST FileName : ARRAY OF CHAR;
              VAR   state    : Files.FileState);

  (**
      CreateLogFile - Create a new log file.


      CreateLogFile creates a new log file and/or overwrites an existing one.
      This makes this file available to be used by the transfer routine to
      copy log entries from one file to another.

      CALLING SEQUENCE -

        CreateLogFile (LogFile, FileName, State)

      ENTRY -

        FileName : ARRAY OF CHAR
          The name of the log file to create.  Please see the note at the
          beginning of the LogLib documentation about legal log names.

      EXIT -

        LogFile : FileLG
          The handle to the log file.

        State : Files.FileState
          The state of the file after attempting to create.

      EXAMPLE -

        CreateLogFile (LogFile, "TEST.A01", State);
  *)




  PROCEDURE GatherLogFile
             (CONST Path       : ARRAY OF CHAR;
              CONST LogName    : ARRAY OF CHAR;
              CONST outputPath : ARRAY OF CHAR;
              CONST outputName : ARRAY OF CHAR) : BOOLEAN;

  (**
      GatherLogFile - Gather log files into one log file.


      GatherLogFile gathers the requested log files into one log file.
      All logs files may be gathered by sending in an '*' for the name.

      CALLING SEQUENCE -

        GatherLogFile (path, LogName, outputPath, outputName)

      ENTRY -

        path : ARRAY OF CHAR
          Path to the log files to be gathered.

        LogName : ARRAY OF CHAR
          Name of the log files to gather.  This name may include the
          '?' and '*' wildcard characters.

        outputPath : ARRAY OF CHAR
          This is the path to the output file for the log entries.

        outputName : ARRAY OF CHAR
          This is the name of the output file for the log entries.  This name
          must NOT include an extension.  When this routine completes the
          outputName fill have an extension of ".A01".

      EXAMPLE -

        GatherLogFile ("C:\TEST\", "MYAPP*.L*", "C:\TEST2\", "MYAPP");
  *)




  PROCEDURE GetCurrent
             (VAR   LogFile : FileLG;
              CONST Raw     : BOOLEAN;
              VAR   Header  : LogHeadDefinition);

  (**
      GetCurrent - Gets the header information for current log entry.


      GetCurrent reads the current log entry information from the log file.
      Whether the entry is to come from the raw or filtered file must be
      specified with the Raw flag.

      CALLING SEQUENCE -

        GetCurrent (LogFile, Raw, Header)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the current entry in the raw file.

          FALSE - Read the current entry in the filtered file.

      EXIT -

        LogFile : FileLG
          Handle to the log file.

        Header : LogHeadDefinition
          Record containing current log entry information

      EXAMPLE -

        GetCurrent (LogFile, False, Head);
  *)




  PROCEDURE GetFirst
             (VAR   LogFile   : FileLG;
              CONST Raw       : BOOLEAN;
              VAR   Header    : LogHeadDefinition;
              VAR   Available : BOOLEAN);

  (**
      GetFirst - Gets the header information for first log entry.


      GetFirst reads the first log entry information from the log file.
      Whether the entry is to come from the raw or filtered file must be
      specified with the Raw flag.

      CALLING SEQUENCE -

        GetFirst (LogFile, Raw, Header, Available)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the first entry in the raw file.

          FALSE - Read the first entry in the filtered file.

      EXIT -

        LogFile : FileLG
          Handle to the log file.

        Header : LogHeadDefinition
          Record containing first log entry information

        Available : BOOLEAN
          TRUE - The requested record is available

          FALSE - The requested record is NOT available

      EXAMPLE -

        GetFirst (LogFile, False, Head, Available);
  *)




  PROCEDURE GetLast
             (VAR   LogFile   : FileLG;
              CONST Raw       : BOOLEAN;
              VAR   Header    : LogHeadDefinition;
              VAR   Available : BOOLEAN);

  (**
      GetLast - Gets the header information for last log entry.


      GetLast reads the last log entry information from the log file.
      Whether the entry is to come from the raw or filtered file must be
      specified with the Raw flag.

      CALLING SEQUENCE -

        GetLast (LogFile, Raw, Header, Available)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the last entry in the raw file.

          FALSE - Read the last entry in the filtered file.

      EXIT -

        LogFile : FileLG
          Handle to the log file.

        Header : LogHeadDefinition
          Record containing last log entry information

        Available : BOOLEAN
          TRUE - The requested record is available

          FALSE - The requested record is NOT available

      EXAMPLE -

        GetLast (LogFile, False, Head, Available);
  *)




  PROCEDURE GetNext
             (VAR   LogFile   : FileLG;
              CONST Raw       : BOOLEAN;
              VAR   Header    : LogHeadDefinition;
              VAR   Available : BOOLEAN);

  (**
      GetNext - Gets the header information for next log entry.


      GetNext reads the next log entry information from the log file.
      Whether the entry is to come from the raw or filtered file must be
      specified with the Raw flag.

      CALLING SEQUENCE -

        GetNext (LogFile, Raw, Header, Available)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the next entry in the raw file.

          FALSE - Read the next entry in the filtered file.

      EXIT -

        LogFile : FileLG
          Handle to the log file.

        Header : LogHeadDefinition
          Record containing next log entry information

        Available : BOOLEAN
          TRUE - The requested record is available

          FALSE - The requested record is NOT available

      EXAMPLE -

        GetNext (LogFile, False, Head, Available);
  *)




  PROCEDURE GetPrevious
             (VAR   LogFile   : FileLG;
              CONST Raw       : BOOLEAN;
              VAR   Header    : LogHeadDefinition;
              VAR   Available : BOOLEAN);

  (**
      GetPrevious - Gets the header information for previous log entry.


      GetPrevious reads the previous log entry information from the log file.
      Whether the entry is to come from the raw or filtered file must be
      specified with the Raw flag.

      CALLING SEQUENCE -

        GetPrevious (LogFile, Raw, Header, Available)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the previous entry in the raw file.

          FALSE - Read the previous entry in the filtered file.

      EXIT -

        LogFile : FileLG
          Handle to the log file.

        Header : LogHeadDefinition
          Record containing previous log entry information

        Available : BOOLEAN
          TRUE - The requested record is available

          FALSE - The requested record is NOT available

      EXAMPLE -

        GetPrevious (LogFile, False, Head, Available);
  *)




  PROCEDURE GetRecNum
             (VAR   LogFile      : FileLG;
              CONST Raw          : BOOLEAN;
              CONST RequestedRec : ModSys.INT32;
              VAR   Header       : LogHeadDefinition;
              VAR   Available    : BOOLEAN);

  (**
      GetRecNum - Gets the header information for specified log entry.


      GetRecNum reads the specified log entry information from the log file.
      Whether the entry is to come from the raw or filtered file must be
      specified with the Raw flag.

      CALLING SEQUENCE -

        GetRecNum (LogFile, Raw, RequestedRec, Header, Available)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the previous entry in the raw file.

          FALSE - Read the previous entry in the filtered file.

        RequestedRec : ModSys.INT32
          The number of the record to read.

      EXIT -

        LogFile : FileLG
          Handle to the log file.

        Header : LogHeadDefinition
          Record containing previous log entry information

        Available : BOOLEAN
          TRUE - The requested record is available

          FALSE - The requested record is NOT available

      EXAMPLE -

        GetRecNum (LogFile, False, 24, Head, Available);
  *)




  PROCEDURE LoadBlockFields
             (VAR   LogFile : FileLG;
              CONST Raw     : BOOLEAN;
              CONST Method  : UpdateType);

  (**
      LoadBlockFields - Load block data from log to block fields.


      LoadBlockFields reads the block data from the log file and puts it into
      the block data field of the record.

      CALLING SEQUENCE -

        LoadBlockFields (LogFile, Raw, Method)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the data from the raw file.

          FALSE - Read the data from the filtered file.

        Method : LogLib.UpdateType
          The method to be used to write the data.

      EXIT -

        LogFile : FileLG
          The handle to the log file.

      EXAMPLE -

        LoadBlockFields (LogFile, True, LogLib.ADD);
  *)




  PROCEDURE FlushBlockFields
             (VAR   LogFile : FileLG;
              CONST Raw     : BOOLEAN);

  (**
      FlushBlockFields - Flush (get rid of) any saved block field data.


      FlushBlockFields flushes (gets rid of) any of the block data that
      was being accumulated to use with a record.  If the record is not
      going to be used then this routine flushes the block data also.

      CALLING SEQUENCE -

        FlushBlockFields (LogFile, Raw, Method)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the data from the raw file.

          FALSE - Read the data from the filtered file.

        Method : LogLib.UpdateType
          The method to be used to write the data.

      EXIT -

        LogFile : FileLG
          The handle to the log file.

      EXAMPLE -

        FlushBlockFields (LogFile, True, LogLib.ADD);
  *)




  PROCEDURE LoadMemoryRecord
             (VAR   LogFile : FileLG;
              CONST Raw     : BOOLEAN;
              VAR   Success : BOOLEAN);

  (**
      LoadMemoryRecord - Load memory record for requested log entry.


      LoadRecord loads the memory record with the data from the log file for
      the requested record.

      CALLING SEQUENCE -

        LoadMemoryRecord (LogFile, Raw, Success)

      ENTRY -

        Raw : BOOLEAN
          TRUE - Read the data from the raw file.

          FALSE - Read the data from the filtered file.

      EXIT -

        LogFile : FileLG
          The handle to the log file.

        Success : BOOLEAN
          Was the operation successful?

      EXAMPLE -

        LoadMemoryRecord (LogFile, True, Success);
  *)




  PROCEDURE OpenLogFile
             (VAR   LogFile   : FileLG;
              CONST FileName  : ARRAY OF CHAR;
              CONST Modify    : BOOLEAN;
              VAR   TotalRecs : CARDINAL;
              VAR   state     : Files.FileState);

  (**
      OpenLogFile - Opens the specified log file.


      OpenLogFile opens the requested log file for processing.  The file may
      be opened for modification or as a read only file.

      CALLING SEQUENCE -

        OpenLogFile (LogFile, FileName, Modify, State)

      ENTRY -

        FileName : ARRAY OF CHAR
          Name of the log file to open.  Please see the note about legal log
          file names at the beginning of the LogLib documentation.

        Modify : BOOLEAN
          BOOLEAN value as to whether the file may be modified while open.

      EXIT -

        LogFile : FileLG
          Handle to the log file.

        TotalRecs : CARDINAL
          Total number of RAW records in this log.

        State : Files.FileState
          The state of the file upon returning.

      EXAMPLE -

        OpenLogFile (LogFile, "MYAPP.A01", True, TotalRecs, State);
  *)




  PROCEDURE PostErrorMessage
             (CONST Message : ARRAY OF CHAR);

  (**
      PostErrorMessage - Allows a user error message while updating.


      PostErrorMessage allows a user error message to be posted to the
      error file during the time that the UpdateDataBase procedure is
      running.  This is NOT a valid call at any other time.

      CALLING SEQUENCE -

        PostErrorMessage (Message)

      ENTRY -

        Message : ARRAY OF CHAR
          The message to post to the error file.

      EXAMPLE -

        PostErrorMessage ("Unknown Error Occurred");
  *)




  PROCEDURE PresentLog
             (VAR   LogFile : FileLG;
              CONST LProc   : PresentProc);

  (**
      PresentLog - Scroll log file entries on screen.


      PresentLog opens a window on screen and scrolls the information about
      the entries in the log file.  Only the filtered log will be presented.

      CALLING SEQUENCE -

        PresentLog (LogFile, LProc)

      ENTRY -

        LogFile : FileLG
          The handle to a valid opened log file to display.

      EXAMPLE -

        PROCEDURE LoadRoutine
                  (RecordsStart : in     ModSys.INT32;
                   RecordsMax : in     ModSys.INT32);


        begin
          -- |
          -- | The records from RecordsStart to RecordsMax have been selected.
          -- | At this point you can load them, print them, etc.
          -- |
        end LoadRoutine;

        PROCEDURE PresentMyLog is new Loglib.PresentLog
             (LoadRoutine);

        begin
          PresentMyLog (LogHandle, state);
  *)




  PROCEDURE PrintLogReport
             (VAR   LogFile  : FileLG;
              CONST DestFile : ARRAY OF CHAR;
              CONST DflName  : ARRAY OF CHAR;
              CONST Raw      : BOOLEAN;
              CONST StartRec : ModSys.INT32;
              CONST EndRec   : ModSys.INT32);

  (**
      PrintLogReport - Print report of log file to output file.


      PrintLogReport prints a report of the contents of the log file to the
      requested output.

      CALLING SEQUENCE -

        PrintLogReport (LogFile, DestFile, DFLName, Raw, StartRec, EndRec)

      ENTRY -

        LogFile : FileLG
          The handle to a valid opened log file.

        DestFile : ARRAY OF CHAR
          The name of destination for the report.

        DFLName : ARRAY OF CHAR
          The name of the DFL file that this log file belongs to.

        Raw : BOOLEAN
          TRUE - Read the data from the raw file.

          FALSE - Read the data from the filtered file.

        StartRec : ModSys.INT32
          The number of the starting log entry to use.

        EndRec : ModSys.INT32
          The number of the ending log entry to use.  If this number is greater
          than the number of entries in the log then the report will stop at the
          end of the log file.

      EXAMPLE -

        PrintLogReport (LogHandle, "MYAPP.RPT", "MYAPP.DFL", False, 1, 100);
  *)




  PROCEDURE ProcessLogFile
             (VAR   LogFile : FileLG;
              CONST Raw     : BOOLEAN;
              CONST PProc   : ProcessProc);

  (**
      ProcessLogFile - Read the log file entries into memory sequentially.


      ProcessLogFile reads the log entries starting at the first and continuing
      sequentially through the file.  The entry is read, the memory record is
      loaded and then the PProc is called.  If the block data is to be loaded
      then the proper routine will need to be called from inside the PProc.

      CALLING SEQUENCE -

        ProcessLogFile (LogFile, Raw)

      ENTRY -

        LogFile : FileLG
          The handle to a valid opened log file to process.

      EXIT -

        Raw : BOOLEAN
          TRUE - Read the data from the raw file.

          FALSE - Read the data from the filtered file.

      EXAMPLE -

        PROCEDURE ProcessProc
                   (LogFile : in out FileLG;
                    LogHead : in     LogHeadDefinition;
                    ContinueOn : in out BOOLEAN) is

        begin
          -- |
          -- | The memory record for the current entry is loaded.  Validate
          -- | it, transfer it, print it, etc.
          -- |
        end ProcessProc;

        PROCEDURE ProcessMyLog is new Loglib.ProcessLog
                   (ProcessProc);

        begin
          ProcessMyLog (LogHandle, state);
  *)




  PROCEDURE SortFilteredLog
             (VAR   LogFile    : FileLG;
              CONST SortMethod : SortMethodType;
              CONST Force      : BOOLEAN);

  (**
      SortFilteredLog - Sort the filtered log in a different order.


      SortFilteredLog allows the filtered log to be sorted in one of four
      different methods to allow efficiency of processing.  The four methods
      are 1) Date - date + time 2) Relation - Relation + Date + Time
      3) UserID - UserID + Date + Time 4) UserRelation - UserID + Relation
      + Date + Time.

      CALLING SEQUENCE -

        SortFilteredLog (LogFile, SortMethod, Force)

      ENTRY -

        LogFile : FileLG
          The handle to a valid opened log file.

        SortMethod : SortMethodType
          The method of sorting to be used.

        Force : BOOLEAN
          TRUE - Sort the file even if it is current sorted in this method.

          FALSE - Don't sort if current sorted in the defined SortMethod.

      EXAMPLE -

        SortFilteredLog (LogHandle, LogLib.Date, True);
  *)




  PROCEDURE TransferLogEntries
             (VAR   LogFile  : FileLG;
              VAR   DestLog  : FileLG;
              CONST Raw      : BOOLEAN;
              CONST StartRec : ModSys.INT32;
              CONST EndRec   : ModSys.INT32);

  (**
      TransferLogEntries - Transfer current entry in LogFile to DestLog.


      TransferLogEntries allows the user to transfer the current log entry
      (Raw or Filtered as defined by Raw) to a second opened log file.  If
      it is a filtered entry then the corresponding log entry will be
      transferred along with the requested log entry.

      CALLING SEQUENCE -

        TransferLogEntry (LogFile, DestLog, Raw, StartRec, EndRec)

      ENTRY -

        LogFile : FileLG
          The handle to a valid opened log file.

        Raw : BOOLEAN
          TRUE - Read the data from the raw file.

          FALSE - Read the data from the filtered file.

        StartRec : ModSys.INT32
          The starting record number to use.

        EndRec : ModSys.INT32
          The ending record number to use.

      EXIT -

        DestFile : FileLG
          The handle to a valid opened destination log file.

      EXAMPLE -

        TransferLogEntries (LogHandle, LogDest, True, 1, 100);
  *)




  PROCEDURE UpdateDataBase
             (VAR   LogFile      : FileLG;
              CONST Raw          : BOOLEAN;
              CONST StartRec     : ModSys.INT32;
              CONST EndRec       : ModSys.INT32;
              CONST ExternalFile : BOOLEAN;
              CONST UProc        : UpdateProc;
              VAR   Error        : BOOLEAN);

  (**
      UpdateDataBase - Update database from entries in log file.


      UpdateDataBase reads the entries of the log file and updates the database.

      CALLING SEQUENCE -

        UpdateDataBase (LogFile, Raw, StartRec, EndRec, ExternalFile, UProc, Error)

      ENTRY -

        LogFile : FileLG
          Handle to a log file.

        Raw : BOOLEAN
          TRUE - Read the data from the raw file.

          FALSE - Read the data from the filtered file.

        StartRec : ModSys.INT32
          The starting RAW record number to use.

        EndRec : ModSys.INT32
          The highest numbered RAW record to use.

        ExternalFile : BOOLEAN
          TRUE - This file was created externally and is being merged into the
                 current data base.

          FALSE - This file was created directly on the current database.

        UProc : UpdateProc
          Procedure to call as each record is processed.  In this procedure the
          user is responsible to locate the record that is to be updated and
          rewrite or write it.

        Error : BOOLEAN
          TRUE - An error occurred while processing.
          FALSE - No errors encountered during processing.

      EXAMPLE -

        PROCEDURE UpdateRoutine
                  (    Relation : ARRAY OF CHAR;
                       Operation : UpdateType;
                   VAR Continue : BOOLEAN);

        BEGIN
          The current memory record for the Relation is loaded with data
          as defined by the Operation.  Take any actions necessary and
          then return the Continue flag is TRUE to do another record
          or FALSE to stop.

        END UpdateRoutine;


        BEGIN
          LogLib.UpdateDataBase (LogFile, TRUE, 1, 150, FALSE, UpdateRoutine, Error);
  *)




  PROCEDURE VerifiedLogFile
             (CONST LogFileName : ARRAY OF CHAR) : BOOLEAN;

  (**
      VerifiedLogFile - Verify if the records seem to be intact in this log file.


      This routine reads through the records in the log file and returns a boolean
      indicating if at least the structure of all the records seems to be valid.
      An invalid return value would indicate that at least one record does not
      match the size recorded for it.

      CALLING SEQUENCE -

        VerifiedLogFile (LogFileName)

      ENTRY -

        LogFile : ARRAY OF CHAR
          The name of the log file to check.

      EXIT -

        BOOLEAN
          TRUE - All records match the internal size recorded for them.
          FALSE - A record was detected which does not matche the size it should be.
  *)




  PROCEDURE RepairLogFile
             (CONST OriginalLogFile : ARRAY OF CHAR;
              CONST RepairedLogFile : ARRAY OF CHAR;
              VAR   BadRecordsFound : CARDINAL;
              VAR   Success         : BOOLEAN);

  (**
      RepairLogFile - Repair a log file that contains a corrupted record.


      This routines reads through a log file and makes a new copy which does
      not contain the corrupted record.  By throwing out one record at least
      some of the data recorded can be saved.  If you try to update using a
      corrupted file most if not all the data might be lost.  This routine
      provides a mechanism to at least recover most of it.

      CALLING SEQUENCE -

        RepairLogFile (OriginalLogFile, RepairedLogFile, BadRecordsFound, Success)

      ENTRY -

        OriginalLogFile : ARRAY OF CHAR
          The name of the original log file, the one that is thought to contain a
          corrupted record.

        RepairedLogFile : ARRAY OF CHAR
          The name of the file that will receive the good records.  Once this routine
          finishes this should be a clean log file that will not contain any
          corrupted records.

      EXIT -

        BadRecordsFound : CARDINAL
          The number of bad records encountered and cleaned out of the file.

        Success : BOOLEAN
          TRUE - The file was successfully processed which indicates that all possible
                 good records were recovered.
          FALSE - The file could not be processed.  The file may be so corrupted as to
                  be completely unrecoverable.
  *)




Send mail to   warren.merrill@inl.gov with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance