Line Lengths
Contents of Article
Introduction
SPFLite gives you the control over the lengths of lines of text files. This is done primarily by the command MINLEN - Set Minimum Record Length.
Why would this issue be important to you? Here are some likely reasons:
- You are using Picture strings in conjunction with primary commands like FIND, CHANGE, EXCLUDE, SPLIT and JOIN, and sometimes run into issues with "blank" lines that are zero-length. If you could avoid creating zero-length lines, some types of editing tasks can be done more simply.
- You may be creating a conventional text file with standard FORMAT End-of-Line delimiters, but for some reason you need all lines to be of the same length. This requirement may stem from usage of the file by an external system such as a mainframe, or perhaps by an embedded system.
END the edit when AUTOSAVE is in effect, SPFLite will issue a warning message like this:
File contains lines longer than Record-Length of nnn
Click YES to continue and truncate lines, or
Click NO to abandon the file save and return to Edit
Other ways to truncate your data to a given length are:
To define a "garden variety" standard, variable-length Windows text file, the associated PROFILE settings are FORMAT U CRLF 0. In SPFLite, this term really means the maximum logical record length. For files of type Record-format is F, the Record-Length must be a positive number defining the fixed line size. For Record-Format U, Record-Length 0 really means that there is no (arbitrary) maximum length, because the end of the line is determined from the End-of-Line setting rather than a fixed value.
In addition to the Record-Length option, you can now define the minimum logical record length using MINLEN.
In prior versions of SPFLite, the minimum logical record length is treated as 0; that is, there is no minimum, so text lines can be of any length, including length zero.
The MINLEN option defaults to 0 unless you set it otherwise.
When the MINLEN option is set, SPFLite does the following:
- If the MINLEN value is greater than zero, the file currently being edited is scanned, any any lines shorter than the newly-specified MINLEN are padded with blanks to the minimum length.
- Any lines changed manually by typing into them, lines changed from primary or line commands, and lines added from COPY and PASTE commands, will have their minimum line length enforced by the MINLEN value in effect at the time.
NOTE: MINLEN affects the contents of the file "while you are editing", it does NOT necessarily affect the file when it is written. See the next section and the Profile option PRESERVE for details.
The MINLEN option, being a PROFILE setting, is unique to a given file type. If you want a certain minimum length enforce (like 1 for example), you would have to update all of your existing profiles, and then update the DEFAULT profile so that any newly-created profiles would also have the MINLEN set to what you wanted.
Note: Be aware that any primary command such as SPLIT and JOIN, and line commands such as TS, TB/TBB, TR, PL and TL may be documented as implicitly producing lines of a certain length, but the MINLEN value in effect at the time for a file will override this, so that no matter what you attempt to do, you will not create lines shorter than the minimum length.
PRESERVE handling
PRESERVE specifies how trailing blanks on a line are to be handled, so it does interact with MINLEN.
The extra blanks that may be added by MINLEN processing are not treated specially. So if you specify PRESERVE ON, these extra added blanks will be written to the file. So don't specify an uneccessarily large value for MINLEN if you use PRESERVE ON, you could add considerably to your file size.
If you need to truncate or pad lines to manually enforce a line length, the Trim command TR/TRR and the Pad to Length command PL/PLL can be used.
The Pad to Length line command PL will accept a special modifier of / or \. When used in this way, a command of PL/ will pad all following lines to a minimum length of 1; PL\ will do the same to preceding lines. Placing PL/ on line 1 of a file can be used to ensure that all lines in the file have a minimum line length of 1; that is, it is a quick way to ensure there are no zero-length lines in the file. If you need to pad to a longer length (such as 4 for example), you can use the block mode version with PLL4 on line 1 and PLL on the last line.
The Truncate line command TL/TLL can also be used, but be aware that since truncation is involved, this command can cause data loss.
See TR / TRR - Trim Trailing Blanks, PL / PLL - Pad Lines, and TL / TLL - Truncate Lines to a Length for more information.
Created with the Personal Edition of HelpNDoc: Make Your PDFs More Secure with Encryption and Password Protection