RPad$: Difference between revisions
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
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. | 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). [[Null]]s and [[Chr$(0) | 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). [[Null]]s and [[Chr$]](0) are allowed. | ||
====Comments and Examples==== | ====Comments and Examples==== |
Revision as of 18:23, 22 July 2013
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)).