Código de Clipper/FiveWin - Convertir cantidades a cadena

Versión 1
estrellaestrellaestrellaestrellaestrella(4)

Publicado el 23 de Septiembre del 2003gráfica de visualizaciones de la versión: Versión 1
12.488 visualizaciones desde el 23 de Septiembre del 2003
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

Si alguno de los archivos de descarga no funciona, comentanos aquí el error.




Comentarios sobre la versión: Versión 1 (4)

11 de Octubre del 2003
estrellaestrellaestrellaestrellaestrella
El codigo incluido aqui por Bayron, ha procesado mis cantidades muy bien hasta ahora, especialmente en español, donde muestra el verdadero resultado de los numeros en letras: no dice Uno pesos, como otros programas que yo he usado, sino correctamente Un peso, Dos pesos, etc. Solamente que los numeros que retorna pueden ir hasta 9,999,999 lo que hace que la variable sea muy grande, pero puede ser modificada facilmente hasta por un programador principiante... La parte dificil ya esta hecha... Gracias Bayron...
Responder
19 de Febrero del 2007
estrellaestrellaestrellaestrellaestrella
Esta muy bien el codigo , solo hice unos cuantos cambios para que funcionara en FoxPro y listo =) , me ahorro muchisimo tiempo de programacion y prueba (aparte de que no tenia idea de como generar la cadena).
Responder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
* * *
* FUNCION...: Num2Car
* PARAMETRO.: Variable <Numerica>
* PROPOSITO.: Devuelve <Cadena> de numero deletrado
* Autor.....: Rafael Castillo Rosas
* * *
FUNCTION Num2Car
Parameters numero
Unidad='UN     DOS    TRES   CUATRO CINCO  SEIS   SIETE  OCHO   '
Unidad=Unidad+'NUEVE  DIEZ   ONCE   DOCE   TRECE  CATORCEQUINCE '
Decena='DIE      VEINT    TREINTA  CUARENTA CINCUENTASESENTA  '
Decena=Decena+'SETENTA  OCHENTA  NOVENTA'
Centena='CIEN         DOSCIENTOS   TRESCIENTOS  CUATROCIENTOSQUINIENTOS   '
Centena=Centena+'SEISCIENTOS  SETECIENTOS  OCHOCIENTOS  NOVECIENTOS  '
Cifra='BILLON      MIL         MILLON      MIL                     '
Cifra=Cifra +'            '
Cant=Tran(numero,'999999999999999.99')
CANTI=Subs(cant,1,18)
num=1
Leyenda=''
Do While Num#7
  Store ' ' To Cc,Dd,Uu,Ca
  CantCent=Substr(Cant,(((Num-1)*3)+1),3)
  C=SubStr(CantCent,1,1)
  D=SubStr(CantCent,2,1)
  U=SubStr(CantCent,3,1)
  Condicion=Iif(Num=6,"Num=6","Val(CantCent)#0")
  If &Condicion
    If Val(C)#0
      If Val(C)=1
	cc=Iif(Val(C+D+U)=100,' ','TO ')
      Endif
      leyenda=Leyenda+Trim(SubStr(Centena,((Val(C)-1)*13)+1,13))+cc
    Endif
    If C='.' &&.and. Val(D+U)#0
	leyenda='('+Alltrim(leyenda)+' PESOS CON '+D+U+'/100 M.N.)'
	num=num+1
	Loop
    Endif
    If Val(D)#0
      If Val(D+U)>15
	If Val(D)<3
	  If Val(D)=2
	    Dd=Iif(Val(U)=0,'E','I')
	  Else
	    Dd='CI'
	  Endif
	Else
	  Dd=Iif(Val(U)=0,' ',' Y ')
	Endif
	leyenda=Leyenda+Trim(SubStr(Decena,((Val(D)-1)*9)+1,9))+Dd
	If Val(u)#0
	  leyenda=Leyenda+Trim(SubStr(Unidad,((Val(U)-1)*7)+1,7))+Uu
	Endif
      Else
	leyenda=Leyenda+Trim(SubStr(Unidad,((Val(D+U)-1)*7)+1,7))+' '
      Endif
    Endif
    If Val(D+U)<10
      If Val(D+U)#0
	leyenda=Leyenda+Trim(SubStr(Unidad,((Val(U)-1)*7)+1,7))+Uu
      Endif
    Endif
    If Val(C+D+U)#1
      Ca=Iif((Num=1 .or. Num=3),'ES ',' ')
    Endif
    Leyenda=Leyenda+Trim(SubStr(Cifra,((Num-1)*12)+1,12))+Ca
    If Rtrim(leyenda)=='UN'
      leyenda='UNO'
    Endif
  Endif
  Num=Num+1
