FILE

Editing Program for Binary Files

DESCRIPTION

FILE is a general purpose program used to display and/or change the contents of a disk file. It is especially useful for handling binary files such as DAT files and DTP files, which cannot be handled by conventional text editors.

RUNNING THE PROGRAM

Change the default drive (and directory, if appropriate) to the drive (and directory) where your file resides. Run the program by typing

FILE

in response to the prompt from the operating system. The program will respond by typing out its name and version no. as well as the current date.

You will be asked to enter the name of your file. The default filename extension is DAT.

SPECIFYING THE BLOCKSIZE

Next you will be asked to enter the number of words per block. FILE reads data from the disk file into memory and writes data from memory to the disk file in chunks called blocks. You can specify how large a block is to be. The maximum blocksize that FILE allows is 2048 words. (1 word = 2 bytes, so the maximum blocksize is 4096 bytes; a byte is the amount of memory or disk space required to store one ASCII character.) If the disk file you are processing is a DAT file or DTP file, you would normally want to use the default blocksize, 256 words, which is obtained by just pressing Return in response to the prompt.


GENERAL PRINCIPLES FOR USING FILE

Unlike some of the other programs (e.g. UPDATE), nothing happens automatically in FILE. You tell FILE what to do by entering command letters. Many of the command letters are followed by numerical arguments.

After you have started FILE and opened the disk file, it sits waiting for your first command. Up to 5 commands may be entered at one time, and FILE will execute them in the order in which they were entered. After it has executed your command(s), it waits for more.

As a general rule, you start by reading into memory a block of data from the disk file. You can then display all or part of the contents of the block on the terminal and/or modify the contents of the block. If you modify the block, the disk file is not altered until you write the block in memory back to the disk file. The block in memory may be written back to its original position or to a new position (the previous contents of that block of the file are then lost). The data in memory may be written to disk any number of times, but only one block of data from the file is held in memory at any one time.

NOTE: Changes made to the disk file by FILE are immediate and permanent.

The old contents of the file are not recoverable.

ENTERING COMMANDS

The program will type an asterisk prompt when it is ready to accept commands. It will accept up to 5 commands on one line, provided that the line of commands and arguments is no more than 40 characters long. No delimiters are required between commands.

To get a menu on the screen listing the commands recognised by FILE, just press Return in response to the asterisk prompt.

The commands and their functions are listed in 10.6 below. Most of the commands may be or must be followed by 1 or 2 numerical arguments. If two numerical arguments are entered, they must be separated by a comma.

THE COMMANDS

The commands recognised by FILE fall into four broad classes: block commands, display commands, change commands and miscellaneous commands. Following are detailed descriptions of all the commands.

(a) The block commands (R, W and B). These commands cause transfer of a whole block of data between memory and the disk file.

R (Read) - Reads the block specified from the disk file into memory. Block number must be specified, and must not be greater than the number of blocks in the file.

W (Write) - Writes the block of data in memory onto the disk file. If a block number is not specified, it will be written onto the block that was last read from. If a number is specified, it will be written onto that block.

N.B. The previous contents of that block of the disk file are lost.

B (Blank) - Zero fills the entire block in memory and writes it out to the specified block of the disk file. Block number must be specified.

(b) The display commands (A, L and S). These commands display all or part of the block in memory at the terminal.

A (ASCII) - Displays the specified bytes of the block in memory in ASCII character format. If followed by two numbers, they are the first and last bytes displayed. If followed by one number, that byte is displayed. If no arguments are specified, the whole block is displayed.

L (List) - Displays the specified words of the block in memory in decimal format. Arguments are as for A, except that they specify words rather than blocks.

S (Show) - Displays the specified bytes of the block in memory in decimal. Arguments are as for A.

(c) The change commands (C, I, N and Z). These commands change the data in all or part of the block in memory.

C (Change) - Accepts new value(s) for specified word(s) of the block currently in memory. Must be followed by one or two numbers specifying word or range of words to be changed.

The program will respond with the *? prompt. The new values must be typed in at the terminal, in decimal and separated by commas. A value omitted by typing two successive commas defaults to zero. A value or a comma must be entered for every word specified in the command.

The block must be Written to change the disk file.

I (Insert) - Same as C, but changes specified bytes instead of words. New values are in decimal, as for C.

N (Negate) - Negates the value of specified word(s) of the block currently in memory. Must be followed by one or two numbers specifying the word or range of words to be negated.

Z (Zero) - Zeroes specified word(s) of the block currently in memory. Arguments as for N.

(d) The miscellaneous commands (F, T, ?, X and Q).

F (File) - Checks for changes made to the block in memory and not written to the disk file. If any are found, the program offers a chance to write the block to to the file. Then closes the current file and prompts the user for a new filename.

N.B. Any commands typed on a line after F will be ignored.

T (Transfer) - Copies blocks into a new file. The program prompts the user for a new filename and creates a new file. Then the program prompts for the start and end numbers of a range of blocks to be copied from the old file to the new file. If no end block is specified, the program transfers only the start block. When the user presses Return in response to the prompt for the start block number, the program closes the new file.

? (which block?) - Prints out the number of the block currently in memory.

X (repeat) - Causes the last command line to be executed again, after incrementing the block number for any R, W or B commands by 1.

e.g., if the last command line was R5N256W, then X will cause R6N256W to be executed.

Note: X must be the only command in the line when it is used. X cannot be used following C,I,T or F in the last command line. X is treated as an invalid character if it is not first in the command line.

Q (Quit) - Checks for changes made to the block in memory and not written to the disk file. If any are found, the program offers a chance to write the block to to the file. Then closes the current file and terminates the program.

EXITING FROM FILE

To exit from FILE, enter the Q (quit) command. The program will check to see whether you have modified the block currently in memory but not written it back to the disk file; if so, it will give you a chance to write the block to the disk file. The program then closes the disk file, which saves all changes, and terminates.

Note: Control-C is disabled in FILE to prevent you from accidentally exiting from the program without writing your last changes to disk.