LPad$: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (1 revision)
(No difference)

Revision as of 14:11, 15 January 2012


LPad$(A$,X[,"char"])

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

Comments and Examples

10 LET A$ = "Right-justify"
20 LET B$ = "Right-edge"
30 PRINT LEN(A$),LEN(B$)
40 LET A$ = LPAD$(A$,13)
50 LET B$ = LPAD$(B$,13)
60 PRINT LEN(A$),LEN(B$)

The above example will print 10 and 13 from line 30, but will print 13 and 13 from line 60 after both strings have been left-padded with blanks.

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.

See Also

Technical Considerations

  1. If the left padding is being done only to improve the output format, the CR format specification provides an alternative that executes faster, takes less time to code, and uses less program space.