Page 1 of 1

Problem with MemoWirit

Posted: Sun Dec 17, 2023 10:55 am
by digitsoft
Good afternoon
Can you tell me why MemoWirit writes strange characters at the end of the last line?

Re: Problem with MemoWirit

Posted: Sun Dec 17, 2023 11:49 pm
by Tom
MemoWrit() adds an EoF-character to the file contens (HEX 1A, Dec 26). Use StrFile() instead (take care - parameters are exchanged), or the low level functions.

Re: Problem with MemoWirit

Posted: Mon Dec 18, 2023 1:47 am
by skiman
Hi,

You can use this as a replacement:

Code: Select all

function abomemowrite(cTargetFile,cBuffer)
******************************************
Local nTarget := FCreate( cTargetFile, FC_NORMAL )

if nTarget == -1
    return .F.
  else
    FWrite( nTarget, cBuffer)
    FClose(ntarget)
endif

return .T.

Re: Problem with MemoWirit

Posted: Mon Dec 18, 2023 1:54 am
by k-insis
This.

Also memoread/memowrit is not that good when using UTF-8 data ; it tries to do some chardata conversion on its own. Found it the hard way when using xml with international IBAN processing resoults years ago.

Using regular fileio functions is much safer choice.

skiman wrote: Mon Dec 18, 2023 1:47 am Hi,

You can use this as a replacement:

Code: Select all

function abomemowrite(cTargetFile,cBuffer)
******************************************
Local nTarget := FCreate( cTargetFile, FC_NORMAL )

if nTarget == -1
    return .F.
  else
    FWrite( nTarget, cBuffer)
    FClose(ntarget)
endif

return .T.

Re: Problem with MemoWirit

Posted: Mon Dec 18, 2023 2:25 am
by Tom
StrFile() does the same, without any conversions.

Re: Problem with MemoWirit

Posted: Mon Dec 18, 2023 7:53 am
by digitsoft
Tom wrote: Sun Dec 17, 2023 11:49 pm MemoWrit() adds an EoF-character to the file contens (HEX 1A, Dec 26). Use StrFile() instead (take care - parameters are exchanged), or the low level functions.
thank you