Page 1 of 1

Searching my old NumLetras function...

Posted: Tue Jul 13, 2004 5:38 pm
by Manolo
I have lost my NumLetras (Transform numbers to equivalent spanish words).
My old hard disk is damaged and I do not have a copy.
The Pauls resources sitte is down. There it had a copy, but...

Can you helpme??

Thanks,
Manolo

Posted: Tue Jul 13, 2004 7:46 pm
by Num3
How much can you give me for it !?

Eheheh... :twisted:

85Mb of snippets and code collected over the past 2 years :P

Sorry but i worked it a bit for Portuguese, no major changes...

Code: Select all

;-Funcion para convertir numeros (digitos) a su equivalente
;-escrito. 
;-Autor: Manolo - vpardo@infonegocio.com
;-Revisado por: El_Choni

Dim SAL$(4)
Dim EXT$(34)    

DataSection
  Data.s "UM","DOIS","TRÊS","QUATRO","CINCO","SEIS","SETE","OITO","NOVE"
  Data.s "DEZ","ONZE","DOZE","TREZE","CATORZE","QUINZE","DEZASSEIS","VINTE"
  Data.s "VINTE","TRINTA","QUARENTA","CINQUENTA","SESSENTA","SETENTA","OITENTA","NOVENTA"
  Data.s "CEM","DUZENTOS","TREZENTOS","QUATROCENTOS","QUINHENTOS","SEIS","SETE","OITO","NOVE"
EndDataSection

For I=1 To 34
  Read EXT$(I)
Next

Procedure.s Descifra(VARIABLE$)
  Dim SAL$(4) 
  UD=0 : DC=0 : DU=0 : CT=0
  Select Len(VARIABLE$)
    Case 1
      UD = Val(Mid(VARIABLE$, 1, 1)) ;--Unidad
    Case 2
      DC = Val(Mid(VARIABLE$, 1, 1)) ;--Decena
      DU = Val(Mid(VARIABLE$, 1, 2)) ;--Decena + Unidad
      UD = Val(Mid(VARIABLE$, 2, 1)) ;--Unidad
    Case 3
      CT = Val(Mid(VARIABLE$, 1, 1)) ;--Centena
      DC = Val(Mid(VARIABLE$, 2, 1)) ;--Decena
      DU = Val(Mid(VARIABLE$, 2, 2)) ;--Decena + Unidad
      UD = Val(Mid(VARIABLE$, 3, 1)) ;--Unidad
  EndSelect 
  ;------------------------------------------------
  ;--Tratamiento de Centenas
  ;------------------------------------------------
  If VARIABLE$ = "100" 
    SAL$(1) = "CEM "
  Else
    If CT <>0
      If CT=1
        SAL$(1)= EXT$(CT+25)+" "
      Else 
        SAL$(1) = EXT$(CT+25)+"CENTOS "
      EndIf 
    EndIf 
  EndIf
  ;------------------------------------------------
  ;--Tratamiento de Decenas
  ;------------------------------------------------
  If DC <> 0 
    If DU => 10 And DU < 16 
      SAL$(2) = EXT$(DU)
    Else
      If DU=>16 And DU < 20
        SAL$(2) = EXT$(16)+EXT$(UD)
      Else
        If DC=2 
          If UD=0
            SAL$(2) = EXT$(CT+12)
          Else
            If UD<>1 
              SAL$(3)=EXT$(DC+16)+EXT$(UD)
            Else
              SAL$(3)= EXT$(DC+16)+EXT$(UD)+"O"
            EndIf
          EndIf
        Else
          If UD=0
            SAL$(3) = EXT$(DC+16)
          Else
            If UD<>1
              SAL$(3)= EXT$(DC+16)+" E "+EXT$(UD)
            Else
              SAL$(3)= EXT$(DC+16)+" E "+EXT$(UD)+"O"
            EndIf
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  ;-----------------------------------------------
  ;--Tratamiento de Unidades
  ;-----------------------------------------------
  If UD<>0 And DC=0 
    If UD=1 And Longitud<=3
      SAL$(4)=EXT$(UD)+"O"
    Else
      SAL$(4)=EXT$(UD) 
    EndIf
  EndIf        
  Descifrar$ = SAL$(1) + SAL$(2) + SAL$(3) + SAL$(4)
  ProcedureReturn Descifrar$                       
EndProcedure 

;----------------------------------------------
;--Composicion de la cifra final
;----------------------------------------------
Procedure.s Transforma(num.s)
  res = FindString(num,",",1)
  If res>0
    entero.s = Mid(num,1,res-1)
    Longitud = Len(entero)
    decimal.s = Mid(num,res+1,Len(num))
    resultado.s = "EUROS "+Descifra(decimal)+" CÊNTIMOS"
  Else
    entero.s=num
  EndIf
  For i = 1 To Len(entero)-3 Step 3 
    lon = lon+3
    letra.s = Mid(entero, Len(entero)-i-1, 3)
    resultado.s = Descifra(letra)+" "+resultado.s
    Select lon
      Case 3
        If Len(entero)>6 And Mid(entero, Len(entero)-5, 3)="000"
          resultado.s = " "+resultado.s
        Else
          resultado.s = " MIL "+resultado.s
        EndIf
      Case 6
        If Mid(entero, Len(entero)-i-2, 1)="1"
          resultado.s = "UM MILHÃO "+resultado.s
        Else
          resultado.s = " MILHÕES "+resultado.s
        EndIf
      Case 9
        resultado.s = " MIL "+resultado.s
    EndSelect 
  Next 
  dif = Len(entero)-lon
  If dif<>0 And lon>0
    If Mid(entero, 1, dif)="1" 
      ;resultado.s = "MIL "+resultado.s
    Else
      resultado.s = Descifra(Mid(entero, 1, dif))+resultado.s
    EndIf
  Else
   resultado.s = Descifra(Mid(entero, 1, dif))+" "+resultado.s
  EndIf
  ;MessageRequester("Resultado "+Str(lon), resultado.s, 0) 
  ProcedureReturn resultado.s
EndProcedure

numero.s = "7311,06"
salida.s = Transforma(numero)
MessageRequester("Resultado de: "+numero.s, salida.s, 0)

Posted: Tue Jul 13, 2004 8:54 pm
by Paul
Hi Manolo,

Just for the record, you emailed me June 27 and asked if I still had this file. I replied 5 minutes later and sent you the requested file.

Maybe check your spam settings to make sure legitimate email is not being blocked :)

Posted: Wed Jul 14, 2004 10:00 am
by Manolo
Thanks to Paul. Yes, spam problem.

Moito obrigado Num3.

In this moment I have my original function and another translate to portuguese language.

:) :)
Manolo

Posted: Wed Jul 14, 2004 5:27 pm
by Num3
LOL

Yeah, but in portuguese it works fine but some prefixes are missing on some combinations...

I never finished the complete translation and recoding for that :wink:

Example: One thounsand AND three....

Posted: Wed Jul 14, 2004 6:01 pm
by Manolo
Yeah, but in portuguese it works fine but some prefixes are missing on some combinations...

I never finished the complete translation and recoding for that

Example: One thounsand AND three....
Take one look. I make for two languages. I speak portuguese and I don't have problem for this. In the moment that I finish will post the full source here.

Regards,
Manolo