FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour No elimina espacios en blanco
Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
No elimina espacios en blanco
Posted: Tue Feb 03, 2015 02:41 PM
Buenas tardes,

alguien me puede indicar a que es debido que no elimine los espacios en blanco con ALLTRIM

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

 
    LOCAL m := 0
    LOCAL n := 0
    LOCAL s := ""
    LOCAL sInt := 0  
    LOCAL c := ""
    LOCAL k := 0
    LOCAL GenSerial := ""
    LOCAL ch := '888888'     
    LOCAL num := 0   
   
    GenSerial := ALLTRIM("MT" + SUBSTR(ch, 1, 1) + SUBSTR(ch, 6, 1))
    c := CHR(MOD(VAL(SUBSTR(ch, 4, 3)), 26) + 65)
    k := ASC(c)
    For m = 1 To 3
        For n = 1 To 2
            s := ""       
            c := CHR(MOD(VAL(ch) + k, 26) + 65)
            If n = 2 
                k := k + VAL(SUBSTR(ch, m + 2, 1))
                s := s + c
                GenSerial := ALLTRIM(GenSerial + s)
            End If
            k := ASC(c)
            num := k * VAL(SUBSTR(ch, m + 1, 1))            
            sInt := INT(MOD(num, 10))
            If sInt > 4 
                sInt := sInt - 5
            Else
                sInt := sInt + 5
            EndIf
            GenSerial := ALLTRIM(GenSerial + STR(sInt))
        ENDFOR
    ENDFOR
    MsgInfo(GenSerial)       
return nil


Muchas gracias.

Saludos
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: No elimina espacios en blanco
Posted: Tue Feb 03, 2015 03:02 PM
Felix, prueba asi
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

 
    LOCAL m := 0
    LOCAL n := 0
    LOCAL s := ""
    LOCAL sInt := 0  
    LOCAL c := ""
    LOCAL k := 0
    LOCAL GenSerial := ""
    LOCAL ch := '888888'     
    LOCAL num := 0   
   
    GenSerial := ALLTRIM("MT"+SUBSTR(ch, 1, 1)+SUBSTR(ch, 6, 1))
    c := CHR(MOD(VAL(SUBSTR(ch, 4, 3)), 26) + 65)
    k := ASC(c)
    For m = 1 To 3
        For n = 1 To 2
            s := ""       
            c := CHR(MOD(VAL(ch) + k, 26) + 65)
            If n = 2 
                k := k + VAL(SUBSTR(ch, m + 2, 1))
                s := s + c
                GenSerial := ALLTRIM(GenSerial) + AllTrim(s)
            End If
            k := ASC(c)
            num := k * VAL(SUBSTR(ch, m + 1, 1))            
            sInt := INT(MOD(num, 10))
            If sInt > 4 
                sInt := sInt - 5
            Else
                sInt := sInt + 5
            EndIf
            GenSerial := ALLTRIM(GenSerial) + AllTrim(STR(sInt))
        ENDFOR
    ENDFOR
    MsgInfo(GenSerial)       
return nil


Creo que un AllTrim equivale solo a un LTRIM( RTRIM( cadena )) pero no quita los espacios intermedios
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: No elimina espacios en blanco
Posted: Tue Feb 03, 2015 03:04 PM

alltrim(c) == ltrim(trim(c))

Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
Re: No elimina espacios en blanco
Posted: Tue Feb 03, 2015 03:08 PM

Cristobal,

perfecto :D

Muchas gracias a ambos (Cristobal,hmpaquito) por contestar.

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: No elimina espacios en blanco
Posted: Thu Feb 05, 2015 11:32 AM

Felix, has mirado esto?

viewtopic.php?f=3t=30053#p171391

&

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
Re: No elimina espacios en blanco
Posted: Thu Feb 05, 2015 12:04 PM

Cristobal,

ahora sí, gracias. Lo acabo de ver.

Muchas gracias.

Saludos

Continue the discussion