RPad$: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (moved RPad$ to RPAD$)
No edit summary
Line 1: Line 1:
   RPad$(A$,X[,"char"])
   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. If "char" is used the padding will use the specified character rather than a blank space for the fill character.
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.
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====
====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.
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
  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)).
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====
====See Also====
*[[LPad$]]
*[[LPad$]]
*[[LTrm$]]
*[[LTrm$]]

Revision as of 10:49, 30 January 2012

 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