| Format |
PAD(string$,len[,pad_code][,char$][,ERR=stmtref])
Where:
| char$ |
Optional string. Its first character
is used to pad string$. If you omit
this, the default is to pad with blanks. String
expression. |
| |
| len |
Desired length of string. Numeric
expression. |
| pad_code
|
Optional numeric parameter defining
how to pad the string, either numeric or string:
- 0 or L Pad on
Left (right justify)
- 1 or R Pad on
Right (left justify - default.
.
- 2 or C Centre
in string
If omitted, the
string is padded to the right.
|
| stmtref |
Program line number or statement
label to which to transfer control. |
| string$ |
String expression to be processed. |
|
| Example |
The
following code uses asterisks to pad a numeric value to a
length of 30 characters:
00180 LET
chq_amt=1.98,cust_name$="ACME INC."
00190 LET
chq_amt$="*****"+PAD(STR(chq_amt),30,"*")
00200 PRINT 'CS',@(0,5),"Customer name
:",PAD(cust_name$,20),"| ",
00210 PRINT @(0,6),chq_amt$
-:run
Customer name :ACME INC. |
*****1.98**************************
This code sample
illustrates the use of alphnumeric versus numeric pad
types in the PAD( ) function:
0100 ! ^100 - PAD
function
0110 Orig$="Test
String",Char$=".",PadLen=20
0120 print 'LF',"Original String:
"+@(24)+'BR'+Orig$+'ER'+'LF'
0130 Type=0,Type$="L"; gosub PadIt; print
0140 Type=1,Type$="R"; gosub PadIt; print
0150 Type=2,Type$="C"; gosub PadIt
0160 stop
0170 !
0180 PadIt:
0190 print
"PAD(Orig$,"+str(PadLen)+","+pad(str(Type),3,2)+","+quo+Char$+quo,
0200 print ") =
"+@(24)+'BR'+pad(Orig$,PadLen,Type,Char$)+'ER'
0210 print
"PAD(Orig$,"+str(PadLen)+","+quo+Type$+quo+","+quo+Char$+quo,
0220 print ") =
"+@(24)+'BR'+pad(Orig$,PadLen,Type$,Char$)+'ER'
0230 return
|