Subject: Saving text to files from EDIT class
From: [email-masked] (Miron the Master)

28 Jan 1998 20:08:35 -0800
Message-ID: <01bd2c1c$0f2f33a0$LocalHost.cygnus.gnu-win32@ppp>
Mime-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_017B_01BD2C24.70F39BA0"
To: "GNU-Win32 Mailing list" <[email-masked]>

This is a multi-part message in MIME format.

------=_NextPart_000_017B_01BD2C24.70F39BA0
Content-Type: text/plain;
	charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

Hi,=20
I've problem with saving text files.
Can you tell me what's wrong with this code:
=20
hEdit - EDIT window=20
=20
int saveFile(char *filename)
{
    char buff[256];
    int i;
    int size;
    int lines =3D SendMessage(hEdit, EM_GETLINECOUNT, 0, 0);
    int fh =3D open(filename, O_WRONLY | O_CREAT);
    for(i =3D 0; i < lines; i++)
    {
        ((int *)buff)[0] =3D 254;
        size =3D SendMessage(hEdit, EM_GETLINE, i, (LPARAM)buff);
        buff[size] =3D 0x0d;      // CR
        buff[size+1] =3D 0x0a;    // LF
        write(fh, buff, size+1);
    }
    close(fh);
 =20
Thanx,

Daniel Mironowicz             [email-masked]

------=_NextPart_000_017B_01BD2C24.70F39BA0
Content-Type: text/html;
	charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-2 =
http-equiv=3DContent-Type><!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 =
HTML//EN"><!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN"><!DOCTYPE HTML =
PUBLIC "-//W3C//DTD W3 HTML//EN">
<META content=3D'"MSHTML 4.71.2016.0"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>Hi, </FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>I've problem with saving text=20
files.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>Can you tell me what's wrong with =
this=20
code:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>hEdit - EDIT =
window</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>int saveFile(char=20
*filename)<BR>{<BR>&nbsp;&nbsp;&nbsp; char =
buff[256];<BR>&nbsp;&nbsp;&nbsp; int=20
i;<BR>&nbsp;&nbsp;&nbsp; int size;<BR>&nbsp;&nbsp;&nbsp; int lines =3D=20
SendMessage(hEdit, EM_GETLINECOUNT, 0, 0);<BR>&nbsp;&nbsp;&nbsp; int fh =
=3D=20
open(filename, O_WRONLY | O_CREAT);<BR>&nbsp;&nbsp;&nbsp; for(i =3D 0; i =
&lt;=20
lines; i++)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((int *)buff)[0] =3D=20
254;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size =3D =
SendMessage(hEdit,=20
EM_GETLINE, i, =
(LPARAM)buff);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
buff[size] =3D 0x0d;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //=20
CR<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buff[size+1] =3D=20
0x0a;&nbsp;&nbsp;&nbsp; // =
LF<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
write(fh, buff, size+1);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;=20
close(fh);<BR></FONT>&nbsp;&nbsp;</DIV>
<DIV>Thanx,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Daniel=20
Mironowicz&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
<A=20
href=3D"mailto:[email-masked]">[email-masked]</A></DI=
V></BODY></HTML>

------=_NextPart_000_017B_01BD2C24.70F39BA0--

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".