RPad$

From BR Wiki
Revision as of 17:43, 26 February 2014 by John (talk | contribs) (moved RPAD$ to RPad$ over redirect)
Jump to navigation Jump to search
 RPad$(A$,X[,"char"])

The RPad$ internal function returns A$, adding trailing blanks to make it X characters long. If A$ already has at least X characters, no blanks are added.

An optional third parameter ("char") has been added to LPad$ and RPad$ to specify the character to be used for the padding (instead of blanks, which are still the default). The "char" parameter is limited to one character in length (error 410 will result if it is longer). Nulls and Chr$(0) are allowed.

Comments and Examples

To make sure that a string to be used as a key field is long enough to match the length of the key field (assumed to be 12 in this example), the RPad$ function can be used in the KEY= clause.

00510 READ #2,USING 520,KEY=RPAD$(X$,12): COMPANY$ NOKEY 980

A more generalized solution is to use the KLN(2) function to obtain the key length for file 2 instead of coding the 12 as a constant; then the KEY= clause would be KEY=RPAD$(X$,KLN(2)).

See Also