(implemented in VERSION 7) System Functions
JST( ) Justify String
   
Format JST( string$,len [, jstcode [$] ][,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.
jstcode Optional numeric or string parameter defining how to justify the string:
  • 0 or R Right justify.
  • 1 or L Left justify default.
  • 2 or C Centre in string

If omitted, the string is right justified.

stmtref Program line number or statement label to which to transfer control.
string$ String expression to be processed.
   
Returns Value used in OPT= option.
   
Description The JST( ) 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 a defined pad character. The default is to pad with spaces.

If the length you specify is less than zero, ProvideX returns an Error #41: Invalid integer encountered (range error or non-integer).

See Also PAD( ) Pad/Truncate string
   
Examples The following code sample uses asterisks to justify a numeric value to a length of 30 characters:

00180 LET chq_amt=1.98,cust_name$="ACME INC."
00190 LET chq_amt$="*****"+JST(STR(chq_amt),30,"*")
00200 PRINT 'CS',@(0,5),"Customer name :",JST(cust_name$,20),"| ",
00210 PRINT @(0,6),chq_amt$
-:run
Customer name :ACME INC. |
*****1.98**************************

This example illustrates the use of alphnumeric versus numeric pad types in the JST( ) function:

0100 ! ^100 - PAD and JST functions
0110 Orig$="Test String",Char$=".",PadLen=20
0120 print 'LF',"Original String: "+@(24)+'BR'+Orig$+'ER'+'LF'
0130 Type=0,Type$="L"; gosub JustifyIt; print
0140 Type=1,Type$="R"; gosub JustifyIt; print
0150 Type=2,Type$="C"; gosub JustifyIt
0160 stop
0170 !
0200 ! ^100
0210 JustifyIt:
0220 print "PAD(Orig$,"+str(PadLen)+","+quo+Type$+quo+","+quo+Char$+quo,
0230 print ") = "+@(24)+'BR'+pad(Orig$,PadLen,Type$,Char$)+'ER'
0240 print "JST(Orig$,"+str(PadLen)+","+quo+Type$+quo+","+quo+Char$+quo,
0250 print ") = "+@(24)+'BR'+jst(Orig$,PadLen,Type$,Char$)+'ER'
0260 return