File Editor - Version 8.30F
By Jeremy Burton

Copyright (c) PSION Plc 1994


Syntax: FE <filename> (<start byte offset>)


FREEWARE DISCLAIMER

Please note that this software is supplied free of charge, as public domain
software, and as such, is entirely unsupported by PSION.
There is no warranty whatsoever, whether implied or otherwise, for
merchantability or fitness for a particular purpose.


**********************************************************************
 

Introduction
============

FE is a hex editor with an integral TLV Dump facility which allows
you to view the underlying structure of a TLV file and overlay that
structure onto the hex dump itself.

TLV (Type Length Value) file formats are used by several SIBO
applications.


A Brief Description of TLV File Formats
=======================================

It is beyond the scope of these notes to provide a full description
of TLV file formats.  An in depth discussion can be found in the
`Additional System Information' manual of the `PSION SIBO C Development Kit'.
However, a brief description follows.

TLV files consist of a standard file header followed by one or more
TLV records.  TLV is an acronym for Type, Length, Value and each TLV
record comprises those parts:

1) Type
-------

Every TLV record has a `type' which is specified at the beginning of
the record.  For instance a record might be a type 0 record, a deleted
record, or a type 1 record, a current data record.

2) Length
---------

The length of the record in bytes in also specified at the beginning
of each record.


3) Value
--------

The actual data in the record.  This is structured differently for
different types of record and for different applications.


**********************************************************************


Instructions
============


Some Conventions
----------------


1) Number Notation
   ---------------

FE diplays most numbers in both decimal and hexadecimal notation.
Where hexadecimal is used, the number is prefixed with a & symbol.

This principle also applies when a user enters numbers, where the &
prefix can be used to specify hexadecimal.

2) Zero Offset
   -----------

FE treats the first byte in any file as having a file offset of 0.
Therefore, it is important to remember that the offset of the last byte
in a file is always 1 below the actual length in bytes of the file.



Starting FE
===========

You must specify a filename when you first start FE from a DOS
prompt.

e.g. To edit a Series 3 agenda file called AGENDA.AGN, type:

     FE AGENDA.AGN

You may optionally specify a `start offset'.  This is used to tell FE
to jump to a particular point in the file immediately on opening it.
(By default, FE jumps to the first byte in the file on opening it).

e.g. To start editing at hex file offset FF, type:

     FE AGENDA.AGN &FF



Screen Layout
=============

The FE screen comprises, from top to bottom:

1) Menu Bar - menus are dropped down by pressing Alt and the
   appropriate highlighted letter from the menu name.

2) Editing Window - this contains the actual hexdump of the file.
   This displays one `sector' (256 bytes) from the file.

   - Relative file offsets within the sector are displayed down the left
     hand side of the screen.
   - The hexadecimal value of each byte is displayed in the middle.
   - A textual representation of the data is displayed on the right.
     If a particular byte value does not correspond to a normal
     printable character, the character is displayed as a stop (.).

   When using the TLV dump function, this window is used to
   display the contents of the TLV log file (see below).

3) Status Window - this contains information about the file being
   edited such as its length and current file offsets (both relative to
   the current sector and absolute).

4) Message Bar - this is where FE displays various messages to the user.


Basic Movement
==============

The cursor keys are used to move around within the current sector.
The byte currently selected is highlighted in red.

To move up and down between sectors, use `Page Up' (PgUp) and `Page
Down' (PgDn).

`Home' and `End' can be used to jump to the first and last byte in
the file, respectively.



Function Descriptions
=====================

All of FE's functions can be selected via their menu option - there are
no `hidden extras'.
In addition, the most commonly used functions have corresponding Ctrl key
equivalents.  A full list of the Ctrl key equivalents can be viewed by
pressing the F1 key.
Some menu options may be disabled at certain times.


The following instructions give detailed explanation (where necessary) of
each of FE's functions in the order in which they appear the menus.


1) `File' Menu (Alt F)
    ------------------

a) Open file

Opens a new file for editing, closing the existing file and saving any
changes.
Remember that you must initially specify a filename when you first
start FE.


b) Write Sector (Ctrl W)

