[Gambas-user] I create a new function to share

kobolds kobolds at ...2041...
Fri Jun 26 17:34:04 CEST 2009




Pino Zollo wrote:
> 
> Il venerdì 26 giugno 2009 04:34:54 kobolds ha scritto:
>> I create a function call FormatX() for easy formatting number, date and
>> string . read the cctools.html for detail on how to use it .
>>
>> post your opinion what you think about it
>>
>> http://www.nabble.com/file/p24216805/cctools.tar cctools.tar
> 
> Hi,
> I have tried in "it_IT.utf8" environment and I get:
> 
> FMain.Form_Open.396: comma is decimal separator         True
> FMain.Form_Open.397: 2 347,25
> 
> Actually puts a space in place of .
> 
> This is the code:
> ----------
>  IF InStr(Str(Pi), ",") THEN ' check the locale...has it comma or point as
>  separator ?
>     comma = TRUE
>   ELSE 
>     comma = FALSE
>   END IF
>   DEBUG "comma is decimal separator ", comma  
>   DEBUG CCtools.formatx(-2347.25, "@N9.2")
> 
> ----------
> 
> I am going to try it in other LANG environment.
> 
> Thank you
> 
> Pino
> 
> -- 
> Key ID: 0xF6768208 
> Key fingerprint = B16D 0A7C 5B29 A334 CE6A  71F6 EAF8 3D88 F676 8208
> Key server: hkp://wwwkeys.eu.pgp.net
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 

thanks for trying the function . I never try other language before so right
now I don't know how to resolve the problem . 

I design this function to make difficult formatting  that gambas programmer
might encounter become easy.
you will probably using it more in situation that need fix size

for example
you need to write program to export data to text file in fix size in
following format. 
1. item_no      type:integer    size = 10 character , leading zero
2. item name   type:string      size = 20 character, trailing space
3. item_qty     type:integer    size = 5 character , leading zero
4. item_price   type:float       size = 10 character , 2 decimal , leading
zero, no thousand and decimal separator

you can easily do this by :
1. formatx(item_no , "@n010")
2. formatx(item_name, "@s20")
3. formatx(item_qty, "@n05")
4 formatx(item_price, "@n010vv2")
  
you can see that how this function simplify your code that you will need
more code without it?


-- 
View this message in context: http://www.nabble.com/I-create-a-new-function-to-share-tp24216805p24222407.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list