Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
Acmlm's Board - I3 Archive - Programming - finding/editing specific lines from a text file in C++ | New poll | | |
Add to favorites | Next newer thread | Next older thread |
User | Post | ||
spiroth10 Paratroopa Since: 01-28-06 From: USA Last post: 6283 days Last view: 6283 days |
| ||
Okay, Im unveiling my new project with this help request, I guess...
Im writing a little application to edit oblivion.ini for you (and back it up/restore it). It will be a .NET application (for now, I can download the Windows SDK in 2 months when I get broadband. yes, Im getting a job and 768k broadband when AOL runs out, its a miracle) As I am using Visual C++ exp anyway, I just need to know how to load up Oblivion.ini, and search for certain lines. Once those lines are found, the values need to be changed to enable/disable the tweaks. And if you didnt know, you can make the game more stable and/or heighten graphical ability (on water/etc) by editing the file. I'm pretty sure C/C++ comes standard with a library that does this, I just havent used file i/o outside of standard C (which seemed to be a mess to me. I could never get more than 1 word into text file), and even that was about 2 years ago. But if it doesn't (I may very well be wrong) please direct me to a library that can... edit: OK, Ive found fstream, but I cant figure out for the life of me how to seek out and replace a line in the text file. ie: bAllow30Shaders=0 to bAllow30Shaders=1 Any help would be great, because once I figure this out, I'll be in the home stretch, and the program will be easy to complete. (edited by spiroth10 on 12-12-06 12:46 AM) (edited by spiroth10 on 12-12-06 01:44 AM) |
|||
HyperHacker Star Mario Finally being paid to code in VB! If only I still enjoyed that. <_< Wii #7182 6487 4198 1828 Since: 11-18-05 From: Canada, w00t! My computer's specs, if anyone gives a damn. STOP TRUNCATING THIS >8^( Last post: 6284 days Last view: 6284 days |
| ||
When did XP start coming with .Net?
Anyway you're probably going to want to read the file one line at a time. Read until you find '\n', then copy 15 characters (the length of "bAllow30Shaders") to a separate buffer, and don't forget the null space at the end. Use strcmp() to see if the buffer you just copied to matches "bAllow30Shaders". If so, you've found your string, so update its contents in the buffer you read the file into, read in the rest of the file, and then write it back. If memory is a problem you might want to write each line to another file immediately instead of reading the entire file into memory. |
|||
spiroth10 Paratroopa Since: 01-28-06 From: USA Last post: 6283 days Last view: 6283 days |
| ||
I dunno -- my computer came with .NET preinstalled (Windows XP Media Center 2005).
anyway thanks. |
|||
spiroth10 Paratroopa Since: 01-28-06 From: USA Last post: 6283 days Last view: 6283 days |
| ||
After trying several configurations with C++ code, none of which working, I have decided to move on to using LUA.
I have figured out how to load the file/convert it to a string within LUA (and possibly even searching/indexing the string) but not how to replace text. I've been googling for awhile now, and I can't find anything specifically related to changing text in an existing file within a LUA Script. I do rather like the language though. and as for a GUI, I'm coding the WinAPI myself now with SmartWin++ -- it makes windows programming a lot less of a PITA -- actually the simplest GUI library I've ever used. anyway, any links to articles/tutorials/docs about editing a textfile from within LUA scripts would be VERY helpful. |
Add to favorites | Next newer thread | Next older thread |
Acmlm's Board - I3 Archive - Programming - finding/editing specific lines from a text file in C++ | | |