Managing Line Lengths

Contents of Article


The MINLEN profile option

The TR and PL line commands


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:

The MINLEN profile option

To define a "garden variety" standard, variable-length Windows text file, the associated PROFILE settings are RECFM U, LRECL 0, EOL CRLF.  The LRECL option is named after an IBM term meaning Logical Record Length.  In SPFLite, this term really means the maximum logical record length.  For files of type RECFM F and RECFM V, the LRECL must be a positive number defining the maximum allowed line size.  For RECFM U, LRECL 0 really means that there is no (arbitrary) maximum length, because the end of the line is determined from the EOL setting rather than a fixed value.

In addition to the LRECL 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:

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.

The TR and PL line commands

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: News and information about help authoring tools and software