Enddo
RETURN Leyenda
Responder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
* Program.: NUMWORDS.PRG
* Author..: Stephen Kurasch, based on Nmbrword.PRG by Tom Rettig
* Date....: June 10, 1985
* Notice..: Copyright 1985, Ashton-Tate
* Notes...: Converts numeric amounts to words
*           Called from CHECK.PRG with a parameter mamt
 
PARAMETERS mamt
 
* Initialize memory variables
camt=""
STORE "     ONE  TWO  THREEFOUR FIVE SIX  SEVENEIGHTNINE " TO ones
STORE "TEN      ELEVEN   TWELVE   THIRTEEN FOURTEEN FIFTEEN  SIXTEEN  "+;
      "SEVENTEENEIGHTEEN NINETEEN " TO teen
STORE "TWENTY THIRTY FORTY  FIFTY  SIXTY  SEVENTYEIGHTY NINETY" TO tens
 
* Store whole dollar amount to a string
cnum=LEFT(STR(mamt,9,2),6)
 
* check hundreds of thousands
IF LEFT(cnum,1)>" "
   camt=RTRIM(SUBSTR(ones,VAL(LEFT(cnum,1))*5+1,5))+" HUNDRED "
ENDIF
 
* check tens of thousands and thousands
DO CASE
   CASE SUBSTR(cnum,2,1)>"1"
      camt=camt+RTRIM(SUBSTR(tens,VAL(SUBSTR(cnum,2,1))*7-13,7))
      IF SUBSTR(cnum,3,1)>"0"
         camt=camt+"-"+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,3,1))*5+1,5))
      ENDIF
      camt=camt+" THOUSAND "
 
   CASE SUBSTR(cnum,2,1)="1"
      camt=camt+RTRIM(SUBSTR(teen,VAL(SUBSTR(cnum,3,1))*9+1,9))+" THOUSAND "
 
   CASE SUBSTR(cnum,2,2)="00"
      camt=camt+"THOUSAND "
 
   CASE SUBSTR(cnum,3,1)>" "
      camt=camt+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,3,1))*5+1,5))+" THOUSAND "
ENDCASE
 
* check hundreds
IF SUBSTR(cnum,4,1)>"0"
   camt=camt+RTRIM(SUBSTR(ones,VAL(SUBSTR(cnum,4,1))*5+1,5))+" HUNDRED "
ENDIF
 
* check tens and ones
DO CASE
   CASE SUBSTR(cnum,5,1)>"1"
      camt=camt+RTRIM(SUBSTR(tens,VAL(SUBSTR(cnum,5,1))*7-13,7))
      IF RIGHT(cnum,1)>"0"
         camt=camt+"-"+RTRIM(SUBSTR(ones,VAL(RIGHT(cnum,1))*5+1,5))
      ENDIF
 
   CASE SUBSTR(cnum,5,1)="1"
      camt=camt+RTRIM(SUBSTR(teen,VAL(RIGHT(cnum,1))*9+1,9))
 
   CASE RIGHT(cnum,2)=" 0"
      camt="ZERO"
 
   OTHERWISE
      camt=camt+RTRIM(SUBSTR(ones,VAL(RIGHT(cnum,1))*5+1,5))
ENDCASE
 
* Convert decimal places to a string containing cents amount
cents=RIGHT(STR(mamt,9,2),2)
camt=RTRIM(camt)+" AND "+cents+"/100 DOLLARS"
 
IF tamt > 0
   @ 11,4 SAY SPACE(74)
   @ 12,10 SAY SPACE(30)
ENDIF
 
string = SPACE(62)
length = LEN(camt)
 
* if length is greater than 75, the words will have to be
*    broken up so that it will fit on the check
IF length > 75
   counter = 74
 
   DO WHILE .NOT. SUBSTR(camt,counter,1) $ " -"
      counter = counter - 1
   ENDDO
 
   * divide the word into two parts and display
   word1 = LEFT(camt,counter)+LEFT(string,75-counter)
   word2 = SUBSTR(camt,counter+1,length-counter)
   @ 11,4 SAY word1
   @ 12,10 SAY word2
 
ELSE
   * else word is less than or equal to 75 characters
   word1 = camt + LEFT(string,75-length)
   @ 11,4 SAY word1
ENDIF
 
RETURN
* Eof: Numwords.prg
Responder

Comentar la versión: Versión 1

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s803