Solved

Parsing a file

Posted on 1998-10-14
2
135 Views
Last Modified: 2010-04-30
Hi,
   I need to be able to parse a file so that it adds four charactors to the end of each line as it stores the file into a variable named CTEXT... any ideas?

Kind Regards,
Rob Green.
0
Comment
Question by:robjgreen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
traygreen earned 60 total points
ID: 1439974
If the file has carriage return/line feed characters in it(or any other identifiable line delimiter character in it) you can run through the file one character at a time.  You can build the output string as you go and replace or append the four characters everytime you hit the delimiter character.

eg.

const cAPPEND_CHARS = "1234"
Dim Char
dim CText as string
 
Open "FILE" For Input As #1      ' Open file.
Do While Not EOF(1)      ' Loop until end of file.
  Char = Input(1, #1)      ' Get one character.
  if asc(Char)<> 13     ' cr/lf
     CText = CText & Char
  else
     CText = CText & cAPPEND_CHARS
  end if      
Loop
Close #1      ' Close file.
0
 

Author Comment

by:robjgreen
ID: 1439975
I actually cracked it before you sent the reply, but thanks for replying so quickly anyway :o)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question