FNUMBER Function

M言語プログラミングブック [WALTERS1997] から引用

Page 81.


The $FNUMBER or $FN function returns a formatted string containing a number that was passed as argument. For example:

GTM> W $FNUMBER(-100,"-");

The formatting is specified using the second argument the function takes. It takes a string with zero or more special character, which are interpreted as follows:

  • “+”: puts a “+” in front of positive values.
  • “-”: removes the “-” from negative values.
  • ”,”: puts commas in every third position left of the decimal point.
  • “T”: represents the number with a trailing sign.
  • “P”: puts negative numbers between parenthesis.

This way, the function can be used as below:

GTM> S A=-100 S B=30000
GTM> W $FN(B,"+")
GTM> W $FN(A,"-")
GTM> W $FN(B,",')
GTM> W $FN(A,"T")
GTM> W $FN(A,"P")

Also, characters can be combined together in order to get specific formatting. For example:

GTM> S A=-100 S B=30000
GTM> W $FN(A,"+T")
GTM> W $FN(B,"+T")

Finally, a third argument can also be specified in order to define the number of digits after the decimal poing. For example:

GTM> W $FN(1/3,"",3)

Table Of Contents

Previous topic

FIND Function

Next topic

GET Function

This Page

inserted by FC2 system