| PAD( ) | Pad/Truncate String | 
PAD(string$,len[,pad_code][,char$][,ERR=stmtref])
   
Where: 
| char$ | Optional string. Its first character is used to pad string$. If omitted, 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: 
 | ||||||||
| stmtref | Program line number or statement label to which to transfer control. | ||||||||
| string$ | String expression to be processed. | ||||||||
The value of the string after applying the padding/truncation.
The PAD( ) function converts a given character string (string$) to the length (len) specified. It makes the string the desired length either by truncating the string$ or by appending the defined pad character. The default is to pad with spaces.
If the length you specify is less than 0, PxPlus returns an Error #41: Invalid integer encountered (range error or non-integer).
The following code uses * (asterisks) to pad a numeric value to a length of 30 characters:
chq_amt=1.98,cust_name$="ACME INC."
chq_amt$="*****"+pad(str(chq_amt),30,"*")
print 'CS',@(0,5),"Customer name :",pad(cust_name$,20),"| ",
print @(0,6),chq_amt$
->run
Customer name :ACME INC. |
*****1.98**************************
This code sample illustrates the use of alpha-numeric versus numeric pad types in the PAD( ) function:
! ^100 - PAD function
Orig$="Test String",Char$=".",PadLen=20
print 'LF',"Original String: "+@(24)+'BR'+Orig$+'ER'+'LF'
Type=0,Type$="L";
gosub PadIt;
Type=1,Type$="R";
gosub PadIt;
Type=2,Type$="C";
gosub PadIt
stop
!
PadIt:
print "PAD(Orig$,"+str(PadLen)+","+pad(str(Type),3,2)+","+quo+Char$+quo,
print ") = "+@(24)+'BR'+pad(Orig$,PadLen,Type,Char$)+'ER'
print "PAD(Orig$,"+str(PadLen)+","+quo+Type$+quo+","+quo+Char$+quo,
print ") = "+@(24)+'BR'+pad(Orig$,PadLen,Type$,Char$)+'ER'
return