by Ramon Paredes » Mon Aug 13, 2007 5:48 pm
Usa la siguiente funcion :
//====================================
FUNCTION CONVERTIR(WNUMERO,FMONEDA)
//====================================
//Nota: wNumero es la cantidad en Numero a convertir
// fMoneda es el Tipo "Dolares","Euros" etc.
// El valor que devuelve es un texto
IF WNUMERO <= 0
FDESCRIP := 'VALOR 0 (NULO)'
RETURN FDESCRIP
ENDIF
Public vd1[9],vd2[9],vd3[9],vd4[9]
vd1[1] = 'UN'
vd1[2] = 'DOS'
vd1[3] = 'TRES'
vd1[4] = 'CUATRO'
vd1[5] = 'CINCO'
vd1[6] = 'SEIS'
vd1[7] = 'SIETE'
vd1[8] = 'OCHO'
vd1[9] = 'NUEVE'
vd2[1] = 'ONCE'
vd2[2] = 'DOCE'
vd2[3] = 'TRECE'
vd2[4] = 'CATORCE'
vd2[5] = 'QUINCE'
vd2[6] = 'DIECISEIS'
vd2[7] = 'DIECISIETE'
vd2[8] = 'DIECIOCHO'
vd2[9] = 'DIECINUEVE'
vd3[1] = 'DIEZ'
vd3[2] = 'VEINTE'
vd3[3] = 'TREINTA'
vd3[4] = 'CUARENTA'
vd3[5] = 'CINCUENTA'
vd3[6] = 'SESENTA'
vd3[7] = 'SETENTA'
vd3[8] = 'OCHENTA'
vd3[9] = 'NOVENTA'
vd4[1] = 'CIENTO'
vd4[2] = 'DOSCIENTOS'
vd4[3] = 'TRESCIENTOS'
vd4[4] = 'CUATROCIENTOS'
vd4[5] = 'QUINIENTOS'
vd4[6] = 'SEISCIENTOS'
vd4[7] = 'SETECIENTOS'
vd4[8] = 'OCHOCIENTOS'
vd4[9] = 'NOVECIENTOS'
F_CAR = STR(WNUMERO,12,2)
F_CENTAVO= SUBSTR(F_CAR,11,2)
F_CIEN = SUBSTR(F_CAR,7,3)
F_MILES = SUBSTR(F_CAR,4,3)
F_MILLON = SUBSTR(F_CAR,1,3)
fValor = f_millon
d_Millon = dame_des(fvalor)
IF LEN(ALLTRIM(d_Millon)) > 0
IF VAL(FVALOR) = 1
d_Millon = d_millon +' MILLON '
ELSE
d_Millon = d_millon +' MILLONES '
ENDIF
ENDIF
fValor = f_Miles
d_Miles = dame_des(fvalor)
IF LEN(ALLTRIM(d_Miles)) > 0
d_Miles = d_Miles +' MIL '
ENDIF
fValor = f_Cien
d_Cien = dame_des(fvalor)
*IF LEN(ALLTRIM(d_Cien)) > 0
*ENDIF
DCENTAVO = ''
IF VAL(F_Centavo) > 0
DCENTAVO = F_CENTAVO+'/100'
ENDIF
Do Case
** 1 1 1 **
Case Len(AllTrim(d_millon)) > 0 .and. len(alltrim(d_miles)) > 0 .and. len(alltrim(d_cien)) > 0
fDetval = AllTrim(d_millon) +' '+ AllTrim(d_Miles)+' '+AllTrim(d_Cien)+' '+FMONEDA
** 0 1 1 **
Case Len(AllTrim(d_millon)) = 0 .and. len(alltrim(d_miles)) > 0 .and. len(alltrim(d_cien)) > 0
fDetval = AllTrim(d_Miles)+' '+AllTrim(d_Cien)+' '+FMONEDA
** 0 0 1 **
Case Len(AllTrim(d_millon)) = 0 .and. len(alltrim(d_miles)) = 0 .and. len(alltrim(d_cien)) > 0
fDetval = AllTrim(d_Cien)+' '+FMONEDA
** 1 0 1 **
Case Len(AllTrim(d_millon)) > 0 .and. len(alltrim(d_miles)) = 0 .and. len(alltrim(d_cien)) > 0
fDetval = AllTrim(d_millon)+' '+AllTrim(d_Cien)+' '+FMONEDA
** 1 0 0 **
Case Len(AllTrim(d_millon)) > 0 .and. len(alltrim(d_miles)) = 0 .and. len(alltrim(d_cien)) = 0
fDetval = AllTrim(d_millon)+' '+FMONEDA
** 1 1 0 **
Case Len(AllTrim(d_millon)) > 0 .and. len(alltrim(d_miles)) > 0 .and. len(alltrim(d_cien)) = 0
fDetval = AllTrim(d_millon) +' '+ AllTrim(d_Miles)+' '+FMONEDA
** 0 1 0 **
Case Len(AllTrim(d_millon)) = 0 .and. len(alltrim(d_miles)) > 0 .and. len(alltrim(d_cien)) = 0
fDetval = AllTrim(d_Miles)+' '+FMONEDA
EndCase
If Len(AllTrim(dCentavo)) > 0
fDetVal = fDetVal + ' CON ' + dCentavo
Else
fDetVal = fDetVal + ' NETOS'
Endif
*@ 15,1 SAY FDETVAL
Return FDETVAL
FUNCTION DAME_DES
PARAMETER FVALSTR
PRIMER = VAL(SUBSTR(FVALSTR,1,1))
SEG_Y_TER = VAL(SUBSTR(FVALSTR,2,2))
SEGUNDO = VAL(SUBSTR(FVALSTR,2,1))
TERCER = VAL(SUBSTR(FVALSTR,3,1))
FDESCRIP =' '
IF PRIMER > 0
IF SEG_Y_TER = 0 .AND. PRIMER = 1
FDESCRIP = FDESCRIP+'CIEN'
ELSE
FDESCRIP = FDESCRIP+ VD4[PRIMER]
ENDIF
ENDIF
IF SEG_Y_TER > 10 .AND. SEG_Y_TER < 20
FDESCRIP = FDESCRIP+' '+VD2[TERCER]
ELSE
IF SEGUNDO > 0
FDESCRIP = FDESCRIP+' '+VD3[SEGUNDO]
ENDIF
IF TERCER > 0
IF SEGUNDO > 0
FDESCRIP = FDESCRIP+' Y '+VD1[TERCER]
ELSE
FDESCRIP = FDESCRIP+' '+VD1[TERCER]
ENDIF
ENDIF
ENDIF
RETURN FDESCRIP
Ramon Paredes
Managua, Nicaragua
... Desde la Tierra de lagos y Volcanes......