Code : Tout sélectionner
Macro LittD(x)
Litt(x + 20)
EndMacro
Macro LittM(x)
Litt(x + 30)
EndMacro
Declare.s Liter(n.l)
Declare.s BigLiter(n.l)
DataSection
Data.s "", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit" ,"neuf"
Data.s "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept"
Data.s "dix-huit", "dix-neuf"
Data.s "", "", "vingt", "trente", "quarante", "cinquante"
Data.s "soixante", "soixante", "quatre-vingt", "quatre-vingt"
Data.s "cent", "mille"
Data.s "et"
EndDataSection
Dim Litt.s(35)
For i = 0 To 32
Read Litt(i)
Next
n$ = InputRequester("On te demande", "Donne un chiffre entre 0 et 999999", "")
n = Int(Val(n$) )
MessageRequester(N$, BigLiter(n) + "!")
End
Procedure.s BigLiter(n.l)
Shared Litt()
If n > 999
tA = n % 1000
If tA = 0
Result$ = LittM(1)
Else
Result$ = LittM(1) + "-" + Liter(tA)
EndIf
mll = (n % 1000000) - (tA)
If mll > 1000
Result$ = Liter(mll / 1000) + "-" + Result$
EndIf
Else
Result$ = Liter(n)
EndIf
ProcedureReturn Result$
EndProcedure
Procedure.s Liter(n.l)
Shared Litt()
Result$ = ""
If n < 0
Pref$ = "moins "
n = Abs(n)
Else
Pref$ = ""
EndIf
If n = 0
Result$ = "zéro"
Else
d = n % 10
v = n % 20
c = ((n % 100) - d) / 10
e = ((n % 100) - v) / 10
If (c > 1) And (c < 8) And (d = 1)
et$ = "et-"
Else
et$ = ""
EndIf
If ((c = 3) Or (c = 4) ) Or (c = 5)
A$ = LittD(c)
B$ = Litt(d)
Else
A$ = LittD(e)
B$ = Litt(v)
EndIf
union$ = ""
If (A$ <> "") And (B$ <> "")
union$ = "-"
Else
union$ = ""
EndIf
Result$ = A$ + union$ + et$ + B$
If n > 99
ct = ((n % 1000) - (n % 100) ) / 100
If Result$ = ""
Suff$ = ""
Else
Suff$ = "-" + Result$
EndIf
If ct = 1
Result$ = LittM(0) + Suff$
Else
Result$ = Litt(ct) + "-" + LittM(0) + Suff$
EndIf
EndIf
EndIf
Result$ = Pref$ + Result$
ProcedureReturn result$
EndProcedure