Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?

FMT

Description 

This function is useful for formatting data for output, according to a defined mask. It takes the general form: 

FMT(var, 'mask code')

Where var is the element to which the mask code is to be applied, and the mask code is defined as: 

Mask code
                                    Description
  j
  Justification
  R Right Justified
  L Left Justified
  U Left Justified, Break on space. Note: This justification will format the output into blocks of data in the variable and it is up to the programmer to actually separate the blocks.
D Date (OCONV)

  N
Decimal Precision: A number from 0 to 9 that defines the decimal precision. It specifies the number of digits for output following the decimal point. The processor inserts trailing zeros if necessary. If n is omitted or is 0, a decimal point will not be output.

m
Scaling Factor: A number that defines the scaling factor. The source value is descaled (divided) by that power of 10. For example, if m=1, the value is divided by 10; if m=2, the value is divided by 100, and so on. If m is omitted, it is assumed equal to n (the decimal precision).

  z
Suppress leading zeros. Note that fractional values, which have no integer, will have a zero before the decimal point. If the value is zero, a null will be output.
 
  ,
The thousands separator symbol. It specifies insertion of thousands separators every three digits to the left of the decimal point. You can change the display separator symbol by invoking the SET-THOU command. Use the SET-DEC command to specify the decimal separator.

  c
Credit Indicator. Note that If a value is negative and the programmer has not specified one of these indicators, the value will be displayed with a leading minus sign. If the programmer specifies a credit indicator, the data will be output with either the credit characters or an equivalent number of spaces, depending on its value.
  • C Prints the literal CR after negative values.
  • D Prints the literal DB after positive values.
  • E Encloses negative values in angle brackets < >
  • M Prints a minus sign after negative values.
  • N Suppresses embedded minus sign.

  $
  Appends a Dollar sign to value.

Fill and Character length
  • #n Spaces. Repeat space n times. Output value is overlaid on the spaces created.
  • *n Asterisk. Repeat asterisk n times. Output value is overlaid on the asterisks created.
  • %n Zero. Repeat zeros n times. Output value is overlaid on the zeros created.
  • &x Format. x can be any of the above format codes, a currency symbol, a space, or literal text. The first character following & is used as the default fill character to replace #n fields without data. Format strings are enclosed in parentheses "( )".

 

An example of use is as: 

     VAL = 321456
     CRT FMT(VAL, 'L2%3')
     CRT DQUOTE( FMT(VAL, 'R2#10') )  
     CRT FMT(VAL , 'L2%10')  
     CRT FMT(VAL, 'R2%10')   
     CRT FMT(VAL, 'L2*10')    
     CRT FMT(VAL, 'R2*10')


to output the following to the screen:

321
" 321456.00"
321456.000
0321456.00
321456.00*
*321456.00

 

Go back to jBASE BASIC.

Was this article helpful?