Jump to content
  • 0

cijfers to text


drjonesx

Question

Hello everybody

 

I'm trying to convert number to text in dutch but it doesn't work

 

i had some problem with the calc field when i m trying ( some are good but other doesn't work)

is there someone that can help me to resolve this little problem cose i m not a dutch person ;)

Or there is a example file already done?

 

In advance thanks u

 

here is my email in case of

drjonesx@belcenter.com

Link to post

12 answers to this question

Recommended Posts

  • 0

Try this custom function:

NumberAsText ( number ; i )

The code of the CF:

If ( GetAsNumber ( number ) < 10^66 ; 
Let ( [ 
number = Filter( number ; "0123456789" ) ; 
Nr = Right ( number ; 3 ) ;  
n = Left ( number ; Length ( number ) - 3 ) ; 
L = Length ( Nr ) ; 
h = If ( L = 3 ; GetAsNumber ( Middle ( Nr ; L - 2 ; 1 ) ) ) ; // Hundreds
t = If ( L > 1 ; GetAsNumber ( Middle ( Nr ; L - 1 ; 1 ) ) ) ; // Tens
d = If ( L > 1 ; GetAsNumber ( Right ( Nr ; 2 ) ) ) ; // Doubles
s = GetAsNumber ( Right ( Nr ; 1 ) ) ; // Singles
th = Choose ( h ; "" ; "één" ; "twee" ; "drie" ; "vier" ; "vijf" ; "zes" ; "zeven" ; "acht" ; "negen" ) & "honderd" ; 
tt = Choose ( t ; "" ; "tien" ; "twintig" ; "dertig" ; "veertig" ; "vijftig" ; "zestig" ; "zeventig" ; "tachtig" ; "negentig" ) ; 
td = Choose ( d ; "" ; "één" ; "twee" ; "drie" ; "vier" ; "vijf" ; "zes" ; "zeven" ; "acht" ; "negen" ; "tien" ; 
		"elf" ; "twaalf" ; "dertien" ; "veertien" ; "vijftien" ; "zestien" ; "zeventien" ; "achttien" ; "negentien" ) ; 
ts = Choose ( s ; "nul" ; "één" ; "twee" ; "drie" ; "vier" ; "vijf" ; "zes" ; "zeven" ; "acht" ; "negen" ) ; 
p = Choose ( i ; "" ; "duizend" ; "miljoen" ; "miljard" ; "biljoen" ; "biljard" ; "triljoen" ; "triljard" ; 
		"quadriljoen" ; "quadriljard" ; "quintiljoen" ; "quintiljard" ; "sexiljoen" ; "sexiljard" ; 
		"septiljoen" ; "septiljard" ; "octiljoen" ; "octiljard" ; "noniljoen" ; "noniljard" ; "deciljoen" ; "deciljard" ) ; 
	txt = 	If ( h > 0 ; th ) & 
	If ( d ≥ 20 and s > 0 ; If ( h > 0 ; "en" ) & ts & If ( d > 20 ; "en" ) ) & 
	If ( d ≥ 20 ; tt ) & 
	If ( d < 20 ; If ( h > 0 and d > 0 or n > 0 and L = 2 ; "en" ) & td ) & 
	If ( L = 1 ; ts ) & p
] ; 
If ( n > 0 ; NumberAsText ( n ; i + 1 ) ) & txt
) ; " ≥ 10^66 " )

 

[edit]Added a tweak to calculation of the doubles and corrected "achttien" in the "td" variable[/edit]

Edited by Guest
Link to post
  • 0

U right but the idea was to make an calcul field that was more easy that to past from an script

i really appricaite your help for this problem

 

Hope u can help in just a calcul field that give the result :)

 

Thanks a lot for your precious help

Link to post
  • 0

Either the CF or the script would really be the eassiest way. You probably need this calc to create cheques or certificates of some kind. If you absolutely need a calc, then you should break the CF down and start repeating all of the content up to 22 times, into a flat non-recursive function, but that would be very hard to edit or debug ....

 

Better use the script, in the way I wrote it, it's easy to use for other fields as well. Good luck :P

Link to post
  • 0

Thank u for your help

 

A friend set me the CF in the file but it seems to have a mistake

 

when i set with the script file 153.51 i receive

TEXT : vijftienduizenddriehonderdenvijftien

resultat : driehonderdenvijftien

 

with the CF

vijftienduizenddriehonderdenéénenvijftig

 

And the result need to be that no?

honderd drieenvijftig euro en eenenvijftig cent

 

Because i don't speak dutch very hard for me to resolv it :(

Thanks for your time Menno

Link to post
  • 0

The formula i made is for integers only, so you should use it twice:

Once for the integer and the create an integer for the fraction and use it again, so it would something like:

NumToText ( 153 ; "" ) & " euro en " NumToText ( 51 ; "" )

I assume that you know how to disect a number into 2 integers?

Link to post
  • 0

:? Try:

Let ( [ 
    n1 = int ( number ) ; 
    n2 = Right ( 100 * number ; 2 ) ; 
    t1 = NumberAsText ( n1 ) ; 
    t2 = If ( GetAsNumber ( n2 ) > 0 ; NumberAsText ( n2 ) ; "nul" )
] ; 
    t1 & " euro en " & t2 & " cent" 
)

Most of this is math, a bit of logical reasoning and a tiny little bit FileMaker 8O:D

Link to post
  • 0

In total it maybe took about an hour of my time and I can use this function for my own projects, so you're welcome :D

Right now I am translating this function in english, french and german, to publish it on my blog

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...