Page 1 of 1

fwnumFormat ( where is the documentation ?)

PostPosted: Mon Mar 23, 2020 3:40 pm
by Silvio.Falconi
? FWNumFormat(nPrice,"E") give me an array

is there a function to set number od price in Italian language

instead of transform(nPrice,"@E €999,999.99")

Re: fwnumFormat ( where is the documentation ?)

PostPosted: Mon Mar 23, 2020 4:07 pm
by Silvio.Falconi
this afternoon I made this (usefull for us Italian people)

sample :
nPrice := 2545.66
Euro(nprice, 10, 2, )

nprice can be numeric or string

Code: Select all  Expand view
Function Euro(nValore, nLen, nDec, lVirgola)
  local n, cEuro

  default nLen := 0, ;
          nDec := 2, ;
          lVirgola:= .T.

  if valtype(nValore) == "C"
    n := val(nValore)
  else
    n := nValore
  endif
                     
  if lVirgola
    cEuro := transform(n, "@E 999,999,999,999" + ; //R
                        iif(nDec > 0, "." + replicate("9", nDec), ""))
  else
    cEuro := str(n, max(nLen, 15), nDec)
  endif

  cEuro := ltrim(cEuro)

  if nLen > 0
    n := nLen - 1
    if len(cEuro) > n
      cEuro := replicate("*", n)
    else
      cEuro := padl(cEuro, n)
    endif
  endif

Return("€" + cEuro)

Re: fwnumFormat ( where is the documentation ?)

PostPosted: Tue Mar 24, 2020 6:02 am
by nageswaragunupudi
This is not necessary.
You can do this using FWNumFormat() and NUMPICT( nLen, nDec, ... )

Code: Select all  Expand view
function temptest()

   local cPic1, cPic2
   local nVal := 1234567.89

   FWNumFormat( "E", .t. )

   cPic1 := NUMPICT( 10, 2 )
   cPic2 := NUMPICT( 10, 2, nil, nil, nil, .t. )

   XBROWSER { { cPic1, nVal, cPic2, nVal } } TITLE "EUROPEN" SETUP ( ;
      oBrw:cEditPictures := { nil, cPic1, nil, cPic2 }, ;
      oBrw:cHeaders := { "PIC1", "VAL1", "PIC2", "VAL2" } )


   FWNumFormat( "B", .t. )

   cPic1 := NUMPICT( 10, 2 )
   cPic2 := NUMPICT( 10, 2, nil, nil, nil, .t. )

   XBROWSER { { cPic1, nVal, cPic2, nVal } } TITLE "BRITISH" SETUP ( ;
      oBrw:cEditPictures := { nil, cPic1, nil, cPic2 }, ;
      oBrw:cHeaders := { "PIC1", "VAL1", "PIC2", "VAL2" } )

   FWNumFormat( "A", .t. )

   cPic1 := NUMPICT( 10, 2 )
   cPic2 := NUMPICT( 10, 2, nil, nil, nil, .t. )

   XBROWSER { { cPic1, nVal, cPic2, nVal } } TITLE "AMERICAN" SETUP ( ;
      oBrw:cEditPictures := { nil, cPic1, nil, cPic2 }, ;
      oBrw:cHeaders := { "PIC1", "VAL1", "PIC2", "VAL2" } )

   FWNumFormat( "I", .t. )

   cPic1 := NUMPICT( 10, 2 )
   cPic2 := NUMPICT( 10, 2, nil, nil, nil, .t. )

   XBROWSER { { cPic1, nVal, cPic2, nVal } } TITLE "INDIAN" SETUP ( ;
      oBrw:cEditPictures := { nil, cPic1, nil, cPic2 }, ;
      oBrw:cHeaders := { "PIC1", "VAL1", "PIC2", "VAL2" } )

   FWNumFormat( "A", .t., nil, HB_UTF8CHR( 0x20b1 ) )

   cPic1 := NUMPICT( 10, 2 )
   cPic2 := NUMPICT( 10, 2, nil, nil, nil, .t. )

   XBROWSER { { cPic1, nVal, cPic2, nVal } } TITLE "PHILIPPINES" SETUP ( ;
      oBrw:cEditPictures := { nil, cPic1, nil, cPic2 }, ;
      oBrw:cHeaders := { "PIC1", "VAL1", "PIC2", "VAL2" } )

   FWNumFormat( "A", .t., nil, HB_UTF8CHR( 0x0E3F ) )

   cPic1 := NUMPICT( 10, 2 )
   cPic2 := NUMPICT( 10, 2, nil, nil, nil, .t. )

   XBROWSER { { cPic1, nVal, cPic2, nVal } } TITLE "THAILAND" SETUP ( ;
      oBrw:cEditPictures := { nil, cPic1, nil, cPic2 }, ;
      oBrw:cHeaders := { "PIC1", "VAL1", "PIC2", "VAL2" } )

return nil
 


Image

Re: fwnumFormat ( where is the documentation ?)

PostPosted: Tue Mar 24, 2020 6:07 am
by nageswaragunupudi
XBrowse, TDatarow etc programs automatically use FWNumFormt() settings to format numeric values.
By simply changing the settings of FWNumFormat() you can Internationalize your application as long as you do not interfere with their working by providing your own hard coded picture formats.

Re: fwnumFormat ( where is the documentation ?)

PostPosted: Tue Mar 24, 2020 11:09 am
by Silvio.Falconi
Sorry, on that situation I must not use the numlet on a xbrowse but on anoter control
see please viewtopic.php?f=3&t=38670
the price is printed on each rows

Re: fwnumFormat ( where is the documentation ?)

PostPosted: Tue Mar 24, 2020 2:38 pm
by nageswaragunupudi
TRANSFORM( nValue, NUMPICT( nLen, nDec, nil, nil, nil, .t. ) )

Re: fwnumFormat ( where is the documentation ?)

PostPosted: Tue Mar 24, 2020 6:18 pm
by Silvio.Falconi
thanks run ok as you can see

Image

I set 7 nlen 2 ndec

Re: fwnumFormat ( where is the documentation ?)

PostPosted: Wed Mar 25, 2020 8:08 am
by Jorge_T
nageswaragunupudi wrote:XBrowse, TDatarow etc programs automatically use FWNumFormt() settings to format numeric values.
By simply changing the settings of FWNumFormat() you can Internationalize your application as long as you do not interfere with their working by providing your own hard coded picture formats.


Hi Mr. Nages,
With Xbrowse I try to export to Calc format from LibreOffice or Xls from Excel with the instructions Obrw: ToCalc () or Obrw: ToExcel (). I use xbrNumFormat( "E", .t. ) but depends on the number of decimals of the fields it gives me the error "could not set format #, ## 0.00000 to Column N" and in the exported sheet it does not separate well the numerical formats. Also sometimes appears the error (DOS Error -2147352567) WINOLE / 1006
I would appreciate if you can show me some example of the proper functioning of this instruction, thank you very much and regards
viewtopic.php?f=6&t=38661#p230577