Thanks a lot. Share these solution functionskarinha wrote:Regards, Saludos.Code: Select all | Expand
// C:\FWH\SAMPLES\CRC.PRG #include "fivewin.ch" // #include "HbCompat.ch" MEMVAR aCrc, poly, initvalue, finavalue FUNCTION Main() LOCAL crcResu, CCRCRESU, cResult PRIVATE aCrc := { 0x00, 0x01, 0x07 } PRIVATE poly := 0x8005 PRIVATE initvalue := 0xFFFF PRIVATE finavalue := 0x0000 Ccrcresu := Calculate_Crc() // asi, funciona: ? HB_NumToHex( Ccrcresu ) ? HB_NumToHex( hb_Random( 0xFFFFFF ) ) + '"' // no funciona: // cResult := hb_NumToHex( crcresu, 4 ) // return error. // ? cResult // xHarbour: // cResult := NumToHex( crcresu, 4 ) RETURN NIL FUNCTION Calculate_Crc() LOCAL crc := initvalue, i, j FOR I = 1 TO Len( aCrc ) crc = hb_bitXor( crc, hb_bitShift( aCrc[ i ], 8 ) ) FOR j = 1 TO 8 IF hb_bitAnd( crc, 0x8000 ) <> 0 crc = hb_bitXor( hb_bitShift( crc, 1 ), poly ) ELSE crc = hb_bitShift( crc, 1 ) ENDIF NEXT NEXT RETURN hb_bitXor( crc, finavalue ) /* hbmisc.hbc DecToHexa() HexaToDec() IsHexa() hbnf.hbc (instalado): ft_Byt2Hex() ft_Hex2Dec() xhb.hbc HexToNum() HexToStr() NumToHex() StrToHex() Harbour Core *** hb_HexToNum() hb_HexToStr() hb_NumToHex() hb_StrToHex() hbmisc.hbc BinToDec() DecToBin() IsBin() hbnf.hbc ft_Dec2Bin() Harbour Core *** Return -> Int <- Param Bin2I() Bin2L() Bin2W() I2Bin() L2Bin() */ // FIN / END
FWH or harbour function support CRC? ( Solved )
- richard-service
- Posts: 808
- Joined: Tue Oct 16, 2007 8:57 am
- Location: New Taipei City, Taiwan
- Has thanked: 2 times
- Contact:
Re: FWH or harbour function support CRC? ( Solved )
Best Regards,
Richard
Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
Richard
Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
- richard-service
- Posts: 808
- Joined: Tue Oct 16, 2007 8:57 am
- Location: New Taipei City, Taiwan
- Has thanked: 2 times
- Contact:
Re: FWH or harbour function support CRC? ( Solved )
You're welcome...nageswaragunupudi wrote:Congratulations and thanks for sharing your solution.so I make these code and solved my problem below:
Best Regards,
Richard
Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
Richard
Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit