PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Copy edit control contents into a text file
Copy edit control contents into a text file
Iniciado por guest, 09,jun. 2015 15:40 - 6 respuestas
Publicado el 09,junio 2015 - 15:40
Hi,

I want to copy my contents in edit control into a text file. Here is my code:

sample is int
sample = fOpen(".\sample.txt",foCreateIfNotExist)
IF sample = -1 THEN
Error(ErrorInfo)
ELSE
EDT_myedit..Cursor = 1
fAddText(sample,EDT_myedit..TextWithoutFormat)
END

Once executed, I will get a empty file with name "sample.txt". This code will generate another file with name "2" which contains all of my edit control contents.

How to modify my code so that "sample.txt" contains my edit control contents and file "2" is not generated.

Thanks and Regards,
Naveen Rathan
Publicado el 09,junio 2015 - 15:46
Hi Naveen,

I think you should use

fAddText(sample,RTFToText(EDT_myedit))

instead of

fAddText(sample,EDT_myedit..TextWithoutFormat)
(This should save the setting of ..TextWithoutFormat of the EDT_myedit control)
Publicado el 09,junio 2015 - 15:52
Hi Stefan,

Same results even after using RTFtoText. I can see contents in a file name called "2" rather than "sample.txt".

Any help how to resolve this?

Thanks and Regards,
Naveen Rathan
Publicado el 09,junio 2015 - 15:55
fAddText(".\sample.txt",EDT_myedit..TextWithoutFormat)

check this page: http://doc.windev.com/en-US/index.awp…
Publicado el 09,junio 2015 - 16:03
Hello,
Try;

test is string=RTFtoText(EDT_myedit)
IF fFileExist("sample.txt") THEN
fAddText("sample.txt",test)
ELSE
fSaveText("sample.txt",test)
END
Best regards,
Kozeta
Publicado el 09,junio 2015 - 16:10
Thanks Kozeta,

It worked.


Thanks and Regards,
Naveen Rathan
Publicado el 09,junio 2015 - 16:25
Hi

or you could do it in one line by using fsavetext

Best regards