![]() |
Problem modifying a string in a .cfg file
I seem to have run into a problem during the creation of my installer. One of the steps I need performed, involves the manipulation of a string of text within a .cfg file. However, the config file is not devided into sections, it is all one big section, without a section header such as
[Main] Instead, the config file flows sort of like: HazeColor = 1.2 1.3 .56 LightLevel = 2.0 1.3 0.5 AtmAlt = 64e3 etc, etc. I need to have the installer modify one of those lines, ex., HazeColor = 1.0 1.0 1.0 Without there being any Sections defined in brackets, how can I get the value in that string to be changed by the installer? I've tried to research the forums on this, and I am currently also in the IRC channel in case anyone in there can give some insight, but so far, I havent been able to find a problem similar to mine, and I will admit, I am brand new at scripting, and have maybe a total of 10 hours in Visual C++, so Im most definitely not skilled in this kind of thing, and would need a pretty decent explaination. Any help is appreciated greatly. Thanks, EndeavourCmdr. |
Re-format the file.cfg to a new structured file.cfg and you'll be able to modify any string.
|
Unfortunately, thats not an option, beceause the program I am having installed is simply a modification to an existing program, of which I do not have any access or rights to, other then just being an addon developer for it. Thus, the config file structure has to remain the same, and it is not even feasible to have the structure changed. Every single config however does have the same line of text in it which is:
AtmHazeColor = valuehere Is it possible to have the script just find that string without a section defined and replace the value? |
Hold on a second I'll be back
|
code: |
Well thanks! That is alot more complex then I expected. Are there any good tutorials out there on how do learn some of this stuff, other then the manual, which seems to be just a reference?
|
Hmm, actually on a second look, that code wouldnt quite work, because everyone needs to have
AtmHazeColor = 1.0 1.0 1.0 after the install. Before the install, the values may be different on every users machine. So user 1 might have AtmHazeColor = 0.535 0.76 1.0 User 2 might have AtmHazeColor = 0.7 0.85 1.0 etc, etc. But in the end, they all need to read, AtmHazeColor = 1.0 1.0 1.0 So, now I am once again where I started Lol. |
You may find everything in the forum, just point your search to the required keywords. Also browse to wiki http://nsis.sourceforge.net there are about 1000 articles with functions and code examples, simply, everything is possible within NSIS :-)
|
code: |
I dont quite understand. The following is the contents of my script. Where did I mess up?
code: Sorry to be a bother, but this is very new and confusing, and I am a hand on learner, so I will get the hang of this all by having someone explain it a bit and then doing it myself, but it's something I want to learn. |
Replace/add the lines in my upper post with the red lines in the followed post.
Don't forget on the top of your script the defines and the includes. Now you should have this: code: |
1 Attachment(s)
I'm so sorry...
I messed things a little :-) here is the right one, please doenload and test. |
Sigh...
I'm trying hard to get this, but here is my script, which you gave me most of. code: But after trying to compile that, I get this... code: I cant understand what part is wrong there, but im assuming its the: FileOpen $R2 w ; file to write line, that is missing something? Thanks btw for all your help so far. It's actually making sence, but I dont understand all those variables yet. |
Excellent! The file you sent works perfectly. Im going to study it thouroughly and incorporate it into the rest with my new values. Thank you so much.
|
You're welcome! and sorry for the mess...
This happens to me often when I try to write code straight in the reply window :-) A full screen editor is always required. |
| All times are GMT. The time now is 04:35. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.