Accueil > > > FONCTION DE CONVERSION DE CHIFFRES EN LETTRES
FONCTION DE CONVERSION DE CHIFFRES EN LETTRES
Information sur la source
Description
Cette fonction permet de convertir des chiffres en lettres ex : 1250 donne mille deux cent cinquante paramètre chiffre le chiffre à convertir monai la monaie associée. Si ce paramètre est vide, la fonction va chercher dans la base de registre la monnaie déclarée pour fox pro Pour l'histoire , cette fonction a été écrite en commun avec Michel qui nous rejoindra un jour j'espère sur atout fox. Bonne prog à tous Eric
Source
- function convlettre(chiffre,monai)
- local i,t
- local cChif
- local tChif
- local aniveau,texte,arangs,amil,aexcep,avcex
- if vartype(m.monai)="L"
- m.monai=liregaumeric("CurrSymbol")
- *!* monai="Euros"
- endif
-
- m.chiffre=iif(vartype(m.chiffre)=="C",val(m.chiffre),m.chiffre)
- m.chiffre=iif(vartype(m.chiffre)=="N".and. m.chiffre<0,m.chiffre*-1,m.chiffre)
-
-
- m.cChif=ltrim(transform(round(iif(vartype(m.chiffre)=="C",val(m.chiffre),m.chiffre),2),"999999999999999.99"))
- m.tChif=left(m.cChif,len(m.cChif)-3)
- dimension aniveau[1,2],amil[5]
- dimension arangs[9,3],aexcep[12,2],avcex[2,2]
- m.texte=""
- arangs[1,1]="cent "
- arangs[1,2]="dix "
- arangs[1,3]="un "
- arangs[2,1]="deux cents "
- arangs[2,2]="vingt "
- arangs[2,3]="deux "
- arangs[3,1]="trois cents "
- arangs[3,2]="trente "
- arangs[3,3]="trois "
- arangs[4,1]="quatre cents "
- arangs[4,2]="quarante "
- arangs[4,3]="quatre "
- arangs[5,1]="cinq cents "
- arangs[5,2]="cinquante "
- arangs[5,3]="cinq "
- arangs[6,1]="six cents "
- arangs[6,2]="soixante "
- arangs[6,3]="six "
- arangs[7,1]="sept cents "
- arangs[7,2]="soixante dix "
- arangs[7,3]="sept "
- arangs[8,1]="huit cents "
- arangs[8,2]="quatre vingts "
- arangs[8,3]="huit "
- arangs[9,1]="neuf cents "
- arangs[9,2]="quatre vingt dix "
- arangs[9,3]="neuf "
- amil[1]=monai
- amil[2]="mille"
- amil[3]="million"
- amil[4]="milliard"
- amil[5]="billion"
- aexcep[1,1]="dix un"
- aexcep[1,2]="onze"
- aexcep[2,1]="dix deux"
- aexcep[2,2]="douze"
- aexcep[3,1]="dix trois"
- aexcep[3,2]="treize"
- aexcep[4,1]="dix quatre"
- aexcep[4,2]="quatorze"
- aexcep[5,1]="dix cinq"
- aexcep[5,2]="quinze"
- aexcep[6,1]="dix six"
- aexcep[6,2]="seize"
- aexcep[7,1]="vingt un"
- aexcep[7,2]="vingt et un"
- aexcep[8,1]="trente un"
- aexcep[8,2]="trente et un"
- aexcep[9,1]="quarante un"
- aexcep[9,2]="quarante et un"
- aexcep[10,1]="cinquante un"
- aexcep[10,2]="cinquante et un"
- aexcep[11,1]="soixante un"
- aexcep[11,2]="soixante et un"
- aexcep[12,1]="soixante onze"
- aexcep[12,2]="soixante et onze"
- avcex[1,1]="vingts"
- avcex[1,2]="vingt"
- avcex[2,1]="cents"
- avcex[2,2]="cent"
- i=1
- do while.t.
- if i=1
- aniveau[1,1]=right(m.tChif,iif(len(m.tChif)>2,3,len(m.tChif)))
- aniveau[1,2]=""
- else
- dimension aniveau[i,2]
- aniveau[i,1]=right(m.tChif,iif(len(m.tChif)>2,3,len(m.tChif)))
- aniveau[i,2]=""
- endif
-
- m.i=m.i+1
- m.tChif=left(m.tchif,len(m.tchif)-3)
- if len(m.tchif)==0
- exit
- endif
- enddo
-
- for i=1 to alen(aniveau,1)
- aniveau[i,1]=iif(len(aniveau[i,1])<3,padl(aniveau[i,1],3,"0"),aniveau[i,1])
- for m.t=1 to len(aniveau[i,1])
- if substr(aniveau[i,1],t,1)<>"0"
- aniveau[i,2]=aniveau[i,2]+arangs[val(substr(aniveau[i,1],m.t,1)),m.t]
- endif
- next
- if m.i>1
-
- aniveau[i,2]=aniveau[i,2]+amil[i]+iif(val(aniveau[i,1])>1.and.i>2,"s "," ")
- endif
- next
-
- for i=alen(aniveau,1) to 1 step -1
- m.texte=m.texte+aniveau[i,2]
- next
- * traite les exceptions
- for i=1 to 12
- m.texte=strtran(m.texte,aexcep[i,1],aexcep[i,2])
- next i
-
-
- *// enl¦ve un mille
- m.texte=iif(left(m.texte,8)="un mille",right(m.texte,len(m.texte)-3),m.texte)
- *// vingt et cent
- for m.i=1 to 2
- m.texte=strtran(left(m.texte,len(m.texte)-4),avcex[i,1],avcex[i,2])+right(m.texte,4)
- next
-
- * aeval(avcex,{|a|texte:=strtran(left(texte,len(texte)-4),a[1],a[2])+right(texte,4)})
- m.texte=m.texte+iif(len(alltrim(m.texte))>2,;
- amil[1]+"s ",;
- iif(!empty(texte),;
- amil[1]+" ","zéro "+amil[1]+" "))
- m.texte=m.texte+iif(val(right(m.cChif,2))>0,iif(val(right(m.cChif,2))>1,right(m.cChif,2)+" centimes",right(m.cChif,2)+" centime"),"")
- return m.texte
-
-
-
- function liregaumeric
-
- PARAMETERS titi
-
-
- LOCAL oReg,regfile
- LOCAL cOptionValue,cOptionName,nErrNum,retour
-
- if vartype(m.titi)#"C"
- m.retour= ""
- else
-
- m.regfile = "registry.fxp"
- IF !FILE(m.regfile)
- MESSAGEBOX(C_NOREGFILE_LOC )
- RETURN
- ENDIF
-
- oReg = NewObject("FoxReg",m.regfile)
- cOptionValue = ""
- cOptionName = titi
- m.nErrNum = oReg.GetFoxOption(m.cOptionName,@cOptionValue)
- retour=coptionvalue
- endif
- return m.retour
-
-
function convlettre(chiffre,monai)
local i,t
local cChif
local tChif
local aniveau,texte,arangs,amil,aexcep,avcex
if vartype(m.monai)="L"
m.monai=liregaumeric("CurrSymbol")
*!* monai="Euros"
endif
m.chiffre=iif(vartype(m.chiffre)=="C",val(m.chiffre),m.chiffre)
m.chiffre=iif(vartype(m.chiffre)=="N".and. m.chiffre<0,m.chiffre*-1,m.chiffre)
m.cChif=ltrim(transform(round(iif(vartype(m.chiffre)=="C",val(m.chiffre),m.chiffre),2),"999999999999999.99"))
m.tChif=left(m.cChif,len(m.cChif)-3)
dimension aniveau[1,2],amil[5]
dimension arangs[9,3],aexcep[12,2],avcex[2,2]
m.texte=""
arangs[1,1]="cent "
arangs[1,2]="dix "
arangs[1,3]="un "
arangs[2,1]="deux cents "
arangs[2,2]="vingt "
arangs[2,3]="deux "
arangs[3,1]="trois cents "
arangs[3,2]="trente "
arangs[3,3]="trois "
arangs[4,1]="quatre cents "
arangs[4,2]="quarante "
arangs[4,3]="quatre "
arangs[5,1]="cinq cents "
arangs[5,2]="cinquante "
arangs[5,3]="cinq "
arangs[6,1]="six cents "
arangs[6,2]="soixante "
arangs[6,3]="six "
arangs[7,1]="sept cents "
arangs[7,2]="soixante dix "
arangs[7,3]="sept "
arangs[8,1]="huit cents "
arangs[8,2]="quatre vingts "
arangs[8,3]="huit "
arangs[9,1]="neuf cents "
arangs[9,2]="quatre vingt dix "
arangs[9,3]="neuf "
amil[1]=monai
amil[2]="mille"
amil[3]="million"
amil[4]="milliard"
amil[5]="billion"
aexcep[1,1]="dix un"
aexcep[1,2]="onze"
aexcep[2,1]="dix deux"
aexcep[2,2]="douze"
aexcep[3,1]="dix trois"
aexcep[3,2]="treize"
aexcep[4,1]="dix quatre"
aexcep[4,2]="quatorze"
aexcep[5,1]="dix cinq"
aexcep[5,2]="quinze"
aexcep[6,1]="dix six"
aexcep[6,2]="seize"
aexcep[7,1]="vingt un"
aexcep[7,2]="vingt et un"
aexcep[8,1]="trente un"
aexcep[8,2]="trente et un"
aexcep[9,1]="quarante un"
aexcep[9,2]="quarante et un"
aexcep[10,1]="cinquante un"
aexcep[10,2]="cinquante et un"
aexcep[11,1]="soixante un"
aexcep[11,2]="soixante et un"
aexcep[12,1]="soixante onze"
aexcep[12,2]="soixante et onze"
avcex[1,1]="vingts"
avcex[1,2]="vingt"
avcex[2,1]="cents"
avcex[2,2]="cent"
i=1
do while.t.
if i=1
aniveau[1,1]=right(m.tChif,iif(len(m.tChif)>2,3,len(m.tChif)))
aniveau[1,2]=""
else
dimension aniveau[i,2]
aniveau[i,1]=right(m.tChif,iif(len(m.tChif)>2,3,len(m.tChif)))
aniveau[i,2]=""
endif
m.i=m.i+1
m.tChif=left(m.tchif,len(m.tchif)-3)
if len(m.tchif)==0
exit
endif
enddo
for i=1 to alen(aniveau,1)
aniveau[i,1]=iif(len(aniveau[i,1])<3,padl(aniveau[i,1],3,"0"),aniveau[i,1])
for m.t=1 to len(aniveau[i,1])
if substr(aniveau[i,1],t,1)<>"0"
aniveau[i,2]=aniveau[i,2]+arangs[val(substr(aniveau[i,1],m.t,1)),m.t]
endif
next
if m.i>1
aniveau[i,2]=aniveau[i,2]+amil[i]+iif(val(aniveau[i,1])>1.and.i>2,"s "," ")
endif
next
for i=alen(aniveau,1) to 1 step -1
m.texte=m.texte+aniveau[i,2]
next
* traite les exceptions
for i=1 to 12
m.texte=strtran(m.texte,aexcep[i,1],aexcep[i,2])
next i
*// enl¦ve un mille
m.texte=iif(left(m.texte,8)="un mille",right(m.texte,len(m.texte)-3),m.texte)
*// vingt et cent
for m.i=1 to 2
m.texte=strtran(left(m.texte,len(m.texte)-4),avcex[i,1],avcex[i,2])+right(m.texte,4)
next
* aeval(avcex,{|a|texte:=strtran(left(texte,len(texte)-4),a[1],a[2])+right(texte,4)})
m.texte=m.texte+iif(len(alltrim(m.texte))>2,;
amil[1]+"s ",;
iif(!empty(texte),;
amil[1]+" ","zéro "+amil[1]+" "))
m.texte=m.texte+iif(val(right(m.cChif,2))>0,iif(val(right(m.cChif,2))>1,right(m.cChif,2)+" centimes",right(m.cChif,2)+" centime"),"")
return m.texte
function liregaumeric
PARAMETERS titi
LOCAL oReg,regfile
LOCAL cOptionValue,cOptionName,nErrNum,retour
if vartype(m.titi)#"C"
m.retour= ""
else
m.regfile = "registry.fxp"
IF !FILE(m.regfile)
MESSAGEBOX(C_NOREGFILE_LOC )
RETURN
ENDIF
oReg = NewObject("FoxReg",m.regfile)
cOptionValue = ""
cOptionName = titi
m.nErrNum = oReg.GetFoxOption(m.cOptionName,@cOptionValue)
retour=coptionvalue
endif
return m.retour
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
problème d'arrondisement de chiffre [ par jee0404 ]
bonjour, Je suis entraint de migré un programme en foxpro 2.6 vers la version8.
conversion date [ par ducker88 ]
Bonjour,Existe t'il une fonction foxpro qui permette de transformer une date du format JJ/MM/AAAA vers le format AAAA-MM-JJ ?duck88
formation d'une feuille excel [ par jee0404 ]
Bonjour, Il faut que je programme un module qui génére une feu
Besoin d'aide pour une recherche [ par zxr_stinger ]
Bonjour à tousJ'ai besoin de faire un "set filter to " dans mon champ "nom" uniquement sur la première lettre de l'enregistrement.Pour être plus clair
|
Derniers Blogs
KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg SOIRéE ALT.NET MAI - 3 PRéSENTATIONSSOIRéE ALT.NET MAI - 3 PRéSENTATIONS par Rui
Juste pour rappel, la prochaine soirée ALT.NET Paris aura lieu le 24 Mai
Nous initions un nouveau format, à savoir plus de sessions dans un format plus court. Le but est de voir plus de choses dans un format plus concis et créer ainsi une dynamique...
Cliquez pour lire la suite de l'article par Rui
Logiciels
974 Application Server (12.2.4.0)974 APPLICATION SERVER (12.2.4.0)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP mySongBook Player (1.0.0)MYSONGBOOK PLAYER (1.0.0)mySongBook Player est un logiciel gratuit permettant l'accès à une archive de tablatures/partitio... Cliquez pour télécharger mySongBook Player
|