SHOAIB_1975
(Just in Town)
2010-03-24 06:14 AM
How can I edit a text file with KiXtart?

I want to edit a text file please help

Mart
(KiX Supporter)
2010-03-24 09:12 AM
Re: How can I edit a text file with KiXtart?

Welcome to the board.

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


Glenn BarnasAdministrator
(KiX Supporter)
2010-03-24 11:55 AM
Re: How can I edit a text file with KiXtart?

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