RPad$

From BR Wiki
Jump to navigation Jump to search
 RPAD$(<sring>,<length>[,"character"])

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

An optional third parameter ("character") 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