Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4297 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Please, could somebody explain how to solve my problem?

 

I have to write down the amount in words in Polish. I found a java code implementing this functionality. (see attached file slownie.java)

I want to use method: procKwotaSlownie
(double kwota)

I compiled the code and put slownie.jar in
conteiner field. I used SMLoadJar to register JAR.

I would like to use the method (
procKwotaSlownie). To this end I used EvaluateGrovy. Unfortunately I get only ERROR.

See attached the file with my example database (slownie.fmp12).

Thnk you in advance.

slownie.zip

Posted

This won't work as you envisage

You can do EvaluateGroovy ( "return new slownie()") but you cant do anything with that object

 

This can pretty much be done by a custom function too without recursion

If you can explain the rules for the three words you have for million then I can adapt this further..

 

/**
 * toWords(number)
 * 13_02_25 JR
 * v1.0
 * 
 * input: number up to 999 billion
 * return: amount in (currency) words
 * depends: <none>
 * BASED ON http://help.filemaker.com/app/answers/detail/a_id/2860/~/converting-numbers-to-words-or-numbers-to-text
 * 
 */

Let ( [
//swap these two to test
$$CONVERT = number ; 
//$$CONVERT = 987124765123 ; 
// translate as necessary then remove live lines below
//_hundreds = List ( "One Hundred "; "Two Hundred "; "Three Hundred "; "Four Hundred "; "Five Hundred "; "Six Hundred "; "Seven Hundred "; "Eight Hundred "; "Nine Hundred ");
//_teens = List ( "Ten "; "Eleven "; "Twelve "; "Thirteen "; "Fourteen "; "Fifteen "; "Sixteen "; "Seventeen "; "Eighteen "; "Nineteen ") ;
//_tens = List ( "Twenty "; "Thirty "; "Forty "; "Fifty "; "Sixty "; "Seventy "; "Eighty "; "Ninety ") ;
//_units = List ( "One "; "Two "; "Three "; "Four "; "Five "; "Six "; "Seven "; "Eight "; "Nine ") ;
//_currency = List ("dollars" ; "cents") ;
//_higher = List ( "Billion, " ; "Billion " ; "Million, " ; "Million " ;"Thousand, " ; "Thousand " ) ;
//_joinword = " and " ];
 _hundreds = List ( "Sto "; "Dwieście "; "Trzysta "; "Czterysta "; "Pięćset "; "Sześćset "; "Siedemset "; "Osiemset "; "Dziewięćset ");
 _teens = List ("Dziesięć "; "Jedenaście "; "Dwanaście "; "Trzynaście "; "Czternaście "; "Piętnaście "; "Szesnaście "; "Siedemnaście "; "Osiemnaście "; "Dziewiętnaście ") ;
 _tens = List ("Dwadzieścia "; "Trzydzieści "; "Czterdzieści "; "Pięćdziesiąt "; "Sześćdziesiąt "; "Siedemdziesiąt "; "Osiemdziesiąt "; "Dziewięćdziesiąt ") ;
 _units = List ("Jeden "; "Dwa "; "Trzy "; "Cztery "; "Pięć "; "Sześć "; "Siedem "; "Osiem "; "Dziewięć ") ;
 _currency = List ("zł " ; "game") ;
 _higher = List ( "Miliard, " ; "Miliard " ; "Milion, " ; "Milion " ;"Tysiąc, " ; "Tysiąc " ) ;
 _joinword = " and " ];
Case ( $$CONVERT  ≥ 1000000000000 ; "ERROR - too big" ;
GetValue( _hundreds ;(Int(Mod($$CONVERT;10^12) / 10^11) ) ) &
If(Int(Mod($$CONVERT;10^11) / 10^10) = 1;
GetValue( _teens ; (Int(Mod($$CONVERT;10^10) / 10^9) + 1 ) ) ;
GetValue( _tens ; (Int(Mod($$CONVERT;10^11) / 10^10) -1 ) ) &
GetValue( _units ; (Int(Mod($$CONVERT;10^10) / 10^9)   ) ) ) &
Case(Int(Mod($$CONVERT;10^12)/10^9) and Int(Mod($$CONVERT;10^9) / 10^3); GetValue( _higher ; 1 ); Int(Mod($$CONVERT;10^12)/10^9);GetValue( _higher ; 2 );"")
&
GetValue( _hundreds ;(Int(Mod($$CONVERT;10^9) / 10^8) ) ) &
If(Int(Mod($$CONVERT;10^8) / 10^7) = 1;
GetValue( _teens ; (Int(Mod($$CONVERT;10^7) / 10^6) + 1 ) ) ;
GetValue( _tens ; (Int(Mod($$CONVERT;10^8) / 10^7) -1 ) ) &
GetValue( _units ; (Int(Mod($$CONVERT;10^7) / 10^6)   ) ) ) &
Case(Int(Mod($$CONVERT;10^9)/10^6) and Int(Mod($$CONVERT;10^6) / 10^3); GetValue( _higher ; 3 ); Int(Mod($$CONVERT;10^9)/10^6); GetValue( _higher ; 4 );"")
&
GetValue( _hundreds ;(Int(Mod($$CONVERT;10^6) / 10^5) ) ) &
If(Int(Mod($$CONVERT;10^5) / 10^4) = 1;
GetValue( _teens ; (Int(Mod($$CONVERT;10^4) / 10^3) + 1 ) ) ;
GetValue( _tens ; (Int(Mod($$CONVERT;10^5) / 10^4) -1 ) ) &
GetValue( _units ; (Int(Mod($$CONVERT;10^4) / 10^3)   ) ) ) &
Case(Int(Mod($$CONVERT;10^6)/10^3) and Int(Mod($$CONVERT;10^3) / 10^0); GetValue( _higher ; 5 ); Int(Mod($$CONVERT;10^6)/10^3); GetValue( _higher ; 6 );"")
&
GetValue( _hundreds ;(Int(Mod($$CONVERT;10^3) / 100) ) ) &
If(Int(Mod($$CONVERT;100) / 10) = 1;
GetValue( _teens ; (Int(Mod($$CONVERT;10) ) + 1 ) ) ;
GetValue( _tens ; (Int(Mod($$CONVERT;100) / 10) -1 ) ) &
GetValue( _units ; (Int(Mod($$CONVERT;10))   ) ) ) &
Case(Int($$CONVERT) > 1; GetValue( _currency ; 1 ); Int($$CONVERT) = 1; GetValue( _currency ; 1 ); "")
&
If(Mod($$CONVERT; 1) and Int($$CONVERT); _joinword ;"") &
If(Mod(Int($$CONVERT*10); 10) = 1;
GetValue( _teens ; (Mod(Int($$CONVERT*100); 10) + 1 ) ) ;
GetValue( _tens ; (Mod(Int($$CONVERT*10); 10) -1 ) ) &
GetValue( _units ; (Mod(Int($$CONVERT*100); 10)   ) ) ) &
Case(Mod($$CONVERT; 1) > .01 ; GetValue( _currency ; 2 ); Mod($$CONVERT; 1) = .01 ; GetValue( _currency ; 2 );"")
) )
Posted

Thank you for your answer.

Of course, you are right. Custom Method is a better option, but I wanted to learn how to use my own Java classes.

Now I can identify my mistakes.

1. Methods must be public. I had only a public class.
2. The class must be in the package.
3. I used the SMLoadJAR correctly. But I wrongly wanted to use a Java method. In the first step an Import should be done.

Example:
RegisterGroovy (javamethod(parameter) ; „import package.class; class.method(parameter);”)


In Polish the numerals have different forms; example:


Jeden Tysiąc (One Thousand)
Dwa Tysiące (Two Thousand)
Pięć Tysięcy (Five Thousand)

Jeden Milion (One Milion)
Dwa Miliony (Two Milion)
Pięć Milionów (Five Milion)

This topic is 4297 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.