- NSIS Discussion
- Looking for a Line Replacing Function. Word ANYWHERE, Replace Entire Line
Archive: Looking for a Line Replacing Function. Word ANYWHERE, Replace Entire Line
vbgunz
1st February 2005 14:54 UTC
Looking for a Line Replacing Function. Word ANYWHERE, Replace Entire Line
I've been looking for something like this and I cannot find it. I need a function that will open a file for writing. It is looking for any word which means the word does not have to be[list=1][*]on a line by itself[*]starting the line off[/list=1]
It seems every function I've come across on the archives in no way happens to do what I am trying to get done. I am simply trying to find a word in a file and then replace that words entire line.
This word can and will be 99% of the time[list=2][*]NOT on a line by itself[*]NOT starting the line off[/list=2]
I've tried working on my own script to accomplish this but it seems I can only get as far as replacing the word ONLY if it is on a line by itself. Can someone help lend me a hand on this please. World of thanks!
PS. I'd like to call this task the Afrow UK challenge. Sorry Afrow ;)
vbgunz
1st February 2005 18:23 UTC
I feel I should be a bit more descriptive with the kind of function I am seeking.
- It should not do a crazy loop. The new line might contain the old string again.
- No new line should be created above or below the target line.
- Possibility to find a string on the end of a line and replace ONLY everything before that string.
- Anything else you feel might be important to a function o fthis nature.
major thanks to anyone who can help with this :)
vbgunz
2nd February 2005 01:04 UTC
Here is that function created by the man ;)
http://nsis.sourceforge.net/archive/...91&instances=0
Comm@nder21
2nd February 2005 15:01 UTC
search the forums for WordFunc and TextFunc header files.
${WordFind}/${WordFind2X} and ${LineFind}/${LineRead} will do the trick.
vbgunz
2nd February 2005 16:23 UTC
Thanks Comm@nder21, I got it ;)
Afrow UK
2nd February 2005 17:11 UTC
vbgunz, the 2nd function you requested is ready. I shall upload it to the Archive now.
-Stu
Afrow UK
2nd February 2005 17:21 UTC
http://nsis.sourceforge.net/archive/...ances=0,11,311
It's a big function, but it works a brute!
-Stu
vbgunz
2nd February 2005 17:31 UTC
Amazing, Thank a mill!
vbgunz
2nd February 2005 17:47 UTC
Yak! I am certain the Function does as expected and I don't want you to change it so can you add a new Function with the ability to CopyBetween?
Ultimately, I was looking for a way to CopyBetween and put the copy into $0 and then use $0 as the value to ReplaceBetween. You understand?
Sorry if I mentioned it with misunderstanding. I do prefer though after looking at your function that they do stay seperated. Sharp.
File1
<yadda>
This is found in file1 and will be copied. A backup file exist and it is sort of like a database. It will basically serve so many different purposes.
<yadda />
File2
<yadda>
This is found in file1 and will be copied. A backup file exist and it is sort of like a database. It will basically serve so many different purposes.
<yadda />
Afrow UK
2nd February 2005 17:49 UTC
I understand. I shall make a similar function called GetBetween.
Meanwhile, I updated the ReplaceBetween function to make it a tiny bit faster.
-Stu
Afrow UK
2nd February 2005 18:15 UTC
Ok here it is:
http://nsis.sourceforge.net/archive/...ances=0,11,311
-Stu
vbgunz
2nd February 2005 22:03 UTC
Superb, you're indeed an NSIS pimp to be reckoned with. Thanks 2 mill ;)