From: Tom Serface on
Hi Hamishd,

Do you have newlines in the file? The ReadString() function only reads up
until the next newline. It also has a line length of something like 128
characters if I remember correctly. If you have that class you could try
upping that line limit, recompiling, and seeing if that fixes it. Or, if
you have newlines in the "line" you will have to use a normal CFile and
parse the lines yourself. CStdioFile and CStdioFileEx don't really know
anything about double quotes.

Tom

"hamishd" <Hamish.Dean(a)gmail.com> wrote in message
news:1182478868.447385.64760(a)o11g2000prd.googlegroups.com...
I have the following 4 lines of data in a text file which I want to
read (note the large number of spaces in line2):
..5,-90,50
"��
��
",0,50
-15630,166,205,0
0,0

CStdioFileEx file; CString str;
CString Data[10];

file.Open(_T("c:\\file.txt"), CFile::modeRead){
while(file.ReadString(str)){
Data[i++] = str;
}
file.Close();
}

But it doesn't read the 2nd line correctly... here's the result
Data[0] = .5,-90,50
Data[1] = "��
��
"
Data[2] = 0
Data[3] = -15630,166,205,0
Data[4] = 0,0

It should be:
Data[0] = .5,-90,50
Data[1] = "��
��
",0,50
Data[2] = -15630,166,205,0
Data[3] = 0,0

From: Tom Serface on
Hi Asm,

I think OP would have had similar problems with either in this case.
Perhaps OP started with CStdioFile and then tried the Ex version when they
couldn't get the original to work, etc. That's the problem with the "trial
and error" method. Until you get "trial and success" it's not all that
useful.

Tom

"MrAsm" <mrasm(a)usa.com> wrote in message
news:s94n73lqviib20792rdr1nb2ej7joojeau(a)4ax.com...
> On Thu, 21 Jun 2007 19:21:08 -0700, hamishd <Hamish.Dean(a)gmail.com>
> wrote:
>
>>CStdioFileEx file; CString str;
>
> BTW: you wrote CStdioFile in the subject, but it seems that you are
> actually using CStdioFileEx... please don't be misleading in the
> subject :)

From: Tom Serface on
I pity the fool that uses this one ... :o)

Seriously, I need to get the code cleaned up and get it over to Joe so we
can have a place to direct people. This topic is coming up far too often.
I'll work on that this weekend.... thanks for the reminder.

Tom

"MrAsm" <mrasm(a)usa.com> wrote in message
news:s94n73lqviib20792rdr1nb2ej7joojeau(a)4ax.com...
> [The more robust and versatile CStdioFile extension I've seen is by a
> friend who post in this group ;) Mister T. - his implementation checks
> the BOM, etc.]

From: MrAsm on
On Fri, 22 Jun 2007 07:02:27 -0700, "Tom Serface"
<tom.nospam(a)camaswood.com> wrote:

>I pity the fool that uses this one ... :o)

:))

MrAsm
From: hamishd on
> The exmples below don't seem to illustrate much. Perhaps you should try to illustrate the
> spaces with some printable character.

When I remove the spaces it works :(

> Try to avoid putting more than one declaration per line.
>
> Also, you would be better served by using
>
> CStringArray Data;
>
> and just doing Data.Add(string)

I do. Just not in the exmaple sorry.

First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Debug Assertation Failed
Next: Runtime error-help plz.