|
|
#1 |
|
Junior Member
Join Date: Dec 2007
Posts: 7
|
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. |
|
|
|
|
|
#2 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
Here you are,
code: Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Dec 2007
Posts: 7
|
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 |
|
|
|
|
|
#4 |
|
Major Dude
Join Date: Jul 2004
Posts: 671
|
code: |
|
|
|
|
|
#5 | |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
Quote:
Simply compile the provided example and watch the result if it satisfies you. Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
|
#6 | |
|
Junior Member
Join Date: Dec 2007
Posts: 7
|
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 |
|
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Dec 2007
Posts: 7
|
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? |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|