Alguien tiene una rutina para convertir
cifras a letras en ingles
1250 = one thousand two hundred an fifhty
Gracias
FUNCTION EXTENSO( PVALOR )
LOCAL TSTR := STRZERO(PVALOR,18,2)
LOCAL ACIFRA := {{'Trilhon','Trilhons'},;
{'Bilhon' ,'Bilhons'},;
{'Milhon' ,'Milhons'},;
{'Thousand' ,'Thousand'},;
{' ' ,' '},;
{'Cent','Cents'}}
LOCAL TX
LOCAL TEXTENSO := ' '
LOCAL TSUBS := ' '
LOCAL TCENTAVOS:= VAL(SUBSTR(TSTR,17))
IF (PVALOR>0)
IF (TCENTAVOS>0)
TEXTENSO:=EXTCEM(STRZERO(TCENTAVOS,3))+;
ACIFRA[6][IIF(TCENTAVOS=1,1,2)]
ENDIF
IF (INT(PVALOR)>0)
TEXTENSO:=IIF(INT(PVALOR)=1,'Real','Reals')+IIF(TCENTAVOS>0,' and ','')+TEXTENSO
ENDIF
FOR TX := 5 TO 1 STEP -1
IF (VAL(TSUBS:=SUBSTR(TSTR,(TX*3)-2,3))>0)
TEXTENSO:=EXTCEM(TSUBS)+ACIFRA[TX][IIF(VAL(TSUBS)=1,1,2)]+' '+TEXTENSO
ENDIF
NEXT TX
ENDIF
RETURN(STRIPDOUBLE(TEXTENSO,' '))
FUNCTION EXTCEM(PCEM)
LOCAL AVAL := {VAL(SUBSTR(PCEM,1,1)),;
VAL(SUBSTR(PCEM,2,1)),;
VAL(SUBSTR(PCEM,3,1))}
LOCAL TTAM,TEXT := ''
LOCAL ACENT := { 'one hundred','two hundred','Three hundred','Four hundred','Five hundred','Six hundred','Seven hundred','Eight hundred','Nine hundred'}
LOCAL AVINT := { 'Eleven','Twelve','Thirteen','Fourteen','Fifiteen','Sixteen','Seventeen','Eighteen','Nineteen' }
LOCAL ADEZ := { 'Ten','Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety' }
LOCAL AUNIT := { 'One','Two','Three','Four','Five','Six','Seven','Eight','Nine' }
IF (VAL(PCEM)>0)
IF (VAL(PCEM)==100)
TEXT := 'Hundred '
ELSE
IF (AVAL[1]>0)
TEXT := ACENT[AVAL[1]]+IIF((AVAL[2]+AVAL[3]>0),' and ',' ')
ENDIF
IF (AVAL[2]=1).AND.(AVAL[3]>0)
TEXT := TEXT + ' '+AVINT[AVAL[3]]
ELSE
IF (AVAL[2]>0)
TEXT := TEXT+' '+ADEZ[AVAL[2]]+IIF(AVAL[3]>0,' and ','')
ENDIF
TEXT := TEXT+IIF(AVAL[3]>0,' '+AUNIT[AVAL[3]],' ')
ENDIF
ENDIF
ENDIF
RETURN(TEXT := TEXT+' ')
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 90 guests