fwh functions

fwh functions

Postby D.Fernandez » Fri Oct 20, 2017 1:39 pm

Friends, where can I found FWH functions.
Something like this: HB_BASE64DECODE( <cBase64> ) --> cString | Decodes a base 64 encoded character string.

Thank you very much
Regrads.
Ruben Dario Fernandez.
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 462
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: fwh functions

Postby Enrico Maria Giordano » Fri Oct 20, 2017 5:32 pm

HB_BASE64DECODE() is not a FWH function, it is a xHarbour function. So you can find it and many others in the xHarbour documentation. There is a very good one sold by xharbour.com guys:

https://www.xharbour.com/store/p33/OrderDocs

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: fwh functions

Postby D.Fernandez » Fri Oct 20, 2017 5:51 pm

Enrico, thaknyou, very much.

I was asking for a .txt file whith all FWH and Harbour functions to make a json file to MSCode.

Thank.
Regards
Ruben Dario Fernandez.
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 462
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: fwh functions

Postby Antonio Linares » Tue Oct 24, 2017 7:18 am

Ruben,

Here it is all FWH functions info:

http://wiki.fivetechsoft.com/doku.php
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42068
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: fwh functions

Postby betoncu » Tue Oct 24, 2017 8:09 am

I have theese routines written by Badara (an old fivewin user).
I hope they fulfil your needs.

FUNCTION StrToBase64( cTexte )
LOCAL X, cHex, cTexte64 := ""
DO WHILE !( cTexte == "" )
cHex := ""
FOR X := 1 TO 3
cHex += CarToBin( LEFT(cTexte, 1) )
IF LEN(cTexte) > 1
cTexte := SUBSTR(cTexte, 2)
ELSE
cTexte := ""
EXIT
ENDIF
NEXT
FOR X := 1 TO 4
IF SUBSTR(cHex, ( (X - 1) * 6) + 1 ) == ""
cTexte64 += REPLICATE("=", 4 - X + 1)
EXIT
ELSE
IF LEN( cHex ) % 6 > 0
cHex += REPLICATE("0", 6 - ( LEN( cHex ) % 6 ) )
ENDIF
cTexte64 += Carac64( "00" + SUBSTR(cHex, ( (X - 1) * 6) + 1, 6 ) )
ENDIF
NEXT X
ENDDO
RETURN cTexte64


FUNCTION Base64ToStr( cTexte64 )
LOCAL X, cHex, cCar, cTexte := ""
DO WHILE !( cTexte64 == "" )
cCar := LEFT(cTexte64,4)
cHex := ""
FOR X := 1 TO 4
IF SUBSTR(cCar, X, 1 ) != "="
cHex += Hex64( SUBSTR(cCar, X, 1 ) )
ELSE
EXIT
ENDIF
NEXT X
FOR X := 1 TO 3
IF SUBSTR(cHex, ( (X - 1) * 8) + 1 ) == ""
EXIT
ELSE
cTexte += BinToCar( SUBSTR(cHex, ( (X - 1) * 8) + 1, 8 ) )
ENDIF
NEXT X
IF LEN(cTexte64) > 4
cTexte64 := SUBSTR(cTexte64, 5)
ELSE
cTexte64 := ""
ENDIF
ENDDO
//The function Base64toStr, has a error, the change is, add this code on the end function:
cTexte := str2hex(cTexte)
IF Right(cTexte,2)="00"
cTexte := SubStr(cTexte,1,len(cTexte)-2)
ENDIF
cTexte := Hex2Str(cTexte)
RETURN cTexte


