Problem reading text file

C

cum.nex

From an Ecel-VB macro I need to do the following:
1) open a text file for reading (in my case. a mail message file)
Dim fileIn As String
Dim thisLine(500) As String
Open fileIn For Input As #1
Open fileOut For Output As #2
2) read each line from this file
Input #1, thisLine
3) process the line and then write it to an output text file, similar
to the input one.

Problem.
Lines like the following ones (I add >CRLF to display the carriage
return chars):
Received: from smtp-in10.gmail.com (192.168.32.68) by ims88c.gmail.com
(18.0.024.3)>CRLF
id 47DA621000B94BAB for (e-mail address removed); Wed, 28 May 2008
20:00:24 +0200>CRLF
Received: from outrelay05.gmail.com (172.31.0.121) by smtp-
in10.gmail.com (7.3.120)>CRLF
id 4611FE643F754F89 for (e-mail address removed); Wed, 28 May 2008
20:00:24 +0200>CRLF

are read from the macro as:
Received: from smtp-in10.gmail.com (192.168.32.68) by ims88c.gmail.com
(18.0.024.3)
id 47DA621000B94BAB for (e-mail address removed); Wed>CRLF
28>CRLF
May 2008 20:00:24 +0200>CRLF
Received: from outrelay05.gmail.com (172.31.0.121) by smtp-
in10.gmail.com (7.3.120)
id 4611FE643F754F89 for (e-mail address removed); Wed>CRLF
28>CRLF
May 2008 20:00:24 +0200>CRLF

That is:
1) spaces at the beginning of the line are trimmed (" id
4611FE643"...)
2) lines are split ("Wed, 28 May"...)

Why and which solution?
Thanks.
 
J

JoeU2004

cum.nex said:
Dim thisLine(500) As String
[....]
2) read each line from this file
Input #1, thisLine

I believe you should use Line Input, not Input.

And either you should use:

Dim thisline as String

or

Dim thisLine as String*500

depending on your intent. I would opt for the first form.

Alternatively, perhaps you want:

Line Input #1, thisLine(i)

where "i" is incremented for each read.


----- original message -----
 
C

cum.nex

cum.nex said:
   Dim thisLine(500) As String
[....]
2) read each line from this file
       Input #1, thisLine

I believe you should use Line Input, not Input.

And either you should use:

Dim thisline as String

or

Dim thisLine as String*500

depending on your intent.  I would opt for the first form.

Alternatively, perhaps you want:

Line Input #1, thisLine(i)

where "i" is incremented for each read.

----- original message -----


From an Ecel-VB macro I need to do the following:
1) open a text file for reading (in my case. a mail message file)
   Dim fileIn As String
   Dim thisLine(500) As String
   Open fileIn For Input As #1
   Open fileOut For Output As #2
2) read each line from this file
       Input #1, thisLine
3) process the line and then write it to an output text file, similar
to the input one.
Problem.
Lines like the following ones (I add >CRLF to display the carriage
return chars):
Received: from smtp-in10.gmail.com (192.168.32.68) by ims88c.gmail.com
(18.0.024.3)>CRLF
       id 47DA621000B94BAB for (e-mail address removed); Wed, 28 May 2008
20:00:24 +0200>CRLF
Received: from outrelay05.gmail.com (172.31.0.121) by smtp-
in10.gmail.com (7.3.120)>CRLF
       id 4611FE643F754F89 for (e-mail address removed); Wed, 28 May 2008
20:00:24 +0200>CRLF
are read from the macro as:
Received: from smtp-in10.gmail.com (192.168.32.68) by ims88c.gmail.com
(18.0.024.3)
id 47DA621000B94BAB for (e-mail address removed); Wed>CRLF
28>CRLF
May 2008 20:00:24 +0200>CRLF
Received: from outrelay05.gmail.com (172.31.0.121) by smtp-
in10.gmail.com (7.3.120)
id 4611FE643F754F89 for (e-mail address removed); Wed>CRLF
28>CRLF
May 2008 20:00:24 +0200>CRLF
That is:
1) spaces at the beginning of the line are trimmed ("        id
4611FE643"...)
2) lines are split ("Wed, 28 May"...)
Why and which solution?
Thanks.

It works, thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top