Writes any changes the user has made to the current sector to the file.
Whether or not the user is prompted before updating the file depends on
how the options have been set (see `Options' menu below).


c) Jump To (Ctrl J)

Jump to any byte offset within the file.
Remember you can specify the offset in either hex (& prefix) or in
decimal (no prefix).
FE also supports incremental jumping: you can prefix the offset with
either + or - to indicate movement forward or backward in the file,
relative to the current offset.


d) Find (Ctrl F)

Search for a text string within the file between the current offset and
the end of the file.
The search IS case sensitive.
FE will automatically jump to the start of the first match found.


e) Find Again (Ctrl A)

Find the next match for the previously entered search clue starting from
one byte ahead of the last match found.


f) Exit (Ctrl X)

Exit FE and close the file.
You will ALWAYS be prompted as to whether you wish to save any changes
made to the current sector irrespective of the option setting.



2) `Tlv' Menu (Alt T)
   ------------------

FE will check the TLV integrity of the file from start to finish,
irrespective of the current file offset.

The TLV dump runs until either:

i) The TLV dump is successful
   You are returned to the current file offset and the TLV record
   structure is overlaid onto the hex dump.
   The message `TLV Dump Successful' is displayed in the message bar.

ii) The TLV dump is not successful
    FE displays the nature of the TLV error it has found - press
    Space to continue.
    FE will then jump to the file offset where the error was found.
    The TLV structure is overlaid onto the hex dump up to the point
    of the error.

    The possible errors are:

    1) Unknown Header
       FE does not recognise the header of the file.

    2) Record length exceeds end of file
       A record's declared length exceeds the actual length of the
       file

    3) Unexpected record type
       A record type not supported by this file format has been found

    4) Type 2 Record must be first
       A data record has been detected before a Type 2 record

    5) Actual record length differs from declared record length
       The length declared at the start of the record differs from
       the actual length of the data in the record

    6) Should only have one Type 2 Record
       A second Type 2 record has been found in the file

    7) Illegal Field Type
       The Type 2 record contains an unsupported field type

    8) Write Failure Record
       A Series 3a Agenda file record contains a write failure record
       indicating that no data after that point should be trusted


Positions of Errors
-------------------

The file offset that FE indicates as the position of the error is not
always the actual position of the corruption in a file.  It is merely
the first detectable error.
Because TLV files are read sequentially, a seemingly valid piece of data
can cause a `knock-on' effect further down the file.
For example, if a record header erroneously gave its length as 4K
rather than 1K, FE might not be able to detect the error until 4K
further into the file although the actual error was obviously at the
beginning of the record.


TLV Overlay
-----------

After a TLV dump, the actual structure of the TLV file is overlaid
onto the hex dump itself.  This is done by highlighting the first
byte in each record in cyan.  This overlay can be toggled on/off (see
below).


The Log File
------------

The TLV dump process also creates a text `log' file of the TLV
structure.
This details the type, length and file offset of each record and the
contents of some record types.  It also shows where errors were
found.

This log file can be viewed from within FE (see below).
The log file name can be set using the `TLV Dump' option in the
`Options' menu (see below).



a) Start (Ctrl T)

Starts the TLV dump process (see above).


b) Toggle Overlay (Ctrl O)

Turns the TLV structure indicators which overlay the hex dump on/off.


c) View File (Ctrl V)

View the TLV log file.
The hex dump will be removed from the editing window and replaced by
the TLV log file.
If a TLV error has been detected, the relevant part of the log file
will be displayed.  Otherwise, the start of the log file will be
displyed.
The keys used are as follows:
    Up & down cursor - move up and down 1 line
    PgUp & PgDn      - move up and down 1 page
    Home & End       - jump to start/end of file
    Esc              - return to hex edit


d) Jump to Last Error

Makes the position of the last detected fatal TLV error, the current
offset.


e) Compress File

This is used to compress a TLV file by removing the deleted (Type 0)
records from it.
The file must pass a TLV integrity check before it can be compressed.


f) Extract Text

This is designed to extract the text from a TLV file which is badly
corrupted to a newline delimited text file.
(This relies on the fact that between most records in a TLV file, there
are usually two unprintable characters and that between each field in a
reocrd there is usually one unprintable character.)

Simply enter the filename to extract to and press Enter.



3) `Edit' Menu (Alt E)
   -------------------

a) Toggle Edit Mode (Ctrl M)

Toggle between editing in `hex' mode and `text' mode.
The current mode is displayed in the status window.

When in `hex' edit mode, your keypesses are interpreted as
hexadecimal numbers and the byte at the current offset is changed to
the hexademcimal value you type in.
In `text' edit mode, your keypresses are interpreted as single ASCII
characters and the ASCII character at the current offset is replaced.


b) Set Start Marker (Ctrl S)

Sets the Start Marker to the current offset.
The Start Marker is used to mark the beginning of a file block for various
file editing operations.
The position of the Start Marker is shown in green on the hex dump.


c) Set End Marker (Ctrl E)

Sets the End Marker to the current offset.
The End Marker is used to mark the end of a file block for various
file editing operations.
The position of the Start Marker is shown in blue on the hex dump.


NOTE: The Start and End Markers are inclusive, i.e. both the byte at the
Start Marker and the byte at the End Marker are part of the selected
block.


d) Show Length (Ctrl L)

Displays the (inclusive) length between the Start and End Markers in hex
and decimal in the message bar.
This is especially useful for finding the length of records and Lead Byte
Counted (LBC) strings in a file.


e) Copy Section

Copies the file section between the markers to another filename.
Specify the filename and press Enter.


f) Cut Section

Permanently remove the file section between the two markers.

NOTE: Information cut from a file is permanently lost.  If you wish to
retain it, use the Copy Section option first.


g) Paste Section

Paste another file into the current file, immediately behind the
position of the Start Marker.



4) `Options' Menu (Alt O)
   ----------------------

a) TLV Dump

Enables you to set the name of the TLV log file produced when the TLV
dump option is used.


b) Save

Enables you to set whether writes to the file are confirmed or not.


c) Colours

Enables you to set the screen colours.



5) `Help' Menu (Alt H)
   -------------------

a) Keypress List (F1)

Displays a list of the Ctrl key equivalents for specific menu
options.


b) View Instructions

Lets you view this file, FE.TXT, in the editing window.
FE.TXT must be in the current DOS directory for FE to find it.


**********************************************************************


These notes prepared 17/06/94 by Jeremy Burton.
