LPad$: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (moved LPad$ to LPAD$)
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
LPAD$(<string>$,<length>[,"<character>"])


The '''LPad$''' [[internal function]] returns the string$, adding leading blanks to make it "length" characters long. If the string$ already has at least that many characters, no blanks are added.


LPad$(A$,X[,"char"])
====Comments and Examples====


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"
  10 LET A$ = "Right-justify"
  20 LET B$ = "Right-edge"
  20 LET B$ = "Right-edge"
Line 15: Line 14:
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.
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.
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 "character" parameter is limited to one character in length (error 410 will result if it is longer). Nulls and CHR$(0) are allowed.


====See Also====
====See Also====
*[[RPad$]]
*[[RPad$]]
*[[LTrm$]]
*[[LTrm$]]
Line 23: Line 23:


====Technical Considerations====
====Technical Considerations====
# 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.
# 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.


<noinclude>
<noinclude>
[[Category:Internal Functions]]
[[Category:Internal Functions]]
</noinclude>
</noinclude>

Latest revision as of 00:10, 22 May 2014

LPAD$(<string>$,<length>[,"<character>"])

The LPad$ internal function returns the string$, adding leading blanks to make it "length" characters long. If the string$ already has at least that many 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 ("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 "character" 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.