Shopping Cart

Search:

Signup

Contact

FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

# FileMaker Pro Custom Functions

NumeroATesto ( numero ; scala )

Rate this function:

Discuss this Custom Function

Federico Severin, Federico Severin
http://ilseve.altervista.org

Re-writes amounts in words in Italian language (3/3)

Sample Input:
 NumeroATesto ( 321 , 0 ) NumeroATesto ( 321 , 3 ) NumeroATesto ( 321 , 6 )
Sample Output:
 trecentoventuno trecentoventunomila trecentoventunomilioni

Then copy & paste into FileMaker Advanced's Edit Custom Function window.

## Description:

// IMPORTANT: must be used with ImportoInLettere and ImportoInLettereRicorsiva

// Given a 3 cipher number, this function spells it in letters, in italian
// It takes maximum 3 cipher numbers (see ImportoInLettereRicorsiva)
// Parameter "scala" tell the function if the number represents "unità", "migliaia", "milioni" or "miliardi" (units, thousands, millions and billions/milliards)
// More precisely, scala represents the number of digits already read, hence from the actual position to the decimal comma

// If the number is 0, no need to write letters
If ( numero = 0 ; "" ;

// Else, let's declare some variables
Dichiara (

[
// c represents hundreds digit, d the tens, u the units (indipendently from the scale)
c = Tronca ( numero / 100 ; 0 );
d = Tronca ( ( numero - c * 100 ) / 10 ; 0 );
u = numero - c * 100 - d * 10;

// Define the correct suffix, accordingly to the scala
suffisso = Casi (
scala = 0 ; "";
scala = 3 ; If ( numero = 1 ; "mille" ; "mila" );
scala = 6 ; If ( numero = 1 ; "milione" ; "milioni" );
scala = 9 ; If ( numero = 1 ; "miliardo" ; "miliardi" ) );

// Translate in words the hundreds digit
c_parola = Casi (
c = 1; "";
c = 2; "due";
c = 3; "tre";
c = 4; "quattro";
c = 5; "cinque";
c = 6; "sei";
c = 7; "sette";
c = 8; "otto";
c = 9; "nove" );

// Translate in words the tens digit.
// While number from 20 to 99 have a regular linguistical schema, it's not the same for numbers from 10 to 19.
// So, if tens digit = 1, you must translate manually the number, as can be seen in the Else part of the If block.
d_parola = If ( d > 1;
Casi (
d = 2; "venti";
d = 3; "trenta";
d = 4; "quaranta";
d = 5; "cinquanta";
d = 6; "sessanta";
d = 7; "settanta";
d = 8; "ottanta";
d = 9; "novanta"
);
Casi (
u = 0; "dieci";
u = 1; "undici";
u = 2; "dodici";
u = 3; "tredici";
u = 4; "quattordici";
u = 5; "quindici";
u = 6; "sedici";
u = 7; "diciassette";
u = 8; "diciotto";
u = 9; "diciannove"
)
);

// Translate in words the unit digit.
// If d = 1 the number enters in the particular schema treated above.
// If u = 0, you don't need to write anything.
u_parola = If ( d = 1 or u = 0; "" ; Casi (

u = 1; Casi ( scala = 0 ; "uno" ; scala = 3; ""; "un" ); // if the function is processing simple units, must write "uno"; one thousand in italian is "mille", so don't write anything; for all other cases: "un"
u = 2; "due";
u = 3; "tre";
u = 4; "quattro";
u = 5; "cinque";
u = 6; "sei";
u = 7; "sette";
u = 8; "otto";
u = 9; "nove" )
)
]; // End of variable declaration

// Now let's define the formula to be evaluated.
// We aim to write, in order, hundreds, tens and units,
// but pay attention to tens:
// if d >=2, then can write d_parola & u_parola, but if u=1 d_parola losts last letter (e.g.: 20 -> "venti", 21 -> "ventuno", 22 -> "ventidue");
// if d = 1, we are in the particular schema of numbers from 10 to 19, totally translated in d_parola;
// if d = 0, there are no tens, so just write units.
// Eventually, add the suffix determined by scala.
If ( c > 0 ; c_parola & "cento" ; "" ) & Casi (
d ≥ 2 ; If ( u = 1 ; Sinistra ( d_parola ; Lunghezza ( d_parola ) - 1 ) & u_parola ; d_parola & u_parola );
d = 1 ; d_parola;
d = 0 ; u_parola ) & suffisso

) // End of Let function (Dichiara)
) // End of beginning If

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it