Page 1 of 1

unix2dos

Posted: Sat May 01, 2021 9:25 pm
by Otto
Hello frieds,

I see this string in FWLOG.
cVData = E "button <br> \ r \ n reset <br> \ r \ n submit

I think it's a UNIX format. How can you convert this string to DOS?

As a workaround I am writing to the FWLOG file and then read the data from there. But I am sure there is a better way.

Is there a conversation function.

Best regards,
Otto

Re: unix2dos

Posted: Sun May 02, 2021 8:10 am
by Otto
Hello,
I forgot to post my workaround,
a funny one but working.
Best regards,
Otto



Code: Select all | Expand


fwlog cLine
cDosLine :=    unix2dos()

function unix2dos
    local chtmlfile
    local nAt := 0
    local cTmp := ""
   
    chtmlfile :=memoread( "readhtm.log" )
    ferase("readhtm.log")
    chtmlfile :=  STRTRAN( chtmlfile, '\r\n' , '' )
    chtmlfile :=  STRTRAN( chtmlfile, 'E"' , ' "' )
    memowrit("readhtm.txt",chtmlfile)
    cTmp := memoread( "readhtm.txt" )
    nAt := AT( '"', cTmp )
    cTmp := substr(cTmp , nAt+1 )  
    cTmp := ALLTRIM( left( cTmp, (len(cTmp)-4 ) ) )

return( cTmp  )
//----------------------------------------------------------------------------//

Re: unix2dos

Posted: Sun May 02, 2021 12:20 pm
by ADutheil
My function is

Code: Select all | Expand

FUNCTION Unix2Win( cArqu )
LOCAL cBuff := ""
LOCAL cSaid := "DoUnix.txt"
LOCAL nEntr
LOCAL nSaid
LOCAL lRetu := .T.

BEGIN SEQUENCE
    IF ( nEntr:= fOpen( cArqu ) ) < 1
        msgStop( "IMPOSSÍVEL ABRIR: " + cArqu, msg_atencao )
        lRetu := .F.
        BREAK
    ENDIF
    IF (nSaid:= fCreate( cSaid ) ) < 1
        msgStop( "IMPOSSÍVEL CRIAR: " + cSaid, msg_atencao )
        lRetu := .F.
        fClose( nEntr )
        BREAK
    ENDIF
    WHILE hb_fReadLine( nEntr, @cBuff, chr(10) ) == 0
        fWrite( nSaid, cBuff + hb_OSNewLine() )
    ENDDO
    IF len( cBuff ) > 0
        fWrite( nSaid, cBuff + hb_OSNewLIne() )
    ENDIF
    fClose( nSaid )
    fClose( nEntr )
END SEQUENCE
RETURN ( lRetu )

Re: unix2dos

Posted: Sun May 02, 2021 2:13 pm
by Antonio Linares
Dear Otto,

\ r \ n is Chr( 13 ) + Chr( 10 ), in FWH we have a define for it: CRLF

<br> is html code, and it seems so for button and submit

how do you create such line ? :-)

Re: unix2dos

Posted: Sun May 02, 2021 4:47 pm
by Otto
Dear Antonio,
Many thanks for your response. I read the attributes and event attributes of all tags from W3Schools.com. Some attributes then return these strings.
You can only see in FWLOG that E "and \ r \ n are still there.
I can't see the E "either when I scan the characters one by one.
The workaround works, and I now have the entire TAGLIST in a DBF file.

Best regards,
Otto

Image

Image
Image
Image
Image