Page 1 of 1 1
Topic Options
#198151 - 2010-03-24 06:14 AM How can I edit a text file with KiXtart?
SHOAIB_1975 Offline
Just in Town

Registered: 2010-03-24
Posts: 1
Loc: United Arab Emirates
I want to edit a text file please help

Edited by Richard H. (2010-03-24 09:17 AM)
Edit Reason: Fixed up title

Top
#198155 - 2010-03-24 09:12 AM Re: How can I edit a text file with KiXtart? [Re: SHOAIB_1975]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Welcome to the board.

If it is a text file you can have a look at Open(), Readline(), Writeline() and Close().


Edited by Richard H. (2010-03-24 09:17 AM)
Edit Reason: Fixed up title

Top
#198169 - 2010-03-24 11:55 AM Re: How can I edit a text file with KiXtart? [Re: SHOAIB_1975]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Welcome!

As was pointed out, you can use Open, ReadLine, WriteLine, and Close to manipulate a file. These are the native commands, and you need to review the examples in the manual to put them to use.

I use a function that I wrote called "FileIO", which reads a text file into an array -
$Array = FileIO('filename', 'R')
- is all that's needed to load the file. This is usually much easier than using the native commands.

Once the data is in the array, you can use AScan() to search for data, or simply enumerate the array to evaluate each line, edit lines, insert or delete rows, etc. When you're done, call
$Rc = FileIO('filename', 'W', $Array)
to overwrite the original data with the new data. There's even an optional parameter to remove blank lines, which allows you to delete lines by simply clearing the array element. It's posted in the UDF library on my web site. There are similar UDFs published here to simplify reading and writing text files.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

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 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.056 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

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