FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour nXOR
Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
nXOR
Posted: Sun Nov 13, 2011 06:13 AM

alert (numtohex ("1")) => 31

alert (numtohex ("2")) => 32

pero alert ( nXor( NUMTOHEX("1"), NUMTOHEX("2") ) => 0 (valor incorrecto)

   alert ( nXor(  (StrToHex("1")),  (StrToHex("2") ) )) => 0   (valor incorrecto)

y alert (( nXor ( 31,32))) => 61 (el valor correcto)

¿No puedo comparar la cadena con NumToHex o quizás

Un saludo



Manuel
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: nXOR
Posted: Sun Nov 13, 2011 09:08 AM
Manuel,

Prueba asi:

Code (fw): Select all Collapse
function Test()

   MsgInfo( nXor( Val( hb_numtohex( Asc( "1" ) ) ), Val( hb_numtohex( Asc( "2" ) ) ) ) )

   MsgInfo( nXor( 31, 32 ) )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 711
Joined: Thu Oct 06, 2005 09:57 PM
Re: nXOR
Posted: Sun Nov 13, 2011 04:16 PM

Muchas gracias Antonio. Ha funcionado perfectamente el ejemplo.

Pero no consigo me funcione usando una cadena variable, seguramente porque lo planeo mal :

cCad := "123456"
cRecno := ''

FOR n=1 TO 6
nRecno += 'Val( NumToHex( Asc("' + StrChar(cCad , n) + '")))'
if n < 6
nRecno += ', '
endif
NEXT

MsgInfo ( nXor ( nRecno ) ) => 0 está mal

MsgInfo( nXor( Val( NumToHex( Asc( "1" ) ) ), ;
Val( numtohex( Asc( "2" ) ) ), ;
Val( numtohex( Asc( "3" ) ) ), ;
Val( numtohex( Asc( "4" ) ) ), ;
Val( numtohex( Asc( "5" ) ) ), ;
Val( numtohex( Asc( "6" ) ) ) ;
) ) => 59 esta bien

Un saludo



Manuel

Continue the discussion