Skip to main content
Version: 3.1.X

Maintenance Utilities

These tools are essential for the physical health of the Master File (.mst). They handle sorting, cross-platform conversion, tag renaming, and manual unlocking of databases.

MSRT (Sort)

The MSRT program sorts a master file in ascending order based on sort keys generated by a format specification.

When a master file is sorted, record mfn=1 will contain the lowest sort key, mfn=2 the second lowest, and so on.

Syntax

msrt <dbname> <keylen> <keyfmt>|tag=<n> [-mfn] [+del] [tell=<n>]

Parameters

ParameterDescription
dbnameThe master file to be sorted in place.
keylenThe fixed length of the sort key.
keyfmtThe PFT format used to generate the sort key (e.g., v10).
tag=<n>Shortcut: Specifies a data field <n> as the sort key without a PFT.
-mfnKeep Original MFNs. Updates the .mst file in place without renumbering the MFNs. The physical order changes, but the ID remains.
+delDelete Duplicates. If consecutive records have identical sort keys, they are deleted.
tell=<n>Displays a progress message every <n> keys processed.

How it works

  1. Index Update: MSRT updates the .xrf file, swapping entries to reflect the new order.
  2. Renumbering (Default): By default, records are renumbered after sorting.
  3. In-Place Update (-mfn): If -mfn is used, the records remain in the same physical slots (saving rewrite time), but the logical order is updated.

Examples

Sort by Title (Tag 24) Sorts the cds database using the first 60 characters of field 24, converted to uppercase (Heading Mode).

msrt \cisis\cds\cds 60 mhu,v24

Sort by Tag 998 (Fixed) Sorts mxtb_out assuming tag 998 contains numeric values padded with zeros.

msrt mxtb_out 9 v998


RETAG (Renumber Tags)

The RETAG program changes the tag of fields in the master file according to a conversion table. It modifies records in their original positions, preserving the master file structure.

Syntax

retag <dbname> {<retag.tab>|unlock} [from=<n>] [to=<n>] [tell=<n>] [shift=<n>]

Retag Table (.tab)

A simple text file mapping old tags to new tags. It may contain up to 5,461 entries.

Format:

<old_tag> <new_tag>

Example Table:

24 240
70 700
69 690

In this example, tag 24 becomes 240, 70 becomes 700, etc. Only records containing these tags are rewritten.

Unlocking with RETAG

RETAG can also be used to perform a generic unlock of the master file using the unlock keyword instead of a table.


CRUNCHMF (Cross-Platform Conversion)

CRUNCHMF converts the binary structure of the Master File (.mst and .xrf) from one operating system architecture to another (e.g., moving a database from Windows to Linux). The binary structures are often incompatible between systems (Little Endian vs Big Endian).

The program automatically detects the source system format.

Syntax

crunchmf <dbn> <target_dbn> [options]

Options

OptionDescription
target={os}Defines the target architecture. Default: linux.
Values: pc (Windows), linux, hpux, sun, alpha, vax, unisys, mpe, cdc, same.
format={isis}Target format: isis (Standard) or cisisX (Extended).
mstxl={0|1|2|4}Determines the maximum size of the .mst file.
0 = 512MB (Default).
Higher values allow for databases larger than 2GB.
tell=<n>Report progress.

Example

Converting a Windows database to Linux:

crunchmf bases/mydb/data/mydb bases/mydb/data/mydb_linux target=linux


CTLMFN (Control Record / Unlock)

CTLMFN reads and edits the Control Record (the header) of the Master File. This is the first block of the file containing critical metadata like the Next MFN and Locking flags.

It is primarily used to manually unlock a database stuck in a "Write Lock" or "Data Entry Lock" state.

Syntax

ctlmfn <dbname>

Control Fields

When run, the tool displays a table of values:

FieldMeaning
nxtmfnNext MFN to be assigned (Total records + 1).
nxtmfbLast block assigned in the file.
nxtmfpNext available position in the last block.
mfcxx2Data Entry Lock (Number of users inputting data).
mfcxx3Exclusive Write Lock (0 = Unlocked, 1 = Locked).

Example: Resetting a Lock

If a server crash leaves a database locked (Error: "Database already locked"), run ctlmfn and reset mfcxx3 to 0.

$ ctlmfn users
*users
nxtmfn nxtmfb nxtmfp t reccnt mfcxx1 mfcxx2 mfcxx3 RC
6 24 391 0 0 0 0 1 0

nxtmfn [6]:
nxtmfb [24]:
nxtmfp [391]:
...
mfcxx3 [1]: 0
ok

Note: Press Enter to keep existing values, type 0 for the lock field, and type ok to save.


MXCP (Copy & Clean)

Copies records from one database to another, serving as the primary tool for database compression and cleaning (removing deleted records).

  • Syntax: mxcp <in> create=<out> [clean] [undelete]
  • Key Features:
  • clean: Compresses the MF, removing space from deleted records/fields.
  • undelete: Recovers logically deleted records during the copy.

MXTB (Tabulation)

Generates frequency tables and statistics based on database keys.

  • Syntax: mxtb <dbn> create=<dbout> <keylen>:<format>
  • Example:
mxtb books create=stats 60:v100

(Creates a stats database where records count the frequency of Authors in books).