FUNCTION Carac64( cBin )
LOCAL nPos := ASC( BinToCar( @cBin ) ) + 1
RETURN SUBSTR( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", nPos, 1)


FUNCTION Hex64( carac64 )
LOCAL cCodeAsc, nI, cRet
nI := AT(carac64, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" )
cCodeAsc := CHR( nI -1 )
cRet := SUBSTR( CarToBin( @cCodeAsc ) , 3, 6)
RETURN cRet


FUNCTION CarToBin( carac, lInverse )
#define cHexa "0123456789ABCDEF"
#define aBin {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" }
LOCAL cToHex, cRet

IF EMPTY( lInverse )
cToHex := str2Hex( carac )
cRet := aBin[ AT( LEFT(cToHex,1), cHexa ) ] + aBin[ AT( SUBSTR(cToHex,2), cHexa ) ]
ELSE
cToHex := SUBSTR(cHexa, ASCAN(aBin, LEFT(carac,4) ), 1 ) + SUBSTR(cHexa, ASCAN(aBin, SUBSTR(carac,5,4) ), 1 )
cRet := Hex2str( cToHex )
ENDIF
RETURN cRet


FUNCTION BinToCar( cBin )
RETURN CarToBin( @cBin, .T. )
Birol Betoncu
birol.betoncu@gmail.com
Using Harbour, FWH 19.05, BCC7
User avatar
betoncu
 
Posts: 126
Joined: Sat Oct 08, 2005 9:38 pm
Location: Cyprus (North)

Re: fwh functions

Postby betoncu » Tue Oct 24, 2017 8:12 am

Sorry I am sending routines again.

Code: Select all  Expand view
FUNCTION StrToBase64( cTexte )
LOCAL X, cHex, cTexte64 := ""
   DO WHILE !( cTexte == "" )
      cHex := ""
      FOR X := 1 TO 3
         cHex += CarToBin( LEFT(cTexte, 1) )
         IF LEN(cTexte) > 1
            cTexte := SUBSTR(cTexte, 2)
         ELSE
            cTexte := ""
            EXIT
         ENDIF
      NEXT
      FOR X := 1 TO 4
         IF SUBSTR(cHex, ( (X - 1) * 6) + 1 ) == ""
            cTexte64 += REPLICATE("=", 4 - X + 1)
            EXIT
         ELSE
            IF LEN( cHex ) % 6 > 0
               cHex += REPLICATE("0", 6 - ( LEN( cHex ) % 6 ) )
            ENDIF
            cTexte64 += Carac64( "00" + SUBSTR(cHex, ( (X - 1) * 6) + 1, 6 ) )
         ENDIF
      NEXT X
   ENDDO
RETURN cTexte64


FUNCTION Base64ToStr( cTexte64 )
LOCAL X, cHex, cCar, cTexte := ""
   DO WHILE !( cTexte64 == "" )
      cCar := LEFT(cTexte64,4)
      cHex := ""
      FOR X := 1 TO 4
         IF SUBSTR(cCar, X, 1 ) != "="
            cHex += Hex64( SUBSTR(cCar, X, 1 ) )
         ELSE
            EXIT
         ENDIF
      NEXT X
      FOR X := 1 TO 3
         IF SUBSTR(cHex, ( (X - 1) * 8) + 1 ) == ""
            EXIT
         ELSE
            cTexte += BinToCar( SUBSTR(cHex, ( (X - 1) * 8) + 1, 8 ) )
         ENDIF
      NEXT X
      IF LEN(cTexte64) > 4
         cTexte64 := SUBSTR(cTexte64, 5)
      ELSE
         cTexte64 := ""
      ENDIF
   ENDDO
//The function Base64toStr, has a error, the change is, add this code on the end function:
   cTexte := str2hex(cTexte)
   IF Right(cTexte,2)="00"
      cTexte := SubStr(cTexte,1,len(cTexte)-2)
   ENDIF
   cTexte := Hex2Str(cTexte)
RETURN cTexte


FUNCTION Carac64( cBin )
LOCAL nPos := ASC( BinToCar( @cBin ) ) + 1
RETURN SUBSTR( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", nPos, 1)


FUNCTION Hex64( carac64 )
LOCAL cCodeAsc, nI, cRet
   nI := AT(carac64, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" )
   cCodeAsc := CHR( nI -1 )
   cRet := SUBSTR( CarToBin( @cCodeAsc ) , 3, 6)
RETURN cRet


FUNCTION CarToBin( carac, lInverse )
#define cHexa  "0123456789ABCDEF"
#define aBin  {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" }
LOCAL cToHex, cRet

   IF EMPTY( lInverse )
      cToHex := str2Hex( carac )
      cRet := aBin[ AT( LEFT(cToHex,1), cHexa ) ] + aBin[ AT( SUBSTR(cToHex,2), cHexa ) ]
   ELSE
      cToHex := SUBSTR(cHexa, ASCAN(aBin, LEFT(carac,4) ), 1 ) + SUBSTR(cHexa, ASCAN(aBin, SUBSTR(carac,5,4) ), 1 )
      cRet := Hex2str( cToHex )
   ENDIF
RETURN cRet


FUNCTION BinToCar( cBin )
RETURN CarToBin( @cBin, .T. )
 
Birol Betoncu
birol.betoncu@gmail.com
Using Harbour, FWH 19.05, BCC7
User avatar
betoncu
 
Posts: 126
Joined: Sat Oct 08, 2005 9:38 pm
Location: Cyprus (North)

Re: fwh functions

Postby D.Fernandez » Wed Oct 25, 2017 12:31 am

Hi betoncu, thank you very much

Best regards

Ruben Dario Fernandez
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 462
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay

Re: fwh functions

Postby D.Fernandez » Wed Oct 25, 2017 12:33 am

Gracias Antonio, espero devolverles un muy buen archivo.json

Gracias, saludos
Ruben Dario Fernandez.
Dario Fernandez
FWH 24.09, Harbour, MVS2022 Community, BCC, MySql & MariaDB, Dbf/Cdx VSCode.
Maldonado - Uruguay
D.Fernandez
 
Posts: 462
Joined: Wed Jul 31, 2013 1:14 pm
Location: Maldonado - Uruguay


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 31 guests