![]() |
Find and Replace within a text file
Hello,
I am a long time user of NSIS but only have a very superficial knowledge of what goes on under the hood. So please be very specific with what I need to do to get this to work if you can help. I've searched and found similar problems from other users but the answers appear to be more like 'hints' than instructions (I couldn't work them out at all). I essentially made a graphics mod installer for a game which just writes files into specific locations. The problem now is that the developer is updating the functionality of the game and adding options to the init file. My script simply replaces the whole init file (thus deleting any new options). What I want to do is have NSIS search through the existing init file and simply edit the lines with the new graphic options. There is no way of knowing if the line numbers will always be consistent (so I couldn't use LineFind), or if the option defaults will remain the same (so I need to be able to search using wildcards or partial lines). For example, I need to search through the file until it finds a line starting with: [GraphicOption: and then replace the whole line with: [GraphicOption: NewGraphicSet] I really hope someone can help me with this. I've looked at LineFind etc but I can't work them out. |
Here you are,
code: |
Thanks for your reply Red Wine.
I've tried to test the script but I am getting a compile error. I placed the macros at the end of the script with the page functions but the compiler is not recognizing them. I was also unsure if this script will completely replace the line of code, or just the searched text. It is important that the whole line be replaced. Thanks |
code: |
Quote:
Simply compile the provided example and watch the result if it satisfies you. |
Quote:
I got the script to compile, Red Wine, but it still doesn't replace the whole line. It only replaces the searched text. I'll try Instructor's script and report back. Thanks again |
Success!!
Thanks Instructor. This works perfectly. One more question. How do I hide the process from the user? Is there a command to not show the section when it executes? |
| All times are GMT. The time now is 04:41. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.