|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
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
|
Téléchargements
Logiciels à télécharger sur le même thème :
|