Page 1 of 1 1
Topic Options
#43848 - 2003-08-09 05:18 AM reading one file to create another
JohnQ Offline
Starting to like KiXtart

Registered: 2003-03-04
Posts: 171
This seems simple enough but I keep putting myself in an endless loop.

I have one text file with multiple lines. I need to append every line in that file (with the same characters). What I need to do is read the first line in file # 1, add ",blahblah" to the end of it and write the new line to a new file. Then on to the next line of file # 1, add the same thing and write it to the new file.

The end result would be a new file identical to the first but with ",blahblah" at the end of every line.

Any suggestions?

Top
#43849 - 2003-08-09 05:22 AM Re: reading one file to create another
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Maybe if you posted the code you have so far with short samples of the 2 before files and the after file.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#43850 - 2003-08-09 05:26 AM Re: reading one file to create another
JohnQ Offline
Starting to like KiXtart

Registered: 2003-03-04
Posts: 171
The code that I tried to come up with is an embarasssment to the world.

An example of the original file would be:
I used to be stupid
I am still stupid
I will always be stupid

The second file (to be created) would be something like:
I used to be stupid,10
I am still stupid,10
I will always be stupid,10

Top
#43851 - 2003-08-09 05:42 AM Re: reading one file to create another
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca


break on
IF Open(1'C:\testout.txt',5) = 0
  IF Open(2'C:\testin.txt') = 0
    $x = ReadLine(2)
    WHILE @ERROR = 0
      $=WriteLine(1$x + ",10" + @CRLF)
      $x = ReadLine(2)
    LOOP
    $=Close (2)
    $=Close (1)
  ELSE
    BEEP
    ? "C:\testin.txt file not opened, error code: [" + @ERROR + "]"
  ENDIF
ELSE
  BEEP
  ? "C:\testout.txt file not opened, error code: [" + @ERROR + "]"
ENDIF

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#43852 - 2003-08-09 03:53 PM Re: reading one file to create another
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
An quick look into the KiXtart Manual would also reveal example scripts to read from and write to a text file.
_________________________
There are two types of vessels, submarines and targets.

Top
#43853 - 2003-08-09 03:56 PM Re: reading one file to create another
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
hehee...
Notice how similar mine is to the example. [Wink]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#43854 - 2003-08-09 03:59 PM Re: reading one file to create another
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You damn lazy boy! Can't even create your own example? [Big Grin] [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 756 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.03 seconds in which 0.012 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org