|
|
#1 |
|
Junior Member
|
More text replacement woes...
I have read the docs. I have been searching these forums for hours. I still need help. I have installed and used the StrReplace and ReplaceInFile scripts from the Archive. I'm not a programmer by day, so bear with me, please. The closest solution to what I've found so far is HERE.
Basically, I want to do two things. I'll wait before posting the second one because hopefully I can learn how to do it from the response I get to this one. ----my text file---- asdfasdf CDPath=F: asdfasdf ----eof------------- Wherein F: can be anything, from blank, to a longer string. I have seen how to replace a full line, but not unless I match the string exactly. How can I flush the junk after the equals sign and keep the rest intact? I have used the ReplaceInFile !insertmacro, but that only works if my string matches exactly, and although I can "cheat" by inserting a $\r$\n, that still just moves the "junk" after the equals sign to another line I would still need to delete. I'm not a programmer by day, please forgive my noobishness... This isn't second nature to me yet, and I'm certain a NSIS whiz could do what I want in 5 minutes, which has taken me... longer than I care to admit.
|
|
|
|
|
|
#2 |
|
Moderator
Join Date: Nov 2002
Location: Shropshire, England
Posts: 6,887
|
I think this calls for another text manipulation function by Afrow!
Please bare with me and I will have one written shortly. -Stu |
|
|
|
|
|
#3 |
|
Moderator
Join Date: Nov 2002
Location: Shropshire, England
Posts: 6,887
|
Done:
http://nsis.sourceforge.net/archive/...b.php?page=626 You want to do this: code: -Stu |
|
|
|
|
|
#4 |
|
Junior Member
|
Thanks a ton. I had gone to the IRC chatroom yesterday where Anders gave me some useful code, but most of it was greek. I still want to use it to learn though, but yours is immediately helpful. Thanks very much, Afrow! I hope I can help my community as much as you help NSIS.
|
|
|
|
|
|
#5 |
|
Member
Join Date: Feb 2004
Posts: 58
|
sweet afrow..can this be made into a macro too?
|
|
|
|
|
|
#6 |
|
Moderator
Join Date: Nov 2002
Location: Shropshire, England
Posts: 6,887
|
...
code: -Stu |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Dec 2006
Posts: 7
|
Sorry for bumping such an old thread...
This function has been very helpful but it misses one important feature for me: If the searched string isn't found, I'd like to write the replacement string to a new line, instead of just dropping it. I know how to add the new line at the bottom of the file, but I need help with writing that exception. |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Dec 2006
Posts: 7
|
Some help please? Or am I missing something obvious?
|
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Dec 2006
Posts: 7
|
Nevermind, I eventually used the script to delete any previously existing matching lines and then added my lines at the bottom.
This worked for me because it doesn't matter where the new lines are. |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|