PDA

View Full Version : How to edit a txt or config file


altainta
02-05-2006, 06:03 PM
Sorry to ask this but i am complete Noob

I want to design a program which will generally edit a config.txt (It should not delete or create new just edit the previous one) Line number my help
e.g Config.txt content
activateAI 1 #1 or 2
SrNo. 92384400
UserName Someone
Passs Something
So everyting which is colour should be edited by a programe
So far i designed a program (Which is just related to it) but the program i designed just create new entries and read previous entries from the **.txt files. Please guide me i don't even know how to ask abt this and what this thing is called actually.

The above given example is easy i can also edit by notepad but the file have about 78 conf chars and each and every char is attached to other char so if one gets wrong other will too.
i will also attach my programm if u want.

Mhtml
02-06-2006, 04:42 AM
Well I don't know how you're programming this (gui? cpp? windows?)..
Well obviously you first need to parse the file.

Now you have mixed syntax in that example, so unless you are using regular expressions or something, the one thing I've never found a decent library for, anyway you're gunna need to test each line for two sorts of syntax.

NAME VALUE [#COMMENT]

That's the basic syntax you have, as you can see there are the 2 possibilities.

If you can tell me how you're making this, I can probably help you with some code otherwise best I can do are just pseudo algorithms.

altainta
02-06-2006, 08:19 AM
Thanks fror reply first :)
U r correct abt (NAME VALUE [#COMMENT]) This is correct systanx i want
I am programming in VB6.
Sir i have a file which is a good example i open the file and it is a Perl Script
When i open it in edit tab pro software it shows the file as i want like it actually shoows like this (With colours)
(Just an example)

###NAME VALUE #COMMENTS
autoRestart 0
autoRestartMin 10800
autoRestartSeed 3600
autoRestartSleep 1
autoSleepMin 900
autoSleepSeed 900
and
##Primary key (AS PER NOTEPAD NOT VIEWABLE) Name Value #comments

0 autoRestart 0
1 autoRestartMin 10800
2 autoRestartSeed 3600
3 autoRestartSleep 1
4 autoSleepMin 900
5 autoSleepSeed 900

the primary key will diffrentiate them with each other or getting mixed up
So every thing in colour Magneta should be changeable via Vb programe
A sample program which i have post in other forum (Just a create entry) which will give a clear hint (Actually it is my different programm just related to this file). By viewing that forum post u will see that I can create entries in txt file but i need to update it. The entries created in txt file include "" inverterd commans which i remove with Replace function in notepad.
http://www.vbcity.com/forums/topic.asp?tid=120198
They have given me a solution or may be hint but i can't understant it but still hope u can explain me.