vEdit makes converting text, database, and binary files with fixed-length records properly easy. Files with “fixed-length records” fall into two categories:

  • Data/binary files that are organized into records of the same length. There is no “Newline” (e.g., Carriage-Return and Line-Feed) at the end of each record. Therefore, you must explicitly set the correct record length with CONFIG > File handling > File type. When properly set, the records will align nicely within vEdit. You will have to “know” the record length from the file specifications, or you will have to deduce it. Such files are edited in “Record” mode.
  • Text files in which all lines have the same length. Each line (record) ends with a “Newline” (e.g., Carriage-Return and Line-Feed). Such files are already normal text files.

A file “exported” from a database will often be a text file in which all lines (records) have the same length. However, the raw database file will often be a binary file with fixed-length records.

Once you open the files it should be easy to figure out which you have:

  • If the records are aligned when you first open it, it is probably a text file. CONFIG > File handling > File type will be set to “0”, “1” or “2”.
  • If nothing is aligned when you first open it, it is probably a data/binary file. VEDIT typically opens binary files with a record length of 64; you must set CONFIG > File handling > File type to the correct record length and possibly CONFIG > File handling > Record header size to the correct header size. The records should then be aligned on the screen.

Text files, in which all lines have the same length, generally do not need to be converted into anything else.

Files with fixed-length records are limited in how you can edit. For example, you can not insert or delete characters since this would change the length of the current record and thereby corrupt the entire file. Similarly, you cannot delete a field by highlighting it as a columnar block.

This limitation on editing files with fixed-length records is controlled with CONFIG > File handling > Overwrite-only mode. You can turn it off, but you must then be extra careful not to corrupt the file.

Converting from Fixed-Length to Normal Text

When possible, you should convert the data file into a standard text file with Carriage-Return and Line-Feed after each record. This is easily done in vEdit.

Data files with fixed-length records can be converted into normal text files which have a “Newline” (e.g., Carriage-Return and Line-Feed) at the end of each record. In other words, each record is converted into a text line. Such text files are much easier to edit and can be imported into databases and other programs.

Convert from fixed-length records into normal text file

  1. Check if the file’s record length is set correctly; the records should be nicely aligned on the screen. If necessary, use CONFIG > File handling > File type to set the correct record length.
  2. Next make sure e records don’t already end in Carriage-Return and Line-Feed. To check this, place the cursor at the end of one record and then press Alt-D (hot-key for VIEW > Toggle display mode) six times to toggle into “Hex mode”. If there are hex codes “0D” and/or “0A” then the records already end in Carriage-Return and/or Line-Feed (skip step 3). If not continue on to step 3 after Press Alt-D four more times to toggle back into the normal “ASCII-0” display mode.
  3. Select EDIT > Convert > CONVERT macro. Select Yes to convert the entire file.
  4. In the convert menu, enter “7” to convert from fixed-length records to “newlines”. Then select [Win/DOS] assuming you want Carriage-Return and Line-Feed at the end of each record.

Although the file will not look any differently on the screen now, it will have been converted. You can confirm this by checking CONFIG > File handling > File type; it should now be set to “0”.

After saving the converted file, you should be able to open/import it in most other programs.

Converting Normal Text into Fixed-Length Records

Text files with "Newline" characters can be converted into data files with fixed-length records and without "newline" charaters.

This procedure generally only done if all text lines have the same length. In particular, the longest text line should not be longer than the desired record length. The conversion will pad shorter lines and can optionally truncate longer lines.

Convert from text lines into fixed-length records

1. Select User then Find longest line. If the longest line is longer than the desired record length it is recommend to stop and correct the length. Alternatively, you can have lines longer than the record length truncated in the following steps.

2. Select Edit, Convert, then Convert Macro. Select Yes to convert the entire files.

3. In the convert menu enter "8" to convert to a data file with fixed-length records.

4. Enter the desired record length, you maybe prompted for confirmation to convert any tab characters into spaces (based on the currently configured tab stops).

5. If any lines are longer than the record length you will be prompted with: Split, Split All, Truncate, Truncate All, Edit, or Abort.

Split
Splits the long line into two lines, thereby creating two records. The second record is padded with spaces to reach the record length.
Truncate
Simply truncates the end of the long line.

Any lines shorter than the record length are padded with spaces to the record lenght.

6. If any lines are split or truncated, the files convert.err display a summary of the conversion, including the line numbers of the too-long lines.

You can confirm your changes by clicking Config > File handling > File type; it should now be set to the selected record length.

Related Resources