#198151 - 2010-03-24 06:14 AM
How can I edit a text file with KiXtart?
|
SHOAIB_1975
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
|
|
|
|
#198169 - 2010-03-24 11:55 AM
Re: How can I edit a text file with KiXtart?
[Re: SHOAIB_1975]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4395
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!
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(toimas)
and 446 anonymous users online.
|
|
|