LPad$: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (moved LPAD$ to LPad$ over redirect)
No edit summary
 
Line 1: Line 1:
  LPad$(A$,X[,"char"])
  LPAD$(<string>$,<length>[,"<character>"])


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.
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====
====Comments and Examples====
Line 14: 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====

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.