No elimina espacios en blanco

No elimina espacios en blanco

Postby Baxajaun » Tue Feb 03, 2015 2:41 pm

Buenas tardes,

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

Code: Select all  Expand view
#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
User avatar
Baxajaun
 
Posts: 961
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: No elimina espacios en blanco

Postby cnavarro » Tue Feb 03, 2015 3:02 pm

Felix, prueba asi
Code: Select all  Expand view

#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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: No elimina espacios en blanco

Postby hmpaquito » Tue Feb 03, 2015 3:04 pm

alltrim(c) == ltrim(trim(c))
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: No elimina espacios en blanco

Postby Baxajaun » Tue Feb 03, 2015 3:08 pm

Cristobal,

perfecto :D

Muchas gracias a ambos (Cristobal,hmpaquito) por contestar.
User avatar
Baxajaun
 
Posts: 961
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: No elimina espacios en blanco

Postby cnavarro » Thu Feb 05, 2015 11:32 am

Felix, has mirado esto?
viewtopic.php?f=3&t=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
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: No elimina espacios en blanco

Postby Baxajaun » Thu Feb 05, 2015 12:04 pm

Cristobal,

ahora sí, gracias. Lo acabo de ver.

Muchas gracias.

Saludos
User avatar
Baxajaun
 
Posts: 961
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 97